# Program that will prompt the user to enter a hex digit character ( 0...9 or A...F ), display it on the next line in decimal

``` .MODEL SMALL
.STACK 100H

.DATA
PROMPT     DB  \'Enter a HEX digit : \$\'
DECIMAL    DB  \'The equivalent Decimal digit is : \$\'
CONTINUE   DB  \'Do you want to do it again : \$\'
ILLEGAL    DB  \'Illegal Character - Enter 0..9 or A..F : \$\'
NEXT_LINE  DB  0DH,0AH,\"\$\"

.CODE
MAIN PROC
MOV AX, @DATA                ; initialize DS
MOV DS, AX

@START_1:                    ; jump label
MOV AH, 9                  ; set string output function
LEA DX, PROMPT             ; load and display the string PROMPT
INT 21H

@START_2:                    ; jump label
MOV AH, 1                  ; read a character
INT 21H

MOV BL, AL                 ; save the character into BL

CMP BL, \"A\"                ; compare BL with \"A\"

CMP BL, \"F\"                ; compare BL with \"F\"

@SINGAL_DIGIT:               ; jump label
CMP BL, \"0\"                ; comapre BL with \"0\"

CMP BL, \"9\"                ; compare BL with \"9\"

@ILLEGAL_CHARACTER:          ; jump label
MOV AH, 9                  ; set string output function

LEA DX, NEXT_LINE          ; load and display the string NEXT_LINE
INT 21H

LEA DX, ILLEGAL            ; load and display the string ILLEGAL
INT 21H

@LESS_THAN_TEN:              ; jump label
MOV AH, 9                  ; set string output function

LEA DX, NEXT_LINE          ; load and display the string NEXT_LINE
INT 21H

LEA DX, DECIMAL            ; load and display the string DECIMAL
INT 21H

MOV AH, 2                  ; print the contents of BL
MOV DL, BL
INT 21H

@GREATER_THAN_NINE:          ; jump label
MOV AH, 9                  ; set string output function

LEA DX, NEXT_LINE          ; load and display the string  NEXT_LINE
INT 21H

LEA DX, DECIMAL            ; load and display the string DECIMAL
INT 21H

MOV AH, 2                  ; display the digit 1
MOV DL, 31H
INT 21H

SUB BL, 11H                ; subtract 11H from BL to find 2nd digit

MOV DL, BL                 ; display the 2nd digit
INT 21H

@CONTINUE:                   ; jump label
MOV AH, 9                  ; set string output function

LEA DX, NEXT_LINE          ; load and display the string NEXT_LINE
INT 21H
INT 21H

LEA DX, CONTINUE           ; load and display the string CONTINUE
INT 21H

MOV AH, 1                  ; read a character
INT 21H

CMP AL, \"y\"                ; compare AL with \"y\"

CMP AL, \"Y\"                ; compare AL with \"Y\"

@JUMP:                       ; jump label
LEA DX, NEXT_LINE          ; load and display the string NEXT_LINE
MOV AH, 9
INT 21H
INT 21H