I just started with assembly and it's going great, but there's 1 thing that I just don't understand. How do conditional jumps work?
I have a sample of assembly code here.
TEST EAX, EAX
FCLEX
JGE SHORT 004022B1
I see that when a certain condition is greater or equal, a jump will be made to 004022B1.
But what is that condition and where is it checked?
I assume the condition must be TEST EAX,EAX. But I'm not sure what it does.
Can anyone explain to me how conditional jumps work and where the condition is checked/stored?
Conditional jumps (and some other instructions) use flags. These flags are bits in the (E/R) FLAGS register. test a, b
sets the flags according to the result of and a, b
, without updating a
with the result. fclex
does not change any normal flags (it changes FPU flags of course).
jge
tests* whether the value of the sign flag is equal to the overflow flag. test a, b
sets the overflow flag to zero and the sign flag to the signbit of the result of and a, b
. So the jump will be taken if eax
is positive.
*: note that it does not test for "greater or equal". That interpretation is valid when the flags are checked after a cmp
(and some other instructions). It really just looks at the flags.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.