52系列单片机由键盘控制8*8点阵,需变出不同花样的汇编程序
- 提问者网友:遁入空寂
- 2021-05-10 10:01
- 五星知识达人网友:怙棘
- 2021-05-10 11:07
在8X8点阵式LED通过按键来选择要显示的图形,点阵控制使用P1端口和P3端口,按键为P2.0
CNTA EQU 30H
COUNT EQU 31H
ORG 00H
LJMP START
ORG 0BH
LJMP T0X
ORG 30H
START: MOV CNTA,#00H
MOV COUNT,#00H
MOV TMOD,#01H
MOV TH0,#(65536-4000) / 256
MOV TL0,#(65536-4000) MOD 256
SETB TR0
SETB ET0
SETB EA
WT: JB P2.0,WT
MOV R6,#5
MOV R7,#248
D1: DJNZ R7,$
DJNZ R6,D1
JB P2.0,WT
INC COUNT
MOV A,COUNT
CJNE A,#03H,NEXT
MOV COUNT,#00H
NEXT: JNB P2.0,$
SJMP WT
T0X: NOP
MOV TH0,#(65536-4000) / 256
MOV TL0,#(65536-4000) MOD 256
MOV DPTR,#TAB
MOV A,CNTA
MOVC A,@A+DPTR
MOV P3,A
MOV DPTR,#GRAPH
MOV A,COUNT
MOV B,#8
MUL AB
ADD A,CNTA
MOVC A,@A+DPTR
MOV P1,A
INC CNTA
MOV A,CNTA
CJNE A,#8,NEX
MOV CNTA,#00H
NEX: RETI
TAB: DB 0FEH,0FDH,0FBH,0F7H,0EFH,0DFH,0BFH,07FH
GRAPH: DB 12H,14H,3CH,48H,3CH,14H,12H,00H
DB 00H,00H,38H,44H,44H,44H,38H,00H
DB 30H,48H,44H,22H,44H,48H,30H,00H
END