        ; FILE "call2.c"

extern foo, printf

        SECTION         .rodata
_LC2:   db '%lf', 10, 0
_LC1:   dd   -1717986918, 1075812761     ; 7.9 in floating point

        SECTION .text
GLOBAL proc
proc: 
        push    ebp                 ; setup stack frame
        mov     ebp,esp
        sub     esp,40

        fld1                        ; push 0.0 on FPU stack
        fstp    qword [esp]         ; store 0.0 in regular stack
        call    foo                 ; call foo, returned value in FPU stack
        fld     qword [_LC1]        ; push 7.9
        faddp   st1,st0
        fstp    qword [ebp-8]       ; store sum in w
        fld     qword [ebp-8]       ; push w on regular stack
        fstp    qword [esp+4]
        mov     [esp], dword _LC2   ; push address of control string
        call    printf

        leave                       ; take down stack frame
        ret

GLOBAL main
        GLOBAL main:function
main: 
        lea     ecx, [esp+4]
        and     esp,-16
        push    dword [ecx-4]
        push    ebp
        mov     ebp,esp
        push    ecx
        sub     esp,4
        call    proc
        add     esp,4
        pop     ecx
        pop     ebp
        lea     esp, [ecx-4]
        ret


