Question: Following 8086 Assembly program accepts a two digit number and display as two digit number. A macro has been used to read a two-digit number.

Following 8086 Assembly program accepts a two digit number and display as two digit number. A macro has been used to read a two-digit number. Extend this code to read two numbers of two digits. The program will add the numbers and display the sum as two digits.

.model small

.stack 64

.data fdigit db ?

sdigit db ?

number db ?

message db "Please enter a digit number$"

output db "You entered $"

.code .

startup

macro twodigitread

mov [di],al

mov ah,01

int 21h

sub al,30h

mov [bx],al

; adjust

mov al,[di]

mov ah,0

mov cl,10

mul cl; ax=first digit

add al,[bx]

mov [si],al endm

mov dx, offset message

mov ah,9

int 21h

mov ah,01

int 21h

sub al,30H

mov di,offset fdigit

mov bx,offset sdigit

mov si,offset number

twodigitread

mov dx,offset output

mov ah,9

int 21h

mov al,[number]

mov ah,0

mov cl,10

div cl

mov cl,al; first digit

mov ch,ah; second digit

mov dl,cl

add dl,30h

mov ah,2

int 21h

mov dl,ch

add dl,30h

mov ah,2

int 21h

.exit end

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!