@bpotts: It depends on the type of loan. All mortgages in the US are "simple interest" loans, i.e., they don't accrue interest on interest, just on the principal. There are two regularly used types of loans in this category. The majority of mortgages are monthly simple interest (also just known as a standard loan). What this means is interest is only accrued once per month (take the UPB at the end of the billing cycle and multiply that by your interest rate, then divide by 12 to determine interest accrued)
The other type is a daily simple interest, sometimes called a DSI. These are based on the actual number of days in the given time frame, so in a leap year, interest is accrued 366 times, while any other time it is accrued 365 times.
On a standard loan, the amount going to the principal is very straightforward -- every month will be slightly more than the previous month. With a DSI, you have a lot of other things that need to be factored in, including the day the previous month's payment was posted to the account, the day the current month's payment is posting to the account and the number of days in the month.