| dbp:code
|
- function function_name: DWORD; safecall; (en)
- function function_name: HResult; stdcall; (en)
- int callee;
int caller
{
return callee + 5;
} (en)
- ret 12 (en)
- return_type __cdecl func_name; (en)
- caller:
; make new call frame
;
push ebp ; save old call frame
mov ebp, esp ; initialize new call frame
; push call arguments, in reverse
;
; sub esp, 12 : 'enter' instruction could do this for us
; mov [ebp-4], 3 : or mov [esp+8], 3
; mov [ebp-8], 2 : or mov [esp+4], 2
; mov [ebp-12], 1 : or mov [esp], 1
push 3
push 2
push 1
call callee ; call subroutine 'callee'
add esp, 12 ; remove call arguments from frame
add eax, 5 ; modify subroutine result
;
; restore old call frame
;
; most calling conventions dictate ebp be callee-saved,
; i.e. it's preserved after calling the callee.
; it therefore still points to the start of our stack frame.
; we do need to make sure
; callee doesn't modify ebp, though,
; so we need to make sure
; it uses a calling convention which does this
pop ebp ; restore old call frame
ret ; return (en)
|