Y86 is similar to x86-64. Why function pushtest always returns zero?
As I know on x86-64 Push decrements the ESP register first than writes.
Pop read first than increments the ESP register.
.text
.globl pushtest
pushtest:
movq %rsp, %rax
pushq %rsp
popq %rdx
subq %rdx, %rax
ret
First. You should not modify
%rsp(which is Stack Pointer register) manually, don't domovq %rsp, .... The%rspis (and must only be) managed bypush,pop,call,ret. Check also this question.Then it's always
%rdx==0 at the end, because: