I'm solving a school assignment and so far everything has been quite simple. However, I encountered the following piece of code:
mov 0x8(%ebp), %eax ;load pointer function argument into eax
mov (%eax), %eax ;dereference the pointer
test %eax, %eax ;
sete %dl ;test if it was 0
lea 0x1(%eax), %ecx ;???
mov 0x8(%ebp), %eax ;load the argument again
mov %ecx, (%eax) ;store whatever is in ecx on the pointed-to address
...
I'm really at my wit's end here, does the register have an address? Way I see it, the lea would store the address of eax (offset by 1) into ecx, but that doesn't make sense, does it?
lea 0x1(%eax), %ecx
loads the register %ecx
with %eax + 1
. The lea
instruction is commonly used for arithmetic computations, thanks to the relatively sophisticated addressing modes of this instruction set.
If you do not identify %eax
as an address, this is likely what is happening here (as Oli says, we don't have enough context to tell).