Reputation: 51
this is probably an easy one, but I'm confused about this for some time:
Suppose I have something like
main:
...
call some_fun
...
some_fun:
...
jmp op
...
op:
...
ret
would this ret correctly return to where the call starts? if not, then how would the ret returns correctly?
Upvotes: 2
Views: 7797
Reputation: 173
If it still crashes then try out
move dword[stak],esp ;at the very start
and end with
mov esp,[stak]
ret
kinda thing
gl
Upvotes: 1
Reputation: 14057
If in the provided example, you want the next instruction it executes after it returns to be the instruction after call some_fun, then yes it will do exactly as you want provided that you clean up your stack frame before returning.
Assuming that you are using x86 assembly, here is what is going on.
Hope this helps.
Upvotes: 8