; File: double1.asm ; ; Using C printf function to print double values ; ; Declare some external functions ; extern printf ; the C function, we'll call SECTION .data ; Data section msg: db "Answer: %f", 10, 0 ; The string to print. pi: dq 3.14159265 SECTION .text ; Code section. global main main: push ebp ; set up stack frame mov ebp,esp mov eax, [pi+4] push eax mov eax, [pi] push eax ; Answer should be at the top of the stack push DWORD msg ; address of ctrl string call printf ; Call C function add esp, 12 ; pop 2 args from stack sub esp, 8 fld QWORD [pi] fstp QWORD [esp] push DWORD msg ; address of ctrl string call printf ; Call C function add esp, 12 ; pop 2 args from stack ; return from main mov esp, ebp ; takedown stack frame pop ebp ; same as "leave" op ret