3 ms·
That's only one half of it though, the other interesting part is the jmp (instead of call) to hand over control to a subroutine without pushing a new return add
by flohofwoe 3y ago
That's only one half of it though, the other interesting part is the jmp (instead of call) to hand over control to a subroutine without pushing a new return address to the stack (since there's no code after the function call, and the calling function doesn't require its own stack frame).
- jonathrg 3y agoIndeed. Typically you have pairs of call and ret, where call creates a stack frame and ret tears it down caller caller | ^ (call) . . . . . . . . . . . . . (ret) | | V | outer_function outer_function | ^ (call) . . . .(ret) | | V | inner_function A jmp does not modify the stack, so when the inner function calls ret it jumps right back to caller caller caller | ^ (call) . . . . . . (ret) | | v | outer_function | | | (jmp) | | | V | inner_function This trick stops working as soon as outer_function needs local variables or does anything other than returning the exact return value of inner_function. In that case you need a stack frame