; fltfunc.asm call math routine double sin(double x) ; ; compile: nasm -f elf fltfunc.asm ; link: gcc -o fltfunc.o -lm # needs math library ; run: fltfunc ; extern sin extern printf section .data x: dq 0.7853975 ; Pi/4 = 45 degrees y: dq 1.0 ; should be about 7.07E-1 fmt: db "%e = sin(%e)",10,0 global main main: push ebp mov ebp,esp push ebx push dword [x+4] push dword [x] call sin add esp,8 fstp qword [y] push dword [x+4] push dword [x] push dword [y+4] push dword [y] push dword fmt call printf add esp,20 pop ebx mov esp,ebp pop ebp mov eax,0 ret ; result: 7.071063e-01 = sin(7.853975e-01)