;fpsuav_callee.asm
section .data
NULL equ 0
TRUE equ 1
FALSE equ 0
EXIT_SUCCESS equ 0
SYS_exit equ 60
section .bss
fp_arr resq 3
ar_leng resb 3
ar_sum resq 1
ar_ave resq 1
section .text 
global fp_suav
fp_suav:
push r12
mov r12, 0
mov ecx, dword[ar_leng]      ;counter
mov rbx, fp_arr
mov rsi, 0                   ;i=0
movsd xmm0, qword[ar_sum]
sum_loop:
movsd xmm1, qword[rbx+rsi*8] ;fp_arr[i]
addsd xmm0, xmm1             ;update sum
inc rsi                      ;i++
loop sum_loop
movsd qword[ar_sum], xmm1
mov r12d, dword[ar_sum]   
;; cvtsi2sd xmm2, dword[ar_leng]
cqo
divsd xmm0, qword[rsi] 
movsd qword[ar_ave], xmm1
termina:
pop r12
mov rax, SYS_exit
mov rbx, EXIT_SUCCESS
syscall

