CSDN博客

（译）win32asm教程－6

7．0条件跳转

Code部分，你可以看到像这样的标签：

.code

mov eax, edx
sub eax, ecx
cmp eax, 2
jz loc1
xor eax, eax
jmp loc2
loc1:
xor eax, eax
inc eax
loc2:

xor eax, eax意为：eax=0）

mov eax, edx;把edx放入eax中

sub eax, ecx;eax-ecx

cmp eax, 2

Jz loc1

Cmp eax, 2；如果eax＝2设置零标志

Jz loc1；如果设置了零标志就跳转

＝如果eax等于2，跳往位于loc1的指令

if ((edx-ecx)==2)
{
eax = 1;
}
else
{
eax = 0;
}

IF (edx-ecx)=2 THEN
EAX = 1
ELSE
EAX = 0
END IF

3．  1标志寄存器

ZF（零标志）

SF（符号标志）

CF（carry标志）

Carry标志中有计算后最右的位。

OF（溢出标志）

7.2跳转系列

cmp x, y

jmp 如果 x 比 y大

 伪代码 意思 条件 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 equal CF=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 JGE Jump if greater or equal (signed) SF=OF JL Jump if less (signed) SF != OF JLE Jump if less or equal (signed) 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 below 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 greater (signed) ZF=1 or SF!=OF JNGE Jump if not greater or equal (signed) SF!=OF JNL Jump if not less (signed) SF=OF JNLE Jump if not less or equal (signed) ZF=0 & SF=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

0 0