'How to multiply 2 numbers (user input) using the floating point stack in asm?
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
Solution 1:[1]
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)
Solution 2:[2]
XSD 1.1 allows what you are looking for: xs:all with a maxOccurs on each element particle.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Michael Kay |
