用两片74ls573做四位显示,要求连续按几个键都能显示(四位都显示),能移位的, ORG 0000H
LJMP MAIN
ORG 0030H
MAIN:MOV SP,#6FH
LOOP:ACALL KEY1
ACALL DISP
AJMP LOOP
KEY1:MOV P3,#0F0H
MOV A,P3
ORL A,#0FH
CPL A
JZ KPEXT
ACALL DELAY
MOV P3,#0F0H
MOV A,P3
ORL A,#0FH
CPL A
JZ KPEXT
MOV R4,#00
MOV R2,#0FEH
MOV R5,#04
KP1: MOV P3,R2
MOV A,P3
ORL A,#0FH
CPL A
JNZ KP2
MOV A,R4
ADD A,#04
MOV R4,A
MOV A,R2
RL A
MOV R2,A
DJNZ R5,KP1
SJMP KPEXT
KP2: JB ACC.4,KP3
RR A
INC R4
SJMP KP2
KP3: MOV A,R4
AJMP EXIT
KPEXT:MOV A,#0FEH
EXIT:RET
DISP:MOV DPTR,#TAB2
MOV A,R4
MOVC A,@A+DPTR
MOV P0,A
SETB P2.6
CLR P2.6
MOV P0,#0F0H
SETB P2.7
CLR P2.7
ACALL DELAY
RET
DELAY:MOV R7,#25
DE1: MOV R6,#200
DJNZ R6,$
DJNZ R7,DE1
RET
TAB1:DB 0FEH,0FDH,0FBH,0F7H,0EFH,0DFH,0BFH,7FH
DB 0FEH,0FDH,0FBH,0F7H,0EFH,0DFH,0BFH,7FH
TAB2:DB 03FH,06H,05BH,04FH
DB 066H,06DH,07DH,07H
DB 07FH,06FH,077H,07CH
DB 039H,05EH,079H,071H
|