;  su_av.asm
section .data
section .text
global su_av
su_av:
push r12        
mov r11, 0      ;i=0
mov r12d, 0      ;sum=0
sumLoop:
mov eax, dword[rdi+r11*4]     ;get arr[i]
add r12d, eax                 ;update sum in r12d
inc r11                       ;i++
cmp r11, rsi
jb sumLoop                    ;jump if r11<rsi
mov dword[rdx], r12d          ;return sum 
;  find and return average
mov eax, r12d           
cdq                           ;conver dword eax in qword edx:eax
idiv esi
mov dword[rcx], eax           ;return average
pop r12
ret

