Beruflich Dokumente
Kultur Dokumente
MODEL
SMALL
.STACK
100H
.DATA
PROMPT_1
DB
'Enter
a
digit
(0
-‐
9)
$'
PROMPT_2
DB
0dh,
0ah
,'The
number
in
HEX:
$'
.CODE
MAIN
PROC
MOV
AX,
@DATA
;
initialize
DS
MOV
DS,
AX
LEA
DX,
PROMPT_1
;
load
and
display
the
string
PROMPT_1
MOV
AH,
9
INT
21H
MOV
AH,1
;read
char
INT
21H
;convert
char
to
num
AND
AL,0fh
;MULTIPLY
BY
4
SHL
AL,2
;MOV
NUMBER
TO
BE
PRINTED
MOV
BH,AL
;
load
and
display
the
string
PROMPT_2
mov
ah,9
lea
dx,PROMPT_2
int
21h
MOV
CX,
2
;
initialize
loop
counter
MOV
AH,
2
;
set
output
function
Display:
;loop
lable
MOV
DL,
BH
SHR
DL,4
CMP
DL
,
9
;
DL
<=9?
JBE
DIGIT
;yes,
it
is
digit
ADD
DL,
37H
;
no,
it
is
letter
JMP
print_char
DIGIT:
OR
DL,
30H
print_char:
INT
21H
ROL
BX,4
LOOP
Display
mov
dl,'H'
int
21h
MAIN
ENDP
END
MAIN