打表法:

DATA SEGMENT
ASCII DB 30H,31H,32H,33H,34H,35H,36H,37H,38H,39H
      DB 41H,42H,43H,44H,45H,46H
HEX DB 0BH
DATA ENDS
CODE SEGMENT
   ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
       MOV DS,AX
       MOV BX,OFFSET ASCII
       MOV AL,HEX
       AND AL,0FH
       XLAT
       MOV DL,AL
       MOV AH,2
       INT 21H
       MOV AX,4C00H
       INT 21H
CODE ENDS
     END START

 

直接转换:

DATA SEGMENT
HEX DB 0BH
DATA ENDS
CODE SEGMENT
   ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
       MOV DS,AX
       MOV DL,HEX
       AND DL,0FH
       OR DL,30H
       CMP DL,39H
       JBE AD1
       ADD DL,7
AD1:   MOV AH,2
       INT 21H
       MOV AX,4C00H
       INT 21H
CODE ENDS
     END START