📄 带道闸 红绿灯.asm
字号:
one equ r1
two equ r2
three equ r3
onebus bit b.1
twobus bit b.2
threebus bit b.3
onelight bit p1.0 ;第一口红绿灯
twolight bit p1.1 ;第二口红绿灯
threelight bit p1.2 ;第三口送绿灯
onedz bit p1.3 ;第一口道闸
twodz bit p1.4 ;第二口道闸
threedz bit p1.5 ;第三口道闸
onein equ p3.1 ;第一口入口地感
oneout equ p3.2 ;第一口出口地感
twoin equ p3.3 ;第二入口地感
twoout equ p3.4 ;第二口出口地感
threein equ p3.5 ;第三口入口地感
threeout equ p3.6 ;第三口出口地感
org 0000h
jmp ok
org 0040h
ok :
mov one,#0
mov two,#0
mov three,#0
mov p3 ,#0ffh
setb onelight
setb twolight
setb threelight
clr onedz
clr twodz
clr threedz
start :
jnb onein ,oneine
jnb oneout ,oneoute
jnb twoin ,twoine
jnb twoout ,twooute
jnb threein ,threeine
jnb threeout ,o1
jmp start
o1 : jmp threeoute
oneine :
call delay
jb onein ,start
jb twobus ,start
jb threebus ,start
inc one
setb onebus
clr twobus
clr threebus
setb onelight
clr twolight
clr threelight
setb onedz
call delaydz
clr onedz
jnb onein ,$
jmp start
oneoute :
call delay
jb oneout ,start
call jisu
setb onedz
call delaydz
clr onedz
jnb oneout ,$
jmp start
twoine :
call delay
jb twoin ,start
jb onebus ,start
jb threebus ,start
inc two
setb twobus
clr onebus
clr threebus
setb twolight
clr onelight
clr threelight
setb twodz
call delaydz
clr twodz
jnb twoin ,$
jmp start
twooute :
call delay
jb twoout ,start
call jisu
setb twodz
call delaydz
clr twodz
jnb twoout ,$
jmp start
threeine :
call delay
jb threein ,o
jb onebus ,o
jb twobus ,o
inc three
setb threebus
clr onebus
clr twobus
setb threelight
clr onelight
clr twolight
setb threedz
call delaydz
clr threedz
jnb threein ,$
jmp start
threeoute :
call delay
jb threeout ,o
call jisu
setb threedz
call delaydz
clr threedz
jnb threeout ,$
o: jmp start
delay: mov r5,#50
d1: mov r6,#40
d2: mov r7,#20
djnz r7,$
djnz r6,d2
djnz r5,d1
ret
delaydz : mov r4 ,#20
d3: call delay
djnz r4 ,d3
ret
oneing :
rete : jmp start
jisu :
jb twobus ,twobuse
jb threebus ,threebuse
dec one
mov a ,one
jz zero
ret
twobuse :
dec two
mov a ,two
jz zero
ret
threebuse :
dec three
mov a,three
jz zero
ret
zero: setb onelight
setb twolight
setb threelight
clr onebus
clr twobus
clr threebus
ret
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -