# sum_ave.asm
; sum and average for a list of numbers.
; *****************************************************
; Data declarations
section .data
EXIT_SUCCESS equ 0
SYS_exit equ 60
lst dd 1002, 1004, 1006, 1008, 10010
len dd 5
sum dd 0
section .text
global _start
_start:
; summation loop
mov ecx, dword[len]        ; get length value
mov rsi, 0                 ; index=0

SumLoop:
mov eax, dword [lst+rsi*4] ; [lst+rsi*4]=[lst+(rsi*4)]
add dword[sum], eax        ; update sum
inc rsi
loop SumLoop

last:
mov rax, SYS_exit
mov rdi, EXIT_SUCCESS
syscall



