Reputation: 2144
I'm getting acquainted with PCASM book, and i don't understand one thing (which may be just my misunderstanding, i'm still new to low-level programming). It is told that c calling convention is something like
call
instruction to call the subroutine, which, among other things, will push return address on stackESP
ret
when you done which will pop return address (then optionally pop arguments if you wish) and use it to jump back to the calling codeSo far so good, but examples tell that return code is simply four bytes on the stack. That allows to jump anywhere on current code segment, but what if subroutine has to return to another segment? If code segment has to be pushed on the stack the same way as return address, how should one refer to arguments in subroutine (because they will have different offset on near and far return)?
Upvotes: 0
Views: 405
Reputation: 137398
The retf
instruction performs a "long return" which includes a segment and offset.
Upvotes: 3