该汇编代码有什么作用? (测试,异或,JNZ) [英] What does this assembly code do? (TEST,XOR,JNZ)
问题描述
1.
TEST EAX,EAX
JNZ SHORT program.00407190
2.
XOR EAX,EAX
JNZ SHORT program.00407190
如果我错了,请纠正我.谢谢! :)
Kindly correct me if I'm wrong. Thank you! :)
根据我到目前为止的理解:
From my understanding so far:
JNZ
如果不等于零,则为跳转,取决于ZF
是否设置为1,它是否跳转.如果为1,则不会跳转.否则,它会跳起来.
JNZ
is jump if not equal to zero, it will jump or not depending on whether ZF
is set to 1 or not. If it's 1, it will not jump. Else, it will jump.
据我对代码#1的理解,TEST EAX,EAX
将检查其是否为零.如果不等于零(ZF
为0),它将跳转到地址00407190.
From my understanding for code #1, TEST EAX,EAX
will check whether it's zero or not. If it's not equal to zero(ZF
is 0), it will jump to address 00407190.
对于代码2
XOR EAX,EAX
会将EAX寄存器设置为0.它会设置任何标志吗?如果不是,JNZ
指令如何确定是否跳转?
For code #2
XOR EAX,EAX
will set EAX register to 0. Does it set any flags? If not, how does JNZ
instruction determine to jump or not?
最后,为什么人们要检查EAX
是否为0?请帮助我进行更简单,详细的说明,我仍然是初学者.
Lastly, why would people want to check if EAX
is 0 or not? Kindly please assist me in a easier and detailed explanation, I'm still a beginner.
推荐答案
TEST
和XOR
是用于对操作数执行逻辑运算的逻辑指令.
TEST
and XOR
are logical instructions used to perform logical operations on the operands.
测试指令(比较操作数)
TEST destiny, source
它逐个执行操作数的合取,但与AND
不同,该指令不会将结果放入目标操作数中,仅影响标志的状态.
It performs a conjunction, bit by bit, of the operands, but differing from AND
, this instruction does not place the result in the destination operand, it only has effect on the state of the flags.
Source Destiny | Destiny
--------------------------
1 1 | 1
1 0 | 0
0 1 | 0
0 0 | 0 <---
异或指令(异或)
XOR INSTRUCTION (Exclusive OR)
XOR destiny, source
其功能是对两个操作数进行逻辑异或运算.
Its function is to perform the logical exclusive disjunction of the two operands bit by bit.
Source Destiny | Destiny
--------------------------
1 1 | 0 <---
1 0 | 1
0 1 | 1
0 0 | 0 <---
如表所示:
As you see in the tables:
XOR EAX,EAX
将EAX
寄存器设置为零.如果XOR
的结果为零,则将设置ZF
.因此,在这种情况下:(ZF=1
)
XOR EAX,EAX
will set the EAX
register to zero. The ZF
will be set if the result of the XOR
is zero. So in this case: (ZF=1
)
TEST EAX,EAX
不会将结果放置在寄存器中,它只会影响ZF
的状态.在这种情况下,如果EAX == 0
,则(ZF=1
)
TEST EAX,EAX
does not place the result on the register, it only has effect on the state of the ZF
. In this case if EAX == 0
, then (ZF=1
)
JNZ(JNE)指令(视情况而定)
JNZ label
如果不等于或为零,则跳转到label
.如果禁用ZF
,则将完成跳转. (ZF=0
)
It jumps to label
if it is not equal or zero. The jump will be done if ZF
is deactivated. (ZF=0
)
这篇关于该汇编代码有什么作用? (测试,异或,JNZ)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!