我这里有我的代码,但我不知道如何声明、输入和输出浮点型数字。在 c 中,%f 用于浮点数。我在我的代码中尝试过,但它不起作用。我也试过 REAL 8。这是我的代码。我知道 %d 是整数,但是当我使用 %f 时,输出是 0.000000 我无法输出确切的答案。
.386
.model flat, c
.stack 100h
printf PROTO arg1:Ptr byte, printlist:VARARG
scanf PROTO arg2:Ptr byte, inputlist:VARARG
.data
in1fmt byte "%d" , 0
msg1fmt byte 0Ah, "%s" , 0
msg2fmt byte 0Ah, 0Ah, "%s" , 0
msg3fmt byte 0Ah,"%s%d" , 0Ah, 0Ah, 0
msg4fmt byte 0Ah,"%s%d" , 0Ah, 0Ah, 0Ah, 0Ah, 0
msg5fmt byte 0Ah, "%s%d" , 0Ah, 0Ah, 0
msg1 byte "Enter any number: " , 0
msg2 byte "Enter another number: " , 0
msg3 byte "The sum is: " , 0
msg4 byte "The product is: " , 0
msg5 byte "The largest is: ", 0
num1 sdword ?
num2 sdword ?
sum sdword ?
product sdword ?
largest sdword ?
.code
main proc
INVOKE printf, ADDR msg1fmt, ADDR msg1
INVOKE scanf, ADDR in1fmt, ADDR num1
INVOKE printf, ADDR msg2fmt, ADDR msg2
INVOKE scanf, ADDR in1fmt, ADDR num2
mov eax, 0
mov eax, num1
add eax, num2
mov sum, eax
mov eax, 0
mov eax, num1
imul num2
mov product, eax
mov eax, 0
add eax, num1
.if eax > num2
mov eax, num1
mov largest, eax
.else
mov eax, 0
add eax, num2
mov largest, eax
.endif
INVOKE printf, ADDR msg3fmt, ADDR msg3, sum
INVOKE printf, ADDR msg4fmt, ADDR msg4, product
INVOKE printf, ADDR msg5fmt, ADDR msg5, largest
ret
main endp
end