Question: Create a procedure called yearlyBalance that uses a given interest rate, balance, and term to output a table of adjusted balances each year for the

Create a procedure called yearlyBalance that uses a given interest rate, balance, and term to output a table of adjusted balances each year for the number of years specified by the term. For this lab you will use a simplified formula:
interest = balance * rate /100.0;
Pass the initial balance and rate and number of years to the procedure on the floating point stack. Then, using a for loop output the table. Basically you want to add the interest to the balance each year (each time through the loop)
Required:
The yearlyBalance procedure must be in a separate asm file called balances.asm. This means you should have main.asm and balances.asm. You can format these as you normally do and paste them one after the other in the submissions box.
If you do not understand how to create multiple file projects please go to this page.
The following shows an example output:
Enter your balance
1000
Enter the interest rate (like 5.0)
5.0
Enter the number of years
10
Year: 1: $1050.00
Year: 2: $1102.50
Year: 3$1157.63
Year: 4: $1215.51
Year: 5: $1276.28
Year: 6: $1340.10
Year: 7: $1407.10
Year: 8: $1477.46
Year: 9: $1551.33
Year: 10:$1628.89
Press any key to continue ...
NOTE:
You are not to use any .IF .ELSE, .WHILE, or .ENDW instructions. You are to use pure old-fashioned assembly language to solve this.
The use of legacy directives like DB and DW is not allowed in this class. A deduction of 40% will be given if you use them.
The use of indirect addressing around variables is NOT allowed in the class unless you are using indirect addressing. An example of this would be [val1]. Doing this will result in a 25% reduction in your grade.
You must comment every line of code you write or your grade will be reduced 20%
This is what I got so far
; main.asm - Main file that gathers input and calls the yearlyBalance procedure
INCLUDE asmlib.inc ; Include assembly library for I/O operations
yearlyBalance PROTO
.DATA
balancePromptMsg BYTE "Enter your balance", 0
ratePromptMsg BYTE "Enter the interest rate (like 5.0)",0
yearsPromptMsg BYTE "Enter the number of years", 0
.CODE
main PROC
; Prompt user for initial balance
mov edx, OFFSET balancePromptMsg
call WriteString ; Display "Enter your balance"
call ReadFloat ; Read the initial balance as a float
; Prompt user for interest rate
mov edx, OFFSET ratePromptMsg
call WriteString ; Display "Enter the interest rate"
call ReadFloat ; Read the interest rate as a float
; Prompt user for number of years
mov edx, OFFSET yearsPromptMsg
call WriteString ; Display "Enter the number of years"
call ReadInt ; Read the number of years as an integer
push eax ; Save years to the stack (push integer argument)
; Call yearlyBalance procedure
call yearlyBalance
; Exit the program
ret ; Return to the operating system
main ENDP
END main

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!