; fltfunct_64.asm call math routine double sin(double x) ; compile: nasm -f elf64 fltfunct_64.asm ; link: gcc -m64 -o fltfunct_64 fltfunct_64.o -lm # needs math library ; run: ./fltfunct_64 > fltfunct_64.out ; view: cat fltfunct_64.out extern sin ; must extern all library functions extern printf section .data x: dq 0.7853975 ; Pi/4 = 45 degrees y: dq 0.0 ; should be about 7.07E-1 fmt: db "y= %e = sin(%e)",10,0 section .text global main main: push rbp ; set up stack movq xmm0, qword [x] ; pass argument to sin() call sin ; all "C" math uses double movq qword [y], xmm0 ; save result mov rdi, fmt ; print movq xmm0, qword [y] movq xmm1, qword [x] mov rax,2 ; 2 doubles call printf pop rbx ; restore stack mov rax,0 ; no error return ret ; return to operating system ; result: 7.071063e-01 = sin(7.853975e-01)