;fpsuav.asm
;
section .data
EXIT_SUCCESS equ 0
SYS_exit equ 60
NULL equ 0
TRUE equ 1
FALSE equ 0
SYS_read equ 0
SYS_write equ 1
SYS_open equ 2
SYS_close equ 3
SYS_fork equ 57
O_RDWR equ 000002q
;
section .bss
arr resq 3
ar_sum resq 1
ar_ave resq 1
;
section .text
global fpsuav
fpsuav:
;
mov rsi, 0
mov rax, 0
movsd xmm1, qword[rax]
;
mov qword[r12], SYS_write
mov qword[arr], SYS_write
mov qword[ar_sum], SYS_write
mov qword[ar_ave], SYS_write
;
mov qword[r12], SYS_read
mov qword[arr], SYS_read
mov qword[ar_sum], SYS_read
mov qword[ar_ave], SYS_read
;
push qword[r12]
;
sum_loop:
movsd xmm0, qword[arr+rsi*8]         ;arr[i]
movsd qword[r12], xmm0
addsd xmm1, qword[r12]
inc rsi                              ;i++
loop sum_loop
movsd qword[ar_sum], xmm1          ;sum
;
divsd xmm1, qword[rsi]
movsd qword[ar_ave], xmm1          ;average
;
pop qword[r12]
;
; uscita:
; mov rax, SYS_exit
; mov rbx, EXIT_SUCCESS
; syscall

