Reputation: 15
Basically, I want to multiply a user inputted value by a set value. The code works when multiplying to user inputs together, however, if I preset 'number' to a value (ex: 6), it will not do the multiplication and returns 0.
_start:
finit ; init. the float stack
output inprompt ; get radius number
input number, 12 ; get (ascii) value of this number
pushd NEAR32 PTR number ; push address of number
call atofproc ; convert ASCII to float in ST
fld st ; value1 in ST and ST(1)
mov number, 6
; If I substitute the line above by the two lines below, it works:
; output inprompt, 0
; input number, 12
pushd NEAR32 PTR number ; push address of number
call atofproc ; convert ASCII to float in ST
fmul ; value1*value2 in ST
fst prod_real ; store result
push prod_real ; convert the results for printing
lea eax, sum_out ; get the ASCII string address
push eax
call ftoaproc
output outprompt
Upvotes: 0
Views: 360
Reputation: 6846
You're trying to convert 6 from ASCII to float, and 6 is a non-printable character in ASCII so it can't be converted to float. You need to change 6 to 54, which is the ASCII representation of the character '6'
. Or you could pass the floating point constant 6.0 and delete the call to atofproc
if you prefer.
Upvotes: 1