Question: I currently have this assembly code written but i need to pass the initial balance and rate and number of years to the procedure on

I currently have this assembly code written but i need to pass the initial balance and rate and number of years to the procedure on the floating point stack, which I am having difficulty doing. In yearlyBalance, I need to use a for loop to output the table, where we want to add the interest to the balance each year, each time through the loop. Below is the code I currently have. INCLUDE asmLib.inc
yearlyBalance PROTO
.data
promptBalance BYTE "Enter your balance", 0
promptRate BYTE "Enter the interest rate (like 5.0)",0
promptYears BYTE "Enter the number of years", 0
balance DWORD 0.0
rate REAL40.0
term DWORD 0
.code
main PROC
mov edx, OFFSET promptBalance
call writeLine
call readInt
mov [balance], eax
mov edx, OFFSET promptRate
call writeLine
call readFloat
fstp rate
mov edx, OFFSET promptYears
call writeLine
call readInt
mov [term], eax
push [balance]
push [rate]
push [term]
INVOKE yearlyBalance
pop [balance]
pop [rate]
pop [term]
exit
main ENDP
INCLUDE asmLib.inc
.data
outputYears BYTE "Year: ",0
outCol BYTE ": ",0
dollarSign BYTE "$",0
balance DWORD 0.0
rate REAL40.0
term DWORD 0
.code
yearlyBalance PROC
mov ecx, [esp +4]
push 100
fild dword ptr[esp]
pop ebx
fld dword ptr[esp +8]
fdiv ST(0), ST(1)
fstp ST(1)
push 1
fild dword ptr [esp]
pop ebx
fadd ST(0), ST(1)
fstp ST(1)
fild dword ptr [esp +12]
mov ebx, 1
l1:
cmp ebx, ecx
jg ex
; Loop body
mov edx, offset outputYears
call writeString
mov eax, ebx
call writeInt
mov edx, offset outCol
call writeString
mov edx, offset dollarSign
call writeString
fmul st(0), st(1)
call writeFloat
endl
inc ebx
jmp l1
ex:
ret
yearlyBalance ENDP
END
END main Balance, rate, and term all need be passed on the floating-point stack. The calculations are proving to be diffucult. When using the FPU, i have issues with the loop running endlessly.

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 Databases Questions!