1、顯示四位0A49H十六進位制數
DATA SEGMENT
DATA1 DW 0A490H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
MOV AX,DATA1
CALL DISP4
INT 20H
DISP4 PROC NEAR
PUSH BX
PUSH CX
PUSH DX
PUSH AX
MOV AL,AH
CALL DISP2
POP AX
CALL DISP2
POP DX
POP CX
POP BX
RET
DISP4 ENDP
DISP2 PROC NEAR
MOV BL,AL
MOV DL,AL
MOV CL,4
ROL DL,CL
AND DL,0FH
CALL DISP1
MOV DL,BL
AND DL,0FH
CALL DISP1
RET
DISP2 ENDP
DISP1 PROC
OR DL,30H
CMP DL,3AH
JB DDD
ADD DL,07H
DDD:
MOV AH,2
INT 21H
RET
DISP1 ENDP
CODE ENDS
END START
2、顯示兩位0A4H十六進位制數
DATA SEGMENT
DATA1 DB 0A4H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
MOV AX,DATA1
CALL DISP2
INT 20H
DISP2 PROC NEAR
MOV BL,AL
MOV DL,AL
MOV CL,4
ROL DL,CL
AND DL,0FH
CALL DISP1
MOV DL,BL
AND DL,0FH
CALL DISP1
RET
DISP2 ENDP
DISP1 PROC
OR DL,30H
CMP DL,3AH
JB DDD
ADD DL,07H
DDD:
MOV AH,2
INT 21H
RET
DISP1 ENDP
CODE ENDS
END START