ASSIGNMENT NO.7 –
AVERAGE OF NUMBERS
section .data
arr dd 11111111H,
22222222H, 33333333H
msg db 0ah,
"The average is : "
msglen : equ $-msg
count db 03h
section .bss
sum resd
1
dispnum resb
1
result resd
1
var resd 1
%macro disp 2
mov eax, 4
mov ebx, 1
mov ecx, %1
mov edx, %2
int 80h
%endmacro
section .text
global _start
_start:
mov esi, arr
mov edi, 03h
mov eax, 0
clc
nxt_num:
add eax, [esi]
add esi, 4
dec edi
jnz nxt_num
mov [sum],
eax
call disp_proc
disp msg,msglen
mov eax,[sum]
mov edx,00000000h
mov ebx,00000000h
mov
bl,[count]
div ebx
mov [result],eax
call disp_proc
call ext
disp_proc:
mov edx,00000000h
mov [dispnum],edx
mov esi,dispnum+7
mov ecx,8
cnt:
mov edx,0
mov ebx,10h
div ebx
add dl,30h
mov [esi],dl
dec esi
loop cnt
up1: mov eax,4
mov ebx,1
mov ecx,dispnum
mov edx,8
int 80h
ret
ext:
mov eax, 1
mov ebx, 0
int 80h
No comments:
Post a Comment