; Program that demonstrates C-style procedure call and definition
.386
.MODEL FLAT
ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD
.CODE ; start of main program code
_start:
mov eax, 10 ; Load and
push eax ; Push third argument
push eax ; Push second argument
push eax ; Push first argument
call add3nums ; push address of next instruction
; onto the stack, and pass control
; to the address of add3nums
add sp, 12 ; Destroy the pushed arguments
; (equivalent to three pops)
INVOKE ExitProcess, 0 ; exit with return code 0
PUBLIC _start ; make entry point public
add3nums PROC NEAR32 ; Demo proc
push ebp ; Preserve base pointer
mov ebp, esp ; Load stack into base pointer
mov eax, [ebp + 8] ; Get first parameter
add eax, [ebp + 12] ; Add second parameter
add eax, [ebp + 16] ; Add third parameter
pop ebp ; Restore EBP
ret ; Return result in EAX
add3nums ENDP
END ; end of source code