; 先定义 RAM
DISPLAY_BUF EQU 40H ; 8 BYTES TO PORT P0
;DP0 EQU DISPLAY_BUF+0
DISPLAY_ID DATA DISPLAY_BUF + 8
SUB_DISPLAY2P0P2:
PUSH PSW
PUSH ACC
MOV P2, #0FFH ; 关闭显示
MOV A, DISPLAY_ID
ANL A, #7
ADD A, #DISPLAY_BUF
XCH A, R0
XCH A, @R0
MOV P0, A ; OUTPUT 2 P0
XCH A, @R0
XCH A, R0
MOV A, DISPLAY_ID
INC DISPLAY_ID
ANL A, #7
ADD A, #(P2_DATA-$-3)
MOVC A, @A+PC
MOV P2, A ; DISPLAY
POP ACC
POP PSW
RET
P2_DATA:
DB 11111110B ; 0 根据硬件接线
DB 11111101B ; 1
DB 11111011B ; 2
DB 11110111B ; 3
DB 11101111B ; 4
DB 11011111B ; 5
DB 10111111B ; 6
DB 01111111B ; 7