Reputation: 1
I'm having some trouble understanding beginning assembly. I'm supposed to be writing a program which adds two or subtracts two numbers that are command line arguments.
The problem arises when I call a subroutine. It seems to change my stack, with no push/pop interaction from me. Essentially, if i POP off my +/- before any subroutine calls, I can check to see if it is a plus or minus, but after a subroutine call, the same POP would no longer provide me with the +/-. Is this normal behavior, or should, upon a RET call, my stack be as it was before the CALL statement?
Upvotes: 0
Views: 187
Reputation: 49920
As far as the status of the stack after returning from a subroutine call, it depends on the calling convention used. As long as the caller and called agree on how the stack is to be used, all is well -- and if you write both, you can use any convention you want. If either side is written by someone else, you need to find out what convention was used, and adhere to that.
Upvotes: 2