brenden
brenden

Reputation: 604

Is it specified what happens when the stack pointer is pushed on x64?

I am programming in assembly on x64, and I intend on pushing an address within the stack. I intend on writing push %rsp, however, as this instruction changes the value of %rsp, I am not sure what value will be pushed.

Specifically if I run the following:

movq $0x10, %rsp
pushq %rsp

Will the memory address 0x8 contain 0x10 or 0x8? Is this processor dependent or is it standard across all x64 processors?

Upvotes: 1

Views: 736

Answers (1)

brenden
brenden

Reputation: 604

As @Raymond Chen mentioned in the comments, it is specified in Intel's manual, HTML extract here: https://www.felixcloutier.com/x86/push.

The value pushed is the value of %rsp before the push instruction.

Same for push mem with an addressing mode involving RSP, like push 16(%rsp) to copy something already on the stack.

Upvotes: 5

Related Questions