How is return address specified in stack?

后端 未结 4 646
耶瑟儿~
耶瑟儿~ 2021-01-02 09:19

This is what I see by disassemble for the statement function(1,2,3);:

movl   $0x3,0x8(%esp)
movl   $0x2,0x4(%esp)
movl   $0x1,(%esp)
call   0x40         


        
4条回答
  •  伪装坚强ぢ
    2021-01-02 09:43

    Ideally, the call statement should take care of that. The program counter's next location will be pushed into the stack. When the function (sub routine) that was called completes it work and when it encounters a return statement, the control now goes to the address that was pushed into the stack and it will get popped.

提交回复
热议问题