7.0 Conditions Jump
In the Code section, you can see tags like this:
.code
MOV EAX, EDXSUB EAX, ECXCMP Eax, 2JZ LOC1XOR EAX, Eaxjmp Loc2loc1: xor Eax, Eaxinc Eaxloc2:
(Xor eax, Eax means: eax = 0)
Let's take a look at these codes:
MOV EAX, EDX; put EDX in EAX
SUB EAX, ECX; EAX-ECX
CMP EAX, 2
This has a new directive: CMP. CMP is Compare (compare). It compares two values (registers, memory, direct values) and sets z-flags (zero flags). The zero flag is very similar to Carry and one of the internal flag registers.
JZ LOC1
This is also new. It is conditional jump instruction. JZ = jump if zero (if a zero flag is set). LOC1 is a label of the OFFSET at the beginning of a tag directive "XOR EAX, EAX | Inc EAX". Thus JZ LOC1 = If a zero flag is set, jump to the directive located in LOC1.
CMP Eax, 2; if eax = 2 set zero flag
JZ LOC1; if a zero flag is set, jump
= If EAX is equal to 2, jump to the directive located in LOC1
Then there is JMP LOC2. This is also like a jump, but it is an unconditional jump: it is always executed. The above code is:
IF ((EDX-ECX) == 2) {EAX = 1;} else {EAX = 0;}
Or Basic version:
IF (EDX-ECX) = 2 THENEAX = 1ELSEEAX = 0nd IF
3. 1 logo register
The flag register has a set of flags. They do not set depending on calculation or other time. I will not discuss all of them. I only picked a few important saying:
ZF (zero sign)
When the computing structure is zero, the flag is set (COMPARE is actually set only if the flag does not save structure)
Sf (symbol sign)
Structure is negative setting
Cf (Carry Sign)
The carry flag has the rightmost bit after calculation.
Of (overflow sign)
Indicates an overflow calculation. As, structures and goals do not match.
There are more symbols (Parity, Auxiliary, Trap, Interrupt, Direction, IOPL, NESTED TASK, RESUME, & VIRTUAL MODE), but I don't explain because we don't need them.
7.2 Jump series
There is a set of conditions jump, and they are jumping or not, depending on the status of the flag. However, because most jump instructions have a clear name, you don't even need to know which flag is to be set, for example: "If it is equal to the jump" (JGE) and "Symbol flag = overflow flag", "if the zero jump Turn "and" If zero flag = 1 jump ".
In the following table, "Meaning" means what kind of calculation results that the jump. "If you are more jumped" means:
CMP X, Y
JMP if X ratio Y
Fake code
meaning
condition
Ja
JUMP IF ABOVE
Cf = 0 & zf = 0
Jae
Jump if Above or equal
Cf = 0
JB
Jump if Below
Cf = 1
Jbe
JUMP if Below or equalcf = 1 or zf = 1
JC
JUMP IF Carry
Cf = 1
JCXZ
JUMP IF CX = 0
Register CX = 0
JE (is the Same As JZ)
Jump if equal
ZF = 1
JG
JUMP if Greater (Signed)
ZF = 0 & sf = of of
JGE
Jump if Greater or equal (Signed)
Sf = of
JL
Jump if less (Signed)
Sf! = Of
Jle
Jump if less or equal (sign)
Zf = 1 or sf! = Of
JMP
Unconditional Jump
-
JNA
Jump if not above
Cf = 1 or zf = 1
JNAE
Jump if not above or equal
Cf = 1
JNB
Jump if not belew
Cf = 0
JNBE
Jump if not below or equal
Cf = 1 & zf = 0
JNC
JUMP IF NOT CARRY
Cf = 0
JNE
Jump if not equal
ZF = 0
JNG
Jump if not get (SIGNED)
Zf = 1 or sf! = Of
JNGE
Jump if not get or q (SIGNED)
Sf! = Of
JNL
Jump if not less (sign)
Sf = of
JNLe
Jump if not less or equal (signed)
ZF = 0 & sf = of of
JNO
Jump if not overflow (Signed)
Of = 0
JNP
Jump if no parity
PF = 0
JNS
JUMP if not Signed (Signed)
Sf = 0
JNZ
Jump if not Zero
ZF = 0
JO
JUMP if overflow (Signed)
Of = 1
Jp
Jump if Parity
PF = 1
JPE
Jump if Parity Even
PF = 1
JPO
Jump if Paity ODD
PF = 0
JS
Jump if Signed (Signed)
Sf = 1
JZ
Jump if zero
ZF = 1
All jump instructions require a parameter: to jump to the offset.