Hi I am new to assembly language and I am getting confused about the syntax of lea instruction I have seen when I study a piece of code ( which is generated by using gdb command : disassemble main ).
lea 0xa8e96(%rip),%rsi # 0x4aa5df
The syntax I have seen for lea is
lea src, dest
But it seems like there is an additional immediate value ( # 0x4aa5df ) following the %rsi register, how should I interpret this correctly?
Edit: I have checked the value stored in the %rip register which is
(gdb) p /x $rip
$1 = 0x401730
So adding this with the 0xa8e96 gives me 0x4AA5C6 which does not match 0x4aa5df, am I missing something here ?
rip + 0xa8e96 = 0x4aa5df
). It's not part of the instruction. – Jesterlea
instruction for what the processor will take as%rip
during that instruction's execution. You don't want any old value in%rip
as%rip
changes at every instruction -- it would only make sense if you are currently stopped at thelea
, in which case the value will be the address of thelea
instruction.. – Erik Eidtbase(rb, re, n)
(where you can leave out some of these fields if they arent needed), where the calculated address isbase + rb + n * re
wherebase
andn
are immediate values andrb
and re` are values from those registers. – Unnrip
already points past thelea
so the address of the next instruction should be used. – Jester