Please use Assembly Language
Write a program at $4000 to compute the average (nearest integer) of an array of 20 unsigned 8-bit numbers. The array needs to be stored at memory address starting $5000. Store your answer at location $4500.
Expert Answer
Please find program as below:
org 5000H
DATA SEGMENT
ARRAY DB 1,4,2,3,8,6,7,5,9,4,2,5,7,8,9,1,3,6,2
AVG DB ?
MSG DB “AVERAGE = $”
ENDS
CODE SEGMENT
ASSUME DS:DATA CS:CODE
org 4000H
START:
MOV AX,DATA
MOV DS,AX
LEA SI,ARRAY
LEA DX,MSG
MOV AH,9
INT 21H
MOV AX,00
MOV BL,9
MOV CX,9
LOOP1:
ADD AL,ARRAY[SI]
INC SI
LOOP LOOP1
DIV BL
ADD AL,30H
MOV DL,AL
MOV AH,2
INT 21H
MOV AH,4CH
STA 4300H
INT 21H
ENDS
END START