Could someone with a higher knowledge than mine please explain why this code snippet doesn't work?
Code: Select all
MODE 1
DIM Deax 3
DIM primary 7
DIM secondary 7
DIM answer 3
DIM code% 1024
FOR I% = 0 TO 2 STEP 2
P% = code%
[
OPT I%
.calculate
fninit
mov eax, 0
mov DWORD [Deax], 0
fld QWORD [secondary]
fld QWORD [primary]
fcompp
wait
fstsw ax
mov [Deax], eax
sahf
je equal
jg greater
jl lower
ret
.equal
mov DWORD [answer], 0
ret
.greater
mov DWORD [answer], 1
ret
.lower
mov DWORD [answer], 2
ret
]
NEXT I%
CLS
INPUT"Number 1 ";num1
INPUT"Number 2 ";num2
|primary = num1
|secondary = num2
CALL calculate
PRINT "0 = Numbers are equal"
PRINT "1 = Number 1 is greater"
PRINT "2 = Number 2 is greater"
PRINT
PRINT "Answer = ";!answer
PRINT "Value in eax ";!Deax
END
The results is eax are always the same for the same comparison so i could use that but it would be nice to use the correct code.
Regards Ric