测试%EAX%EAX点 [英] The point of test %eax %eax
问题描述
可能重复:结果
x86汇编 - 对EAX为test1EAX
我非常非常新的汇编语言编程,和我目前正在读从二进制产生的汇编语言。我穿过
I'm very very new to assembly language programming, and I'm currently trying to read the assembly language generated from a binary. I've run across
test %eax,%eax
或测试%RDI,RDI%
,等等,等等,我来这是什么一样很迷茫。是不是在%EAX,EAX%
的值相同?它是什么测试?我读的地方,它是做和
操作.....但因为它们是相同的值,是不是只是返回%EAX
?
or test %rdi, %rdi
, etc. etc. I'm very confused as to what this does. Isn't the values in %eax, %eax
the same? What is it testing? I read somewhere that it is doing the AND
operation.....but since they are the same value, wouldn't it just return %eax
?
下面就是一个例子,我发现这种用法:
The following is just one instance where I found this usage:
400e6e: 85 c0 test %eax,%eax
400e70: 74 05 je 400e77 <phase_1+0x23>
我觉得 JE
如果进行比较的两个值跳跃都是平等的......好,因为%EAX
很好,本身在什么情况下,我们会不会跳?
I thought je
jumps if the two values being compared are equal......well, because %eax
is well, itself, in what situation would we NOT jump?
我是一个初学者在一般的编程,所以我倒是AP preciate非常喜欢,如果有人可以给我讲解一下。谢谢!
I'm a beginner to programming in general, so I'd appreciate it very much if someone could explain this to me. Thanks!
推荐答案
CMP
减去操作数,并设置标志。即,它设置零标志,如果该差为零(操作数相等)
CMP
subtracts the operands and sets the flags. Namely, it sets the zero flag if the difference is zero (operands are equal)
测试
设置以Z
ERO ˚F
滞后,如果的与操作的结果是零。如果两个操作数相等,它们的位与为零当且仅当两者都为零。它还设置了取值
IGN ˚F
滞后,如果最高位在结果集,而 p
元数˚F
滞后,如果设置位的个数为偶数。
TEST
sets the Z
ero F
lag if the the result of the AND operation is zero. If two operands are equal, their bitwise AND is zero iff both are zero. It also sets the S
ign F
lag if the top bit is set in the result, and the P
arity F
lag if the number of set bits is even.
JE
[跳转如果等于]测试零标志,如果标志设置跳跃。 JE
是 JZ
的别名[跳转,如果零]因此基于运$ C $拆装器不能选择一个C。因为零标志设置如果参数 CMP
都是平等的。
JE
[Jump if Equals] tests the zero flag and jumps if the flag is set. JE
is an alias of JZ
[Jump if Zero] so the disassembler cannot select one based on the opcode. JE
is named such because the zero flag is set if the arguments to CMP
are equal.
因此,
TEST %eax, %eax
JE 400e77 <phase_1+0x23>
跳转如果%EAX
是零。
这篇关于测试%EAX%EAX点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!