代写 math assembly CS237 Spring 2019

CS237 Spring 2019
Machine Organization & Assembly Language Programming
Programming Assignment #2
100 Points
Due Date/Time: The program is due Tuesday, March 26th at the beginning of class.
The program:
For this assignment, you will write an assembly language program to determine the future value of an investment to which you contribute monthly. Example: Suppose you inherit $50,000.00 and deposit it in a money market account. You then add $1000.00 per month to this account. How much money will the account have in 10 years? In 20 years?
The formula for this is in two parts:
Compound Interest for Principal (initial investment)
P * (1 + r/n)(n*t)
Future Value of a Series (the monthly deposits)
p * (((1 + r/n)(n*t) – 1) / (r/n)) * (1 + r/n)
The sum of the two above formulae will give your answer Variables:
P = The initial investment
p = The monthly deposit
r = Annual interest rate in decimal. [6% is .06]
n = Number of compounds per period. Hardcode this to 12. t = Number of years.
Given these input variables, you will determine the future value of an investment.
[NOTE: There are many financial formulae available for calculating the value of investments and growth. However, as this is a computer science class, not a business class, we will not consider the merits of one formula over another. You must use the exact formulae given above to receive any credit for the assignment.]
You will need to use the floating point macros for this assignment. Be sure to uncomment the initF macro:
start: initIO * Initialize (required for I/O)
setEVT * Error handling routines

initF * For floating point macros only <-------- Documentation on the macros is available online (Course Documents link at left) and in the lecture notes. The only integer instruction useful for floating point numbers is move.l. For other instructions, use the floating point macros. Additional details: As much as possible, use data registers rather than memory for calculating and storing your results. Your answer should be printed with a $ sign and two digits to the right of the decimal point. You are not required to validate input. Your program must be named prog2.s. Your program must assemble with no warnings or errors. Note: The fpow function is slow, and may take a few moments to run. This is normal. Try not to recalculate the same value more than once. Floating point arithmetic is inherently imprecise. Therefore, your answer may differ slightly from the most precise answer. The fpow function does many calculations and is more subject to rounding errors then the other arithmetic operators. However, deviation by more than a .01% indicates a poor implementation of the problem. That is, multiply the correct answer by .0001. If your prog2 answer differs by more than that amount, your implementation is lacking. Because the floating point macros truncate and do not ever round up, your prog2 answer should consistently be smaller than the correct answer. A large number of digits will cause more rounding--and more error--than numbers with fewer digits. IMPORTANT: Mathematically X * Y / Z is the same as Y / Z * X. However, with floating point arithmetic the answers may not be equal at all. Therefore, preserve the order of operators Output: First, your program will print a title line which includes the assignment number, your class account number, and your name. Then your program will prompt the user to enter the four variables one at a time in the exact order specified above (P, p, r, t). There will be a grade deduction for variables requested out of order. Your program will sum the two formulae given above to get the final answer. Then, your program will print the results. At the end of the given period your investment will be worth $xx.xx>. Example:
Program #2, Susie Student, csscxxxx
Please enter the initial investment
5000
Please enter the monthly deposit amount
100
Please enter the annual interest rate in decimal (i.e. .06 not 6%)
.06
Please enter the number of years
10
At the end of the given period your investment will be worth $25566.52
Extra Credit
Very efficient (and accurate) programs will be eligible for up to 20 points (20%) extra credit. The grader will count the number of lines of code in your program, and compare your number with the other students in the

class. The programs that use the fewest instructions will receive extra credit, amount to be determined by me. The rules:
IMPORTANT Neither the grader nor your instructor can provide any help with the extra credit portion. You must do it entirely on your own.
Your program must be completed and correctly submitted on time to receive any extra credit. You may turn your program in up to one week late, but late programs cannot receive extra credit.
No extra credit can be awarded to programs that are not completely accurate. Programs that have points deducted for any reason are not eligible for extra credit.
I cannot speculate in advance the number of lines needed for extra credit.
At least 10% of the class will get extra credit, provided that at least 10% of the students meet the above criteria.
Program Submission:
Be sure to check the Submission Guidelines link. As with the last assignment, you must copy your prog2.s source code file in your handin/ directory. Do not submit a hardcopy printout of your code. The timestamp on your file will be used to determine when your program was submitted.
As usual, programs may be submitted up to one week late with a 5% per day penalty. Days begin and end at 2:00 PM, the time our class starts.
Cheating Policy
There is a zero tolerance policy on cheating in this course. You are expected to complete all programming assignments on your own. Collaboration with other students in the course is not permitted. You may discuss ideas or solutions in general terms with other students, but you must not exchange code. (Remember that you can get help from me. This is not cheating, but is in fact enouraged.) I will examine your code carefully. Anyone caught cheating on a programming assignment or on an exam will receive an “F” in the course, and a referral to the Office for Student Rights and Responsibilities.