What's mean lea 0x4(%esp),%ecx
in at&t assembly? What really is 0x4(%esp)?
views:
68answers:
3
+2
A:
It's %esp + 0x4
.
LEA
stands for Load Effective Address. It's, in this case, a simple addition, as shown above. Typically people and compilers don't really use it anymore because CPUs now ship with a nifty address generation unit (otherwise called AGU), which lets you use all kinds of fancy arithmetics to compute addresses from registers and values. In short, whatever you did with lea
, you can now embed it inside any other instruction.
zneak
2010-08-13 23:01:46
Uh, `lea` instructions are just under 10% of _all_ instructions generated for the code I happen to be working on right now. It may be true that on x86 you can embed any `lea` operation in a load or store operation (I rather doubt that, honestly), but code is still chock full of pointer arithmetic that doesn't necessarily involve a load or store.
Zack
2010-08-13 23:43:33
I'm not the person who downvoted you, but, um, you know the joke about the helicopter pilot and Microsoft technical support?
Zack
2010-08-13 23:44:59
Jens Björnhager
2010-08-14 13:24:28
+1
A:
esp
is the stack pointer. 0x4 is the offset. AT&T syntax has the command source, destination
and the command here is LEA
which is "Load Effective Address."
So we're telling the CPU to load the address "stack pointer + 4" into the register "ecx"
Computer Guru
2010-08-13 23:13:46