; FILE "fpu3.c" extern g SECTION .rodata _LC0 dd 858993459, 1072902963 ; qword floating point 1.2 _LC1 dd -858993459, 1073007820 ; qword floating point 1.3 _LC2 dd 1717986918, 1073112678 ; qword floating point 1.4 _LC3 dd 0, 1073217536 ; qword floating point 1.5 _LC4 dd -1717986918, 1073322393 ; qword floating point 1.6 _LC5 dd 858993459, 1073427251 ; qword floating point 1.7 _LC6 dd -858993459, 1073532108 ; qword floating point 1.8 _LC7 dd 1717986918, 1073636966 ; qword floating point 1.9 _LC8 dd 0, 1073741824 ; qword floating point 2.0 SECTION .text GLOBAL foo foo: push ebp ; set up stack frame mov ebp,esp sub esp,120 fld qword [ebp-80] ; push x1 fld qword [_LC0] ; push 1.2 faddp st1,st0 fstp qword [ebp-120] ; *** store (x1 + 1.2) in temp fld qword [ebp-72] ; push x2 fld qword [_LC1] ; push 1.3 faddp st1,st0 fstp qword [ebp-112] ; *** store (x2 + 1.3) in temp fld qword [ebp-64] ; push x3 fld qword [_LC2] ; push 1.4 faddp st1,st0 fstp qword [ebp-104] ; *** store (x3 + 1.4) in temp fld qword [ebp-56] ; push x4 fld qword [_LC3] ; push 1.5 faddp st1,st0 fstp qword [ebp-96] ; *** store (x4 + 1.5) in temp fld qword [ebp-48] ; push x5 fld qword [_LC4] ; push 1.6 faddp st1,st0 fstp qword [ebp-88] ; *** store (x5 + 1.6) in temp call g ; *** calling g() fld qword [_LC5] ; push 1.7 faddp st1,st0 ; add to value returned by g() fld qword [ebp-32] ; push x7 fld qword [_LC6] ; push 1.8 faddp st1,st0 fld qword [ebp-24] ; push x8 fld qword [_LC7] ; push 1.9 faddp st1,st0 fld qword [ebp-16] ; push x9 fld qword [_LC8] ; push 2.0 ; On the stack at this point (top of stack is on top) ; ; 2.0 ; x9 ; x8 + 1.9 ; x7 + 1.8 ; g() + 1.7 faddp st1,st0 faddp st1,st0 faddp st1,st0 faddp st1,st0 fadd qword [ebp-88] ; add (x5 + 1.6) from temp fadd qword [ebp-96] ; add (x4 + 1.5) from temp fadd qword [ebp-104] ; add (x3 + 1.4) from temp fadd qword [ebp-112] ; add (x2 + 1.3) from temp fadd qword [ebp-120] ; add (x1 + 1.2) from temp fstp qword [ebp-8] ; save in y leave ret