return-address value

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

return-address value

Krozu
After going through chapter 7, and now 8, i reached the point of functions.
I think i have it figured out, but there is one thing that I'm uncertain of and that's the value of the return-address.
So my question is, are the return-addresses in the picture correct?
And if not, any pointers in the right direction would be appreciated. (Didn't add return to keep it "sane" and it's not required for the question to be answered, i think.)

return-address
Reply | Threaded
Open this post in threaded view
|

Re: return-address value

cadet1620
Administrator
The return address is usually the address of the NEXT instruction after the call so that all the return code needs to do after unwinding the stack is jump to the RIP. The VM code will eventually be translated into assembly language that looks something like this
    ...         // Asm code to build stack frame
    ...         //   and load target address into A
    0;JMP       // Jump to start of subroutine
    (RIP1234)   // Unique number for each RIP
    ...         // Asm for next vm statement
So in your picture they'd be 3 and 49. The rest of it looks OK.


--Mark
Reply | Threaded
Open this post in threaded view
|

Re: return-address value

Krozu
I assumed it saved the call instruction and went to the next instruction AFTER returning to the caller. Thanks for the quick reply, and the answer.