汇编语言实验将内存单元存储的字节数据的16进制数的低位输出到显示器并显示。

打表法:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 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

直接转换:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 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