0
基本上,我想將用戶輸入值乘以設定值。乘以當用戶輸入在一起,但是,如果我預設「號」的值(例如:6)該代碼的作品,它不會做乘法並返回0在x86彙編中需要使用FPU進行乘法運算
_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
您確定這是64位MASM代碼?看起來像32位。我問,因爲你添加的標籤。 –
完成後,您不會彈出FP堆棧。你應該使用'fmulp'和'fstp'。我也不明白你爲什麼用'fld st'複製第一個值。另外,除非您需要使用LEA來使用RIP相對尋址來生成與位置無關的代碼,否則可以使用'push offset sum_out'設置arg to'ftoaproc'。而且,不是將其存儲到'prod_real'然後推送它,您可以在堆棧上創建空間並存儲到該空間中。 –