;sumav.asm , renzo diomedi
section .data
DI_0 equ 0
SYS_exit equ 60
arr dd 1002, 1004, 1006, 1008, 10009
leng dd 5
sum dd 0
section .text
global _start
_start:
mov ecx, dword [leng]        ; counter
mov rsi, 0                   ; index=0
sumLoop:
mov eax, dword [arr+(rsi*4)]
add dword [sum], eax         ; update sum
inc rsi
loop sumLoop
mov eax, dword [sum]
div rsi                      ; average
Fine:
mov rax, SYS_exit
mov rdi, DI_0
syscall
