程序清单:
ORG 0000H
MAX7219:DIN BIT P1.1 ;定义变量
CLK BIT P1.2
LOAD BIT P1.1
LED_BF EQU 50H ;显示数据首址
AJMP MAIN
MAIN: MOV SP.#70H
LCALL PROCESS ;设置MAX7219初始值
LCALL DISPLAY ;显示
WAIT; ;其他程序省略
SJMP WAIT
;MAX7219初始化子程序
PROCECC :MOV A #0BH
MOV B #07H
LCALL W_7219
MOV A #09H
MOV B #00H
LCALL W_7219
MOV A ##0AH
MOV B #09H
LCALL W_7219
MOV A #0CH
MOV B #01H
LCALL W_7219
RET
;MAX7219显示子程序
DISPLAY:MOV R0 #LED_BF
MOV R4 #01H
MOV R3 #08H
C_DISP:MOV A @R0
MOV B A
MOV A R4
LCALL W_7219
INC R0
INC R4
DJNZ R3 C_DISP
RET
W_7219:CLR LOAD
LCALL SD_7219
MOV A B
LCALL SD_7219
SETB LOAD
RET
SD_7219:MOV R6 #08H
C_SD:NOP
CLR CLK
RLC A
MOV DIN C
NOP
SETB CLK
DJNZ R6 C_SD
RET
ORG 0000H
MAX7219:DIN BIT P1.1 ;定义变量
CLK BIT P1.2
LOAD BIT P1.1
LED_BF EQU 50H ;显示数据首址
AJMP MAIN
MAIN: MOV SP.#70H
LCALL PROCESS ;设置MAX7219初始值
LCALL DISPLAY ;显示
WAIT; ;其他程序省略
SJMP WAIT
;MAX7219初始化子程序
PROCECC :MOV A #0BH
MOV B #07H
LCALL W_7219
MOV A #09H
MOV B #00H
LCALL W_7219
MOV A ##0AH
MOV B #09H
LCALL W_7219
MOV A #0CH
MOV B #01H
LCALL W_7219
RET
;MAX7219显示子程序
DISPLAY:MOV R0 #LED_BF
MOV R4 #01H
MOV R3 #08H
C_DISP:MOV A @R0
MOV B A
MOV A R4
LCALL W_7219
INC R0
INC R4
DJNZ R3 C_DISP
RET
W_7219:CLR LOAD
LCALL SD_7219
MOV A B
LCALL SD_7219
SETB LOAD
RET
SD_7219:MOV R6 #08H
C_SD:NOP
CLR CLK
RLC A
MOV DIN C
NOP
SETB CLK
DJNZ R6 C_SD
RET