%include "asm_io.inc" segment .data pi dd 3.14 segment .bss tmp resd 1 segment .text global asm_main asm_main: enter 0,0 pusha fld dword [pi] ; ST0 = 3.14 fld1 ; ST0 = 1, ST1 = 3.14 fld1 ; ST0 = 1, ST1 = 1, ST2 = 3.14 fadd st2 ; ST0 = 4.14, ST1 = 1, ST2 = 3.14 fst dword [tmp] ; tmp = 4.14 dump_math 0 ; print the FP stack push dword [tmp] ; put 4.14 on the stack call some_func ; call some_func add esp, 4 ; clean up the stack dump_math 1 ; print the FP stack popa mov eax, 0 leave ret some_func: push ebp ; same ebp on the stack mov ebp, esp ; set ebp = esp fld dword [ebp+8] ; put the parameter on the FP stack ; as if it were a return value fld1 ; put 1 on the stack dump_math 2 ; print the FP stack faddp st1 ; add and pop dump_math 3 ; print the FP stack mov esp, ebp ; reset esp pop ebp ; restore ebp ret ; return