所以我怀疑为什么我们使用ADD AL,07H如果AL包含大于10的东西?对于ADD AL,07的解释是什么? 这是代码。
MOV AH,01H ;TAKE INPUT
INT 21H
MOV BL,AL ; SAVE VALUE OF AL, SO THAT IT CAN BE USED LATER
MOV CL,04H
SHR AL,CL ;SHIFT AL TOWARDS RIGHT BY 4 BITS
CMP AL,0AH ;COMPARE IF AL HAS 10
JB DIGIT
ADD AL,07H
DIGIT:
ADD AL,30H ;Add 30 to make HEX equivalent ASCII code
MOV RES,AL
AND BL,0FH
CMP BL,0AH
JB DIGIT1
ADD BL,7H
DIGIT1:
ADD BL,30H
MOV RES+1,BL
LEA DX,RES ; display the result
MOV AH,9
INT 21H
谢谢。
答案 0 :(得分:2)
您的程序(连续2次)将4位值转换为可显示字符。结果将遵循下表:
0 -> "0" "0" has ASCII 48 = 0 + 48
1 -> "1"
2 -> "2"
3 -> "3"
4 -> "4"
5 -> "5"
6 -> "6"
7 -> "7"
8 -> "8"
9 -> "9" "9" has ASCII 57 = 9 + 48
10 -> "A" "A" has ASCII 65 = 10 + 48 + 7
11 -> "B"
12 -> "C"
13 -> "D"
14 -> "E"
15 -> "F" "F" has ASCII 70 = 15 + 48 + 7
从这个表中你可以看到,当从9变为10时,ASCII不能很好地相互跟随。为了弥补这7个字符的间隙(它包含字符:;< =>?@ )您使用了说明add al,7
和add bl,7