Average of block of bytes in Assembly -masm 8086

Average of block of bytes in Assembly -masm 8086

org 100h
.model small
.data
ARR DB 10,9,8,7,6,5,4,3,2,1
arr_size = $ - offset ARR
sum db 0
avg db 0
.code
;Initilize Data Segment
mov ax,@DATA
mov DS,ax
;====find total sum of array
lea si,arr
mov cl,arr_size
mov ch,00h
L:
mov ah,sum
add ah,[si]
mov sum,ah
inc si
LOOP L
;=====find average==========
mov al,sum
mov ah,00h
mov bl,arr_size
div bl
mov avg,al
;to terminate program
mov ah,4ch
int 21h
ret

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s