【发布时间】:2017-11-02 04:01:00
【问题描述】:
我正在开发一个执行算术运算的 MASM32 项目。我们必须使用协处理器(8087 指令集)才能使用浮点单元。所以,假设我的浮点限制是100.0,那么每个数字都必须小于限制。我试图将两个数字相加,然后比较结果,但它不起作用。
.386
.model flat, stdcall
option casemap :none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
include c:\masm32\include\masm32rt.inc
.data
;Variables de comparación.
FP_max DD 100
;Variables volcadas de la tabla de símbolos.
_a DD 25
_b DD 80.0
.code
start:
fild _a
fild _b
fadd
fcom FP_max ;compare ST(0) with the value of the real8_var variable
fstsw ax ;copy the Status Word containing the result to AX
sahf ;transfer the condition codes to the CPU's flag register
ja overflow ;when all flags are 0
jmp end_program
overflow:
print "ERROR: overflow.", 13, 10, 0
jmp end_program
end_program:
invoke ExitProcess, 0
end start
我的问题是:我做错了什么?它怎么能解决它?谢谢!
【问题讨论】:
-
您可以直接使用
fcomi设置标志,就像您使用fstsw ax/sahf一样。 (我认为需要 ppro,即过去 20 年的任何 x86。)