如何使用ASM中的浮点堆栈乘以2个数字(用户输入)?
我创建了一个PROC,该PROC将收集用户输入以达到余额,利率&单独文件中的期限(年数)。利率是浮点(分数数 - 不是整数)。我不确定我的平衡是否需要转换为浮点以使其乘以速率。
然后,我在单独的文件中原型原型并在main下打电话。我需要使用此公式: 利息=余额 *利率 / 100.0;计算利息。我正在努力增加平衡和速率。请指教。
该代码仅将利率自身乘以主要。
fmul ST(0), ST(0)
call writeFloat
balances.asm proc
yearlyBalance PROC
mov edx, OFFSET balanceNum
call writeLine
call readInt
fst bal
fld bal
mov edx, OFFSET interestRate
call writeLine
call readFloat
mov edx, OFFSET years
call writeLine
call readInt
endl
ret
yearlyBalance ENDP
main.asm
main PROC
call yearlyBalance
fmul ST(0), ST(0)
call writeFloat
endl
exit
main ENDP
END main
I've created a PROC that will gather user input for a balance, interest rate & length of term (# of years) in a separate file. The interest rate is a floating point (fractional number - not an integer). I'm not sure if my balance needs to be converted to a floating point to multiply it by the rate.
I then PROTOtype that PROC in the separate file and call under main. I need to use this formula:
interest = balance * rate / 100.0; to calculate the interest. I'm struggling to multiply the balance and rate. Please advise.
this code just multiplies the interest rate by itself in main.
fmul ST(0), ST(0)
call writeFloat
balances.asm PROC
yearlyBalance PROC
mov edx, OFFSET balanceNum
call writeLine
call readInt
fst bal
fld bal
mov edx, OFFSET interestRate
call writeLine
call readFloat
mov edx, OFFSET years
call writeLine
call readInt
endl
ret
yearlyBalance ENDP
main.asm
main PROC
call yearlyBalance
fmul ST(0), ST(0)
call writeFloat
endl
exit
main ENDP
END main
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用ReadFloat将第一值放在堆栈ST的顶部(0)(1st readFloat)
使用ReadFloat将值放在堆栈ST(0)的顶部,然后将第一个推到ST(1)(2nd ReadFloat)
使用FMUL ST (0),st(1)乘以两个数字并将结果放在st(0)
use readFloat to place first value on the top of the stack ST(0) (1st readFloat)
use readFloat to put value on top of the stack ST(0) and push the first to ST(1) (2nd readFloat)
use fmul ST(0), ST(1) to multiply the two numbers and puts the result at ST(0)