Possible Duplicate:
x86 Assembly - ‘testl’ eax against eax?
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
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>
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?
I'm a beginner to programming in general, so I'd appreciate it very much if someone could explain this to me. Thanks!