In: Computer Science
Write an assembly language program to calculate score = (num1 + num2) /2 i.e input two numbers num 1 and num 2 and divide it by 2 to display score.Test your program for the Pep/9 computer.
STACK SEGMENT
STACK ENDS
DATA SEGMENT ; initialization of data segment
n1 DB 10 ;Declaration of first value
n2 DB 3 ;Declaration of second value
avg DB ? ;Empty slot to store average
remainder DB " remainder ",'$'
rem DB ? ;Empty slot to store remainder
DATA ENDS ;End of data segment
CODE SEGMENT ; code segment
ASSUME CS: CODE, DS: DATA
Start: ;Starting address
MOV AX, DATA
MOV DS, AX ;Initialize the DS register
MOV AL, n1
ADD AL, n2
MOV AH, 00
MOV BL, 02
DIV BL
ADD AL, 48
MOV average, AL ;stores average
ADD AH, 48
MOV rem, AH ;stores remainder
CALL disp
MOV AX, 4C00H ;Returns control to MS-DOS
INT 21H
disp proc ;Procedure "disp"
MOV AH, 02H
MOV DL, average
INT 21H ;Displays average
MOV AH, 09H
LEA DX, remainder
INT 21H ;Displays message "remainder"
MOV AH, 02H
MOV DL, rem
INT 21H ;Displays remainder
ret ;returns control back to the point this procedure was called
disp endp ;End of procedure
CODE ENDS ;End of code segment
END Start ;End of program