Is there a way to pop the address of the top of the stack and not the content? I want the address into a register and use it to manipulate program later.
Asked
Active
Viewed 45 times
1 Answers
3
In AT&T syntax:
leaq (%rsp), %rax
In Intel syntax:
leaq rax, [rsp]
or whatever register you need to use. rax is provided only as an example. The lea command loads the address specified into the register, not the content. For more information, see What's the purpose of the LEA instruction?
You also could do this with a simple mov:
mov %rsp, %rax
or
mov rax, rsp
If you need to actually modify the stack pointer, you can simply add the number of bytes necessary to it.