43.*_*4D. 22 x86 assembly reverse-engineering cmp ollydbg
如果我错了,请纠正我.
这是我对JNZ和的理解CMP.
JNZ- 如果Z标志不为零,将发生跳转(1)
CMP- 如果两个值相等,Z则设置标志(1),否则不设置(0)

这是我正在观看的flash教程.它正在教一个简单的CrackMe解决方案.
如您所见,前面的指令AL与之比较47h.他们是平等的,设置了Z旗帜.(你可以在右侧的Registers窗口中看到它)
下一条指令是a JNZ.我的理解是,如果Z设置了标志,将发生跳转.该Z标志设置,但跳就不会发生!
为什么?
Mic*_*kis 33
JNZ是"如果不为零跳转(ZF = 0)"的缩写,而不是 "如果设置了ZF则跳转".
如果它更容易记住,请考虑JNZ和JNE(如果不相等则跳跃)是等效的.因此,当你正在做cmp al, 47并且内容AL等于47时,设置ZF,不应该跳跃(如果不等于 - JNE).
joh*_*und 19
我会在这里做一些更宽泛的答案.
一般来说,x86中有两种类型的条件跳转:
算术跳转 - 如JZ(如果为零则跳转),JC(如果进位则跳转),JNC(如果不进行则跳转)等.
比较跳跃 - JE(跳跃如果相等),JB(跳跃如果下面),JAE(跳跃如果高于或等于)等.
因此,仅在算术或逻辑指令之后使用第一种类型:
sub eax, ebx
jnz .result_is_not_zero
and ecx, edx
jz .the_bit_is_not_set
Run Code Online (Sandbox Code Playgroud)
仅在CMP指令后使用第二组:
cmp eax, ebx
jne .eax_is_not_equal_to_ebx
cmp ecx, edx
ja .ecx_is_above_than_edx
Run Code Online (Sandbox Code Playgroud)
这样,程序变得更具可读性,您永远不会感到困惑.
请注意,有时这些说明实际上是同义词.JZ == JE; JC == JB; JNC == JAE等.全表如下.如您所见,只有16个条件跳转指令,但有30个助记符 - 它们是为了允许创建更可读的源代码而提供的:
Mnemonic Condition tested Description
jo OF = 1 overflow
jno OF = 0 not overflow
jc, jb, jnae CF = 1 carry / below / not above nor equal
jnc, jae, jnb CF = 0 not carry / above or equal / not below
je, jz ZF = 1 equal / zero
jne, jnz ZF = 0 not equal / not zero
jbe, jna CF or ZF = 1 below or equal / not above
ja, jnbe CF and ZF = 0 above / not below or equal
js SF = 1 sign
jns SF = 0 not sign
jp, jpe PF = 1 parity / parity even
jnp, jpo PF = 0 not parity / parity odd
jl, jnge SF xor OF = 1 less / not greater nor equal
jge, jnl SF xor OF = 0 greater or equal / not less
jle, jng (SF xor OF) or ZF = 1 less or equal / not greater
jg, jnle (SF xor OF) or ZF = 0 greater / not less nor equal
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
109264 次 |
| 最近记录: |