# Program that prompts the user to enter a character, and prints the ASCII code of the character in hex on the next line. Repeat this process ......

``` .MODEL SMALL
.STACK 100H

.DATA
PROMPT_1  DB  0DH,0AH,\'Enter the character : \$\'
PROMPT_2  DB  0DH,0AH,\'The ASCII code of the given number in HEX form is : \$\'

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

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

MOV AH, 1                  ; read a character
INT 21H

MOV BL, AL                 ; move AL to BL

CMP BL, 0DH                ; compare BL with CR

LEA DX, PROMPT_2           ; load and display the string PROMPT_2
MOV AH, 9
INT 21H

XOR DX, DX                 ; clear DX
MOV CX, 4                  ; move 4 to CX

@LOOP_1:                   ; loop label
SHL BL, 1                ; shift BL towards left by 1 position
RCL DL, 1                ; rotate DL towards left by 1 position
; through carry

MOV CX, 4                  ; move 4 to CX

@LOOP_2:                   ; loop label
SHL BL, 1                ; shift BL towards left by 1 position
RCL DH, 1                ; rotate DH towards left by 1 position
; through carry

MOV BX, DX                 ; move DX to BX
MOV CX, 2                  ; initialize loop counter

@LOOP_3:                   ; loop label
CMP CX, 1                ; compare CX wiht 1
MOV DL, BL               ; move BL to DL

@SECOND_DIGIT:           ; jump label
MOV DL, BH             ; move BH to DL

@NEXT:                   ; jump label

MOV AH, 2                ; set output function

CMP DL, 9                ; compare DL with 9
SUB DL, 9                ; convert it to number i.e. 1,2,3,4,5,6
OR DL, 40H               ; convert number to letter i.e. A,B...F

@NUMERIC_DIGIT:          ; jump label
OR DL, 30H             ; convert decimal to ascii code

@DISPLAY:                ; jump label
INT 21H                ; print the character