c - GDB / GNU assembly: test %esi,%esi returns not equal? -
i'm working on homework assignment. we're given pre-compiled binary , have use gdb
assembly dumps, traverse data structures, view values stored in memory, etc. in order puzzle out binary does. here few lines of disassembler dump function call:
0x08048e14 <+21>: test %esi,%esi 0x08048e16 <+23>: jne 0x8048e4b <fun6+76> 0x08048e18 <+25>: jmp 0x8048e5d <fun6+94>
i assumed test %esi,%esi
return result of "equals" (or, rather, equivalent statement expressed using register flags, believe zf
set?), , jne
instruction never execute, , instead program execute instruction @ line <+25>
. however, after stepping through these instructions, program jumps line <+76>
! why happen? baffled.
in case helps explain answer, here register flags after test
instruction @ line <+21>
(zf
isn't set?)(i still don't know how interpret flags):
eflags 0x202 [ if ]
the test
instruction performs bitwise and
, not store result; sets flags.
and jne
"jump if zf
not equal 0", here it's testing if esi
zero.
also see how `test` instruction work? , what `test` instruction do?
Comments
Post a Comment