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 or nothing is in it?
Thanks!
Join Stack Overflow to learn, share knowledge, and build your career.
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 %al - %cl
. (assuming Intel syntax, not AT&T).
Because of the length of the instructions, the sign will be the bit 7 of the expression %al-%cl (and which is thrown away).
If %cl == 0, then the temporary value will be %al exactly and the sign will be the sign of the register %al. Thus a jump is taken, if %al is negative.
Here's a reference for all the conditional jumps.