cmp %al, %cl
js x
I'm confused on what the js (jump on sign) is doing. Is it saying that if al is positive and cl is negative vice versa then jump?
Also, what happens if %cl
is 0?
The JB instruction branches to the address specified in the second operand if the value of the bit specified in the first operand is 1. The bit that is tested is not modified. No flags are affected by this instruction.
JA is used for jumping if the last "flag changing" instruction was on unsigned numbers. but on the other hand, JG is used for jumping if the last "flag changing" instruction was on signed numbers.
jae means Jump if above or equal. It will jump if the carry flag is equal to 0.
CX is known as the count register, as the ECX, CX registers store the loop count in iterative operations. DX is known as the data register. It is also used in input/output operations. It is also used with AX register along with DX for multiply and divide operations involving large values.
JS
will jump if the sign flag is set (by an earlier instruction). CMP will always modify the flags by performing a subtraction, in this case %cl - %al
.
(This is AT&T syntax, so cmp %cl, %al
is the same as Intel syntax cmp al, cl
)
Because of the operand-size of the instructions, the sign will be bit 7 of the expression %cl-%al
(which is thrown away; EFLAGS is updated just like sub
, but not al
.)
If al == 0
, then the temporary value will be cl
exactly and the sign will be the sign of the register cl
. Thus a jump is taken if cl
is negative.
Here's a reference for all the conditional jumps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With