单片机远程控制程序
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
org 0000h
dbuf equ 30h
ljmp main
org 0003h
ljmp int
org 000bh
ljmp tzero
org 1000h
main:mov sp,#60h
mov 21h,#1
mov 22h,#1
mov 23h,#1
mov 24h,#1
mov 40h,#00h
mov 51h,#30
mov 52h,#5
mov 54h,#20
mov 55h,#5
mov a,51h
mov 41h,a
mov a,52h
mov 42h,a
add a,51h
mov 46h,a
mov a,54h
mov 44h,a
mov a,55h
mov 45h,a
add a,54h
mov 43h,a
mov tmod,#01h
mov th0,#3ch
mov tl0,#0afh
setb ea
setb et0
setb tr0
setb ex0
clr it0
setb px0
here:jnb p2.6,extra
lcall dspls
sjmp here
extra:lcall key
sjmp here
int:setb p1.0
setb p1.1
clr p1.2
setb p1.3
setb p1.4
clr p1.5
jnb p3.2,$
reti
tzero:push psw
push acc
mov th0,#3ch
mov tl0,#0afh
inc 40h
mov a,40h
cjne a,#20,twai
mov 40h,#00h
sjmp loop1
twai:ajmp exit
loop1:mov a,21h
jz loop2
mov a,43h
mov b,#10
div ab
mov dbuf+2,a
mov dbuf+3,b
mov a,43h
dec a
mov 43h,a
mov a,44h
mov b,#10
div ab
mov dbuf+0,a
mov dbuf+1,b
mov a,44h
dec a
mov 44h,a
cjne a,#0,next1
mov a,54h
mov 44h,a
mov 21h,#0
next1:mov p1,#0f3h
ajmp exit
loop2:mov a,22h
jz loop3
mov a,43h
mov b,#10
div ab
mov dbuf+2,a
mov dbuf+3,b
mov a,43h
dec a
mov 43h,a
mov a,45h
mov b,#10
div ab
mov dbuf+0,a
mov dbuf+1,b
mov a,45h
dec a
mov 45h,a
cjne a,#0,next2
mov a,55h
mov 45h,a
add a,54h
mov 43h,a
mov 22h,#0
next2:setb p1.0
setb p1.1
clr p1.2
setb p1.3
clr p1.4
cpl p1.5
sjmp exit
loop3:mov a,23h
jz loop4
mov a,46h
mov b,#10
div ab
mov dbuf+0,a
mov dbuf+1,b
mov a,46h
dec a
mov 46h,a
mov a,41h
mov b,#10
div ab
mov dbuf+2,a
mov dbuf+3,b
mov a,41h
dec a
mov 41h,a
cjne a,#0,next3
mov a,51h
mov 41h,a
mov 23h,#0
next3:mov p1,#0deh
sjmp exit
loop4:mov a,24h
jz loop5
mov a,46h
mov b,#10
div ab
mov dbuf+0,a
mov dbuf+1,b
mov a,46h
dec a
mov 46h,a
mov a,42h
mov b,#10
div ab
mov dbuf+2,a
mov dbuf+3,b
mov a,42h
dec a
mov 42h,a
cjne a,#0,next4
mov a,52h
mov 42h,a
add a,51h
mov 46h,a
mov 24h,#0
next4:setb p1.0
clr p1.1
cpl p1.2
setb p1.3
setb p1.4
clr p1
.5
sjmp exit
loop5:mov 21h,#1
mov 22h,#1
mov 23h,#1
mov 24h,#1
exit:pop acc
pop psw
reti
key:jnb p2.6,wait
ajmp stop
wait:mov p1,#0deh
clr tr0
mov dbuf+0,#00h
mov dbuf+1,#00h
mov dbuf+2,#00h
mov dbuf+3,#00h
lcall dspls
wait1:jnb p2.7,cope1
sjmp wait2
cope1:mov a,51h
mov b,#10
div ab
mov dbuf+2,a
mov dbuf+3,b
lcall dspls
jnb p3.0,work1
jb p2.7,wait
sjmp cope1
work1:lcall del
inc 51h
mov a,51h
cjne a,#100,cope1
mov 51h,#0
sjmp cope1
wait2:jnb p3.1,cope2
sjmp wait3
cope2:mov a,52h
mov b,#10
div ab
mov dbuf+2,a
mov dbuf+3,b
lcall dspls
jnb p3.3,work2
jb p3.1,wait
sjmp cope2
work2:lcall del
inc 52h
mov a,52h
cjne a,#100,cope2
mov 52h,#0
sjmp cope2
wait3:jnb p3.4,cope3
sjmp wait4
cope3:mov a,54h
mov b,#10
div ab
mov dbuf+0,a
mov dbuf+1,b
lcall dspls
jnb p3.5,work3
jb p3.4,kwai3
sjmp cope3
kwai3:ajmp wait
work3:lcall del
inc 54h
mov a,54h
cjne a,#100,cope3
mov 54h,#0
sjmp cope3
wait4:jnb p3.6,cope4
ajmp key
cope4:mov a,55h
mov b,#10
div ab
mov dbuf+0,a
mov dbuf+1,b
lcall dspls
jnb p3.7,work4
jb p3.6,kwai4
sjmp cope4
kwai4:ajmp wait
work4:lcall del
inc 55h
mov a,55h
cjne a,#100,cope4
mov 55h,#0
sjmp cope4
stop:mov a,51h
mov 41h,a
mov a,52h
mov 42h,a
add a,51h
mov 46h,a
mov a,54h
mov 44h,a
mov a,55h
mov 45h,a
add a,54h
mov 43h,a
setb tr0
ret
dspls:mov r0,#dbuf+0
mov r7,#4
mov b,#01h
loop:mov a,@r0
mov dptr,#dcode
movc a,@a+dptr
mov p0,a
mov a,b
mov p2,a
lcall delay
mov a,#0ffh
mov p2,a
mov a,b
rl a
mov b,a
inc r0
djnz r7,loop
ret
dcode:db 3fh,06h,5bh,4fh,66h
db 6dh,7dh,07h,7fh,6fh
delay:mov r3,#50
d:mov r4,#50
djnz r4,$
djnz r3,d
ret
del:mov r5,#100
y:mov r6,#100
s:mov r7,#8
djnz r7,$
djnz r6,s
djnz r5,y
ret
end