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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started