I'm working on a MASM32 project that performs arithmetic operations. We have to use the coprocessor (8087 instruction set) to use the floating point unit. So, supose my floating point limit is 100.0
then every number must be less than the limit. I'm trying to sum two numbers and then compare the result but it doesn't work.
.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
My question is: what i'm doing wrong? How can it fix it? Thanks!