ja
needs CF==0 and ZF==0. It doesn't check OF. In x87 flags this means C0==0 and C3==0. It's exactly condition that ST(0) > ST(1) for the comparing using FCOM
, FCOMP
, etc.
You shouldn't be confused with formal condition difference (as ja
is for comparing unsigned numbers) because x87 condition flags differ and are passed here using special transport. It could be even possible to see absolutely mismatching conditions, but Intel tried to provide at least far similarity between conditions and checking instructions.
OTOH, jg
, yes, checks very other conditions with bits that aren't passed using fstsw
+sahf
. So it isn't applicable here even if is named the same as needed condition.
This is legacy issue, as well as tons of other x86 strange solutions. (30+ years of developing without redesign from scratch doesn't give a consistent result. OTOH, all they are well documented so you should just follow the known recipes.)
UPDATE: btw, you can alternatively skip sahf
and check the flags directly:
fstsw ax
test ax, 4100h
jz nie_odejmuj
It is longer in code but expresses the method more clearly.