第2个回答 2019-11-02
GEWEI
EQU
21H
SHIWEI
EQU
23H
SCANLED
EQU
25H
SCANMODE
EQU
26H
RED
EQU
28H
GREEN
EQU
29H
YELLOW
EQU
32H
NUMTIM
EQU
33H
LED
EQU
34H
ORG
000H
JMP
START
ORG
0BH
JMP
TIMER0
ORG
100H
START:MOV
SP,#50H
MOV
R0,#20H
MOV
R5,#20
CLR0:MOV
@R0,#00H
INC
R0
DJNZ
R5,CLR0
MOV
TMOD,#01H
MOV
TH0,#HIGH(65536-5000)
MOV
TL0,#LOW(65536-5000)
SETB
TR0
MOV
IE,#10000010B
MOV
P0,#0FFH
MOV
P1,#0FFH
MOV
P2,#0FFH
MOV
P3,#0FFH
MOV
R3,#10
MOV
R2,#3
MOV
R1,#10
MOV
R7,#200
MOV
RED,#10
MOV
YELLOW,#3
MOV
GREEN,#10
MOV
NUMTIM,#10
MOV
LED,#0FFH
AJMP
$
;=======================
TIMER0:PUSH
ACC
PUSH
PSW
MOV
TH0,#HIGH(65536-5000)
MOV
TL0,#LOW(65536-5000)
DJNZ
R7,RET0
MOV
R7,#200
MOV
A,SCANMODE
MOV
B,#4
DIV
AB
MOV
A,B
RL
A
MOV
DPTR,#TAB_SCAN
JMP
@A+DPTR
TAB_SCAN:
AJMP
RED_LIGHT
AJMP
YEL_LIGHT
AJMP
GRE_LIGHT
AJMP
YEL_LIGHT
RET0:
MOV
A,NUMTIM
LCALL
BIN_BCD
MOV
SHIWEI,A
MOV
GEWEI,B
INC
SCANLED
MOV
A,SCANLED
MOV
B,#4
DIV
AB
MOV
A,B
RL
A
MOV
DPTR,#TAB_SCAN0
JMP
@A+DPTR
TAB_SCAN0:AJMP
SCAN_L1
AJMP
SCAN_L2
SCAN_L1:
MOV
P2,#11110111B
MOV
A,SHIWEI
JMP
END_SCAN
SCAN_L2:
MOV
P2,#11111011B
MOV
A,GEWEI
JMP
END_SCAN
END_SCAN:MOV
DPTR,#TABLE
MOVC
A,@A+DPTR
MOV
P0,A
MOV
A,LED
MOV
P1,A
POP
PSW