The FPU's condition flags have completely different meanings than the condition flags in the EFLAGS register.
If Sum
is greater than C
, then the ficom
will set the FPU condition flags to "C3=0, C2=0, C1=0". When loaded into the CPU's EFLAGS register (via. fstsw
and sahf
) this becomes "ZF=0, PF=0, CF=0". The jg
instruction will branch if "ZF=0" and "SF=0" - it won't test the PF flag or the CF flag at all, but will test the irrelevant SF flag.
Given that you're comparing integers anyway; you should probably just do:
mov eax,[Sum]
cmp [C],eax
jg m1
The alternative is to test the flags in AX directly. For example:
ficom C
fstsw AX
test AX,0x4500 ;Are C3, C2 and C0 clear?
je m1 ; yes, Sum must be greater than C