Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 14th East European Conference Adbis 2010 Novi Sad Serbia September 2010 Proceedings Lncs 6295

Authors: Barbara Catania ,Mirjana Ivanovic ,Bernhard Thalheim

2010th Edition

3642155758, 978-3642155758

More Books

Students also viewed these Databases questions

Question

Explain strong and weak atoms with examples.

Answered: 1 week ago

Question

Explain the alkaline nature of aqueous solution of making soda.

Answered: 1 week ago

Question

Comment on the pH value of lattice solutions of salts.

Answered: 1 week ago