; ave_0.asm
section .data
section .text
global ave_0
ave_0:
push rbp
mov rbp, rsp
push r13
sumLoop:
add eax, dword[rdi+r13*4]
inc r13
cmp r13, rsi
jl sumLoop
;
mov rbx, qword[rbp+16]   ; get sum address
mov dword[rdx], eax      ; return sum
; average
;
cdq   ;convert doubleword eax in quadword edx:eax
idiv rsi ; signed rax=rax/rsi, rem.in rdx, sum/len
mov r13, qword[rbp+24]  ; get ave address
mov dword[rcx], eax     ; return average
pop r13
pop rbp
ret
