基于51單片機(jī)的俄羅斯方塊設(shè)計(jì)論文
基于51單片機(jī)的俄羅斯方塊設(shè)計(jì)論文,基于,51,單片機(jī),俄羅斯方塊,設(shè)計(jì),論文
游戲機(jī)的制作:俄羅斯方塊
目 錄
摘要………………………………………………………………………1
1 方案論證……………………………………………………………………….
1.1 開發(fā)意義…………………………………………………………………
1.2 功能介紹………………………………………………………………….
2 設(shè)計(jì)思路…………………………………………………………………………
.
3 硬件電路………………………………………………………………………
2.1 74HC573驅(qū)動(dòng)芯片電路…………………………………………………….
2.2 8*8LED點(diǎn)陣的接口電路…………………………………………………..
2.3單片機(jī)最小系統(tǒng)電路………………………………………………………..
2.4整體電路圖………………………………………………………………….
4 系統(tǒng)調(diào)試………………………………………………………………………..
3.1硬件調(diào)試………………………………………………………………………
3.2軟件調(diào)試……………………………………………………………………..
5 作品展示…………………………………………………………………………
.
6 元器件清單……………………………………………………………………..
7 結(jié)束語(yǔ)……………………………………………………………………………..
致謝……………………………………………………………………………
參考文獻(xiàn)………………………………………………………………………….
游戲機(jī)的制作:俄羅斯方塊
摘要:
近年來(lái)隨著計(jì)算機(jī)在社會(huì)領(lǐng)域的滲透, 單片機(jī)的應(yīng)用正在不斷地走向深入,應(yīng)用到各個(gè)領(lǐng)域。在實(shí)時(shí)檢測(cè)和自動(dòng)控制的單片機(jī)應(yīng)用系統(tǒng)中,單片機(jī)往往是作為一個(gè)核心部件來(lái)使用,僅單片機(jī)方面知識(shí)是不夠的,還應(yīng)根據(jù)具體硬件結(jié)構(gòu),以及針對(duì)具體應(yīng)用對(duì)象特點(diǎn)的軟件結(jié)合,以作完善。
我做的題目是一個(gè)用51單片機(jī)制作的游戲機(jī),大致分位軟件和硬件2大部分,硬件主要通過5按鍵、1個(gè)8*8LED點(diǎn)陣屏、一個(gè)單片機(jī)系統(tǒng),實(shí)現(xiàn)積木的左、右、下、變化、復(fù)位五個(gè)模式,完全達(dá)到俄羅斯方塊所實(shí)現(xiàn)的功能。
次項(xiàng)目用專門的PROTUES仿真,而采用KEIL軟件程序進(jìn)行程序調(diào)試
關(guān)鍵詞:AT89S52單片機(jī)芯片 ;74HC573驅(qū)動(dòng)芯片 ;GYXM-1558ASR-LED點(diǎn)陣屏
1 方案論證
1.1 開發(fā)意義:
充分理解點(diǎn)陣顯示的原理,已經(jīng)動(dòng)態(tài)掃描的應(yīng)用,對(duì)生活中的產(chǎn)品有了個(gè)全新的認(rèn)識(shí),不但懂得理論與實(shí)際的差距,也時(shí)對(duì)自己思維的一次強(qiáng)有力的挑戰(zhàn),做出這個(gè)東西讓我收獲良多。
1.2 功能介紹:
開始讓他顯示個(gè)積木,在按鍵沒實(shí)現(xiàn)控制的時(shí)候,每隔1S下移一次,有觸底處理功能,當(dāng)碰到底的時(shí)候圖形不能下移,判斷能否消行,能消行則消行,不能再判斷是否到頂,到底則從新開始,沒到底產(chǎn)生下個(gè)隨即數(shù),中間有5個(gè)按鍵控制,一個(gè)實(shí)現(xiàn)圖形左移,一個(gè)實(shí)現(xiàn)圖形右移,一個(gè)實(shí)現(xiàn)下移,一個(gè)實(shí)現(xiàn)旋轉(zhuǎn),一個(gè)復(fù)位。
2 設(shè)計(jì)思路
圖形的上下移動(dòng): 根據(jù)點(diǎn)陣?yán)碚摽赏ㄟ^圖形數(shù)據(jù)的左右移動(dòng)和地址變化來(lái)實(shí)現(xiàn)。
圖形的變化: 可通過地址變化來(lái)得到。即把需要變化的數(shù)據(jù)送到一固定地址,通過地址變化再送回顯示的地址里面。
圖形的碰邊處理: 可通過各個(gè)邊上的數(shù)據(jù)判斷是否到邊來(lái)實(shí)現(xiàn)。
與原有圖形相遇: 可通過與原有圖形數(shù)據(jù)進(jìn)行比較處理來(lái)實(shí)現(xiàn)。:
圖形的旋轉(zhuǎn): 在固定地址里面實(shí)現(xiàn)旋轉(zhuǎn)比較容易,但是在行進(jìn)中的圖形旋轉(zhuǎn)就比較費(fèi)腦筋,我是用一個(gè)地址計(jì)數(shù)下移的次數(shù),再用一個(gè)地址計(jì)數(shù)左移右移的次數(shù)。再根據(jù)這些次數(shù)確定圖形的地址,再把這些地址送到圖形變化的一個(gè)固定的地址中,變化后再送回到顯示的地址中去顯示。
圖形的碰邊處理: 如果不對(duì)圖形進(jìn)行邊框處理,圖形就會(huì)一直移動(dòng),看不到我們想要的效果。我是用把邊框數(shù)據(jù)與圖形數(shù)據(jù)進(jìn)行位運(yùn)算。再判斷這些數(shù)據(jù)就可以得到圖形是否到邊。
3 硬件電路
2.1 74HC573驅(qū)動(dòng)芯片電路
此芯片時(shí)個(gè)鎖存器,也可以做驅(qū)動(dòng)芯片驅(qū)動(dòng)LED點(diǎn)陣屏幕,這里面的電源和地系統(tǒng)附加了 但是實(shí)際中的加上去,不然芯片不能工作。
2.2 8*8LED點(diǎn)陣的接口電路
上面的是仿真的圖 上端接數(shù)據(jù) 下端開片選 但是實(shí)際中引腳很不規(guī)則,所有的花時(shí)間去測(cè)
用一節(jié)干電池,或者用指針萬(wàn)用表打到電阻10K檔。
2.3 單片機(jī)最小系統(tǒng)電路
2.4 整體電路圖以及仿真效果
但是里面的電源、地、晶振、復(fù)位、EA等 在仿真中系統(tǒng)自動(dòng)加的 要是在實(shí)際生活中的加進(jìn)去。
4 系統(tǒng)調(diào)試
3.1 硬件調(diào)試
第一 檢查單片機(jī)的最小系統(tǒng)是否正常,包括檢查晶振、單片機(jī)2端電壓、復(fù)位電路已經(jīng)EA
第二 看驅(qū)動(dòng)芯片是否工作正常、接法是否正確,再檢查L(zhǎng)ED點(diǎn)陣是否接的正確,可以用一節(jié)干電池測(cè),也可以用指針萬(wàn)用表打到電阻10K檔位測(cè)。
3.2 軟件調(diào)試
流程圖
程序代碼
;=========================================================
;俄羅斯方塊,采用移片選的方法.
;編譯時(shí)間: 09年1月15
;編譯者: 譚華
;實(shí)現(xiàn)功能: 俄羅斯方塊的旋轉(zhuǎn),左移,右移
; 消行 碰邊 觸底 產(chǎn)生隨即數(shù)等 基本實(shí)現(xiàn)右移的基本功能
;==============初始化自定義========================================
pianxuan equ p2
shuchu equ p1
bt0 equ 20h.0
bt1 equ 20h.1
bt2 equ 20h.2
bt3 equ 20h.3
bt4 equ 20h.4
bt5 equ 20h.5
bt6 equ 20h.6
bt8 equ 21h.0
bt9 equ 21h.1
bt10 equ 21h.2
bt11 equ 21h.3
;============================================
org 0000h
ajmp start
org 0bh
ljmp intt0
org 30h
;=============主程序初始化================================
start: mov sp, #60h
mov tmod, #21h
mov th0, #0b1h
mov tl0, #0e0h
mov th1, #25
mov tl1, #25
mov r1, #00
call chushihua
call chuzhi
setb ea
setb et0
setb tr0
setb tr1
clr bt0
clr bt1
clr bt2
clr bt3
clr bt4
clr bt5
clr bt8
clr bt9
clr bt10
clr bt11
setb bt6
mov 35h, #0feh
mov r2, #00
mov r4, #00
;=====================================================
; 主程序
;======================================================
main:
jnb bt0, main
clr bt0
call saomiao ;掃描按鍵
call xianshi0 ;調(diào)用下移顯示畫面子程序
call xianshi ;調(diào)用觸邊后靜態(tài)圖形顯示的子程序
jb bt10, loop ;判斷是否觸頂,=1,游戲結(jié)束,跳到滿屏顯示
call chudi ;調(diào)用觸底子程序
call xiaohang ;調(diào)用消行判斷子程序
call yanshi_40ms ;調(diào)用延時(shí)40ms消抖子程序,40ms到,BT5置1
jnb bt5, xia0
clr bt5
call panduan ;調(diào)用按鍵判斷處理子程序
xia0: jnb bt9, xia ;圖形快速下落標(biāo)志位,=1快速下落
clr bt9
call xialuo ;調(diào)用圖形下落子程序
ajmp main
xia: call yanshi_1s ;延時(shí)1s子程序.1s到,BT1=1
jnb bt1, main
clr bt1
call xialuo
ajmp main
loop: call yanshi_500ms ;調(diào)用延時(shí)500ms子程序,500ms到bt11=1
jnb bt11, main
clr bt11
call manping ;調(diào)用滿屏全亮子程序
ajmp main
;=====================================================
; 按鍵掃描
;=====================================================
saomiao:
jb p3.2, qq0
setb bt2
ajmp qq
qq0: jb p3.1, qq1
setb bt3
ajmp qq
qq1: jb p3.0, qq2
setb bt4
ajmp qq
qq2: jb p3.3, qq4
setb bt8
ajmp qq
qq4: setb bt6
clr bt2
clr bt3
clr bt4
clr bt8
qq: ret
;=====================================================
; 圖形下移子程序
;=====================================================
xialuo:
mov a, 35h
rl a
mov 35h, a
ret
;============================================
; 判斷子程序
;=====================================================
panduan:
jnb bt2, ww0
clr bt2
jnb bt6, ww0
clr bt6
call youyi
ajmp ww
ww0: jnb bt3, ww1
clr bt3
jnb bt6, ww1
clr bt6
call zuoyi
ajmp ww
ww1: jnb bt4, ww2
clr bt4
jnb bt6, ww2
clr bt6
call zhuan
ajmp ww
ww2: jnb bt8, ww
clr bt8
jnb bt6, ww
clr bt6
call kuaixia
ww: ret
;============================================================
; 快速下落子程序
;=============================================================
kuaixia: setb bt9
ret
;============================================================
; 滿屏子程序
;============================================================
manping: mov 41h, #0ffh
mov 42h, #0ffh
mov 43h, #0ffh
mov 44h, #0ffh
mov 45h, #0ffh
mov 46h, #0ffh
mov 47h, #0ffh
mov 48h, #0ffh
ret
;============================================================
; 清屏子程序
;============================================================
qingping: mov 41h, #00h
mov 42h, #00h
mov 43h, #00h
mov 44h, #00h
mov 45h, #00h
mov 46h, #00h
mov 47h, #00h
mov 48h, #00h
ret
;============================================
; 下移顯示
;=====================================================
xianshi0: mov a, 35h
mov p1, 31h
mov p2, a
call delay
rl a
mov p1, #00
mov p1, 32h
mov p2, a
call delay
rl a
mov p1, #00
mov p1, 33h
mov p2, a
call delay
mov p1, #00
ret
;=====================================================
; 圖形右移子程序
;=====================================================
zuoyi:
mov a, 31h
jnb acc.0, dd1
ajmp dd
dd1: mov a, 32h
jnb acc.0, dd2
ajmp dd
dd2: mov a, 33h
jnb acc.0, dd3
ajmp dd
dd3: mov a, 35h
cjne a,#0feh,sa0
call sad0
ajmp dd
sa0: mov a, 35h
cjne a,#0fdh,sa1
call sad1
ajmp dd
sa1: mov a, 35h
cjne a,#0fbh,sa2
call sad2
ajmp dd
sa2: mov a, 35h
cjne a,#0f7h,sa3
call sad3
ajmp dd
sa3: mov a, 35h
cjne a,#0efh,sa4
call sad4
ajmp dd
sa4: mov a, 35h
cjne a,#0bfh,dd
call sad5
ajmp dd
dd: ret
sad0: mov a, 33h
rr a
mov 39h,#00
mov 39h, a
anl a,43h
cjne a,#00,dd4
mov 33h, 39h
mov a, 32h
rr a
mov 39h,#00
mov 39h, a
anl a,42h
cjne a,#00,dd4
mov 32h, 39h
mov a, 31h
rr a
mov 39h,#00
mov 39h, a
anl a,41h
cjne a,#00,dd4
mov 31h, 39h
dec 51h
dd4: ret
sad1: mov a, 33h
rr a
mov 39h,#00
mov 39h, a
anl a,44h
cjne a,#00,dd5
mov 33h, 39h
mov a, 32h
rr a
mov 39h,#00
mov 39h, a
anl a,43h
cjne a,#00,dd5
mov 32h, 39h
mov a, 31h
rr a
mov 39h,#00
mov 39h, a
anl a,42h
cjne a,#00,dd5
mov 31h, 39h
dec 51h
dd5: ret
sad2: mov a, 33h
rr a
mov 39h,#00
mov 39h, a
anl a,45h
cjne a,#00,dd6
mov 33h, 39h
mov a, 32h
rr a
mov 39h,#00
mov 39h, a
anl a,44h
cjne a,#00,dd6
mov 32h, 39h
mov a, 31h
rr a
mov 39h,#00
mov 39h, a
anl a,43h
cjne a,#00,dd6
mov 31h, 39h
dec 51h
dd6: ret
sad3: mov a, 33h
rr a
mov 39h,#00
mov 39h, a
anl a,46h
cjne a,#00,dd7
mov 33h, 39h
mov a, 32h
rr a
mov 39h,#00
mov 39h, a
anl a,45h
cjne a,#00,dd7
mov 32h, 39h
mov a, 31h
rr a
mov 39h,#00
mov 39h, a
anl a,44h
cjne a,#00,dd7
mov 31h, 39h
dec 51h
dd7: ret
sad4: mov a, 33h
rr a
mov 39h,#00
mov 39h, a
anl a,47h
cjne a,#00,dd8
mov 33h, 39h
mov a, 32h
rr a
mov 39h,#00
mov 39h, a
anl a,46h
cjne a,#00,dd8
mov 32h, 39h
mov a, 31h
rr a
mov 39h,#00
mov 39h, a
anl a,45h
cjne a,#00,dd8
mov 31h, 39h
dec 51h
dd8: ret
sad5: mov a, 33h
rr a
mov 39h,#00
mov 39h, a
anl a,48h
cjne a,#00,dd9
mov 33h, 39h
mov a, 32h
rr a
mov 39h,#00
mov 39h, a
anl a,47h
cjne a,#00,dd9
mov 32h, 39h
mov a, 31h
rr a
mov 39h,#00
mov 39h, a
anl a,46h
cjne a,#00,dd9
mov 31h, 39h
dec 51h
dd9: ret
;===============圖形左移子程序======================================
;通過圖形移動(dòng)一位,與靜止圖形相與,為零則移動(dòng),否則原地不動(dòng)
;
;=====================================================
youyi: mov a, 31h
jnb acc.7, cc0
ajmp cc20
cc0: mov a, 32h
jnb acc.7, cc1
ajmp cc20
cc1: mov a, 33h
jnb acc.7, cc
ajmp cc20
cc: mov a, 35h
cjne a,#0feh,zz0
call scd0
ajmp cc20
zz0: mov a, 35h
cjne a,#0fdh,zz1
call scd1
ajmp cc20
zz1: mov a, 35h
cjne a,#0fbh,zz2
call scd2
ajmp cc20
zz2: mov a, 35h
cjne a,#0f7h,zz3
call scd3
ajmp cc20
zz3: mov a, 35h
cjne a,#0efh,zz4
call scd4
ajmp cc20
zz4: mov a, 35h
cjne a,#0bfh,cc20
call scd5
ajmp cc20
cc20: ret
scd0: mov a, 33h
rl a
mov 39h,#00
mov 39h, a
anl a,43h
cjne a,#00,cc2
mov 33h, 39h
mov a, 32h
rl a
mov 39h,#00
mov 39h, a
anl a,42h
cjne a,#00,cc2
mov 32h, 39h
mov a, 31h
rl a
mov 39h,#00
mov 39h, a
anl a,41h
cjne a,#00,cc2
mov 31h, 39h
inc 51h
cc2: ret
scd1: mov a, 33h
rl a
mov 39h,#00
mov 39h, a
anl a,44h
cjne a,#00,cc3
mov 33h, 39h
mov a, 32h
rl a
mov 39h,#00
mov 39h, a
anl a,43h
cjne a,#00,cc3
mov 32h, 39h
mov a, 31h
rl a
mov 39h,#00
mov 39h, a
anl a,42h
cjne a,#00,cc3
mov 31h, 39h
inc 51h
cc3: ret
scd2: mov a, 33h
rl a
mov 39h,#00
mov 39h, a
anl a,45h
cjne a,#00,cc4
mov 33h, 39h
mov a, 32h
rl a
mov 39h,#00
mov 39h, a
anl a,44h
cjne a,#00,cc4
mov 32h, 39h
mov a, 31h
rl a
mov 39h,#00
mov 39h, a
anl a,43h
cjne a,#00,cc4
mov 31h, 39h
inc 51h
cc4: ret
scd3: mov a, 33h
rl a
mov 39h,#00
mov 39h, a
anl a,46h
cjne a,#00,cc5
mov 33h, 39h
mov a, 32h
rl a
mov 39h,#00
mov 39h, a
anl a,45h
cjne a,#00,cc5
mov 32h, 39h
mov a, 31h
rl a
mov 39h,#00
mov 39h, a
anl a,44h
cjne a,#00,cc5
mov 31h, 39h
inc 51h
cc5: ret
scd4: mov a, 33h
rl a
mov 39h,#00
mov 39h, a
anl a,47h
cjne a,#00,cc6
mov 33h, 39h
mov a, 32h
rl a
mov 39h,#00
mov 39h, a
anl a,46h
cjne a,#00,cc6
mov 32h, 39h
mov a, 31h
rl a
mov 39h,#00
mov 39h, a
anl a,45h
cjne a,#00,cc6
mov 31h, 39h
inc 51h
cc6: ret
scd5: mov a, 33h
rl a
mov 39h,#00
mov 39h, a
anl a,48h
cjne a,#00,cc7
mov 33h, 39h
mov a, 32h
rl a
mov 39h,#00
mov 39h, a
anl a,47h
cjne a,#00,cc7
mov 32h, 39h
mov a, 31h
rl a
mov 39h,#00
mov 39h, a
anl a,46h
cjne a,#00,cc7
mov 31h, 39h
inc 51h
cc7: ret
;======================================================
; 圖形旋轉(zhuǎn)子程序
;======================================================
zhuan: cjne r1,#0, bu0
call zhuan0
ajmp bu
bu0: cjne r1,#1, bu1
call zhuan1
ajmp bu
bu1: cjne r1,#2, bu2
call zhuan2
ajmp bu
bu2: cjne r1,#3, bu3
call zhuan3
ajmp bu
bu3: cjne r1,#4, bu
call zhuan4
bu: ret
zhuan0: inc r2
cjne r2,#1, gg0
mov 31h, #10h
mov 32h, #18h
mov 33h, #10h
call yizhou
ajmp gg
gg0: cjne r2,#2, gg1
mov 31h, #38h
mov 32h, #10h
mov 33h, #00h
call yizhou
ajmp gg
gg1: cjne r2,#3, gg2
mov 31h, #10h
mov 32h, #30h
mov 33h, #10h
call yizhou
ajmp gg
gg2: cjne r2,#4, gg
mov r2, #00
mov 31h, #10h
mov 32h, #38h
mov 33h, #00h
call yizhou
gg: ret
zhuan1: inc r2
cjne r2,#1, ggg0
mov 31h, #08h
mov 32h, #18h
mov 33h, #10h
call yizhou
ajmp ggg
ggg0: cjne r2,#2, ggg
mov 31h, #30h
mov 32h, #18h
mov 33h, #00h
mov r2, #00
call yizhou
ggg: ret
zhuan2: inc r2
cjne r2,#1, hh0
mov 31h, #18h
mov 32h, #30h
mov 33h, #00h
call yizhou
ajmp hh
hh0: cjne r2,#2, hh
mov 31h, #10h
mov 32h, #18h
mov 33h, #08h
mov r2, #00
call yizhou
hh: ret
zhuan3: inc r2
cjne r2,#1, hh1
mov 31h, #20h
mov 32h, #38h
mov 33h, #00h
call yizhou
ajmp hh4
hh1: cjne r2,#2, hh2
mov 31h, #18h
mov 32h, #10h
mov 33h, #10h
call yizhou
ajmp hh4
hh2: cjne r2,#3, hh3
mov 31h, #38h
mov 32h, #08h
mov 33h, #00h
call yizhou
ajmp hh4
hh3: cjne r2,#4, hh4
mov r2, #00
mov 31h, #10h
mov 32h, #10h
mov 33h, #30h
call yizhou
hh4: ret
zhuan4: inc r2
cjne r2,#1, hh5
mov 31h, #10h
mov 32h, #10h
mov 33h, #18h
call yizhou
ajmp hh8
hh5: cjne r2,#2, hh6
mov 31h, #38h
mov 32h, #20h
mov 33h, #00h
call yizhou
ajmp hh8
hh6: cjne r2,#3, hh7
mov 31h, #18h
mov 32h, #08h
mov 33h, #08h
call yizhou
ajmp hh8
hh7: cjne r2,#4, hh8
mov r2, #00
mov 31h, #08h
mov 32h, #38h
mov 33h, #00h
call yizhou
hh8: ret
;====================================================
yizhou:
mov a, 51h
cjne a,#5, tt7
jmp tt
tt7: cjne a,#6, tt0
call yyizhou
jmp tt
tt0: cjne a,#7, tt1
call yyizhou
call yyizhou
call zhuanpan0
jmp tt
tt1: cjne a,#8, tt2
call yyizhou
call yyizhou
call yyizhou
call zhuanpan0
jmp tt
tt2: cjne a,#9, tt3
call yyizhou
call yyizhou
call yyizhou
call yyizhou
call zhuanpan0
jmp tt
tt3: cjne a,#4, tt4
call zyizhou
jmp tt
tt4: cjne a,#3, tt5
call zyizhou
call zyizhou
jmp tt
tt5: cjne a,#2, tt6
call zyizhou
call zyizhou
call zyizhou
call zhuanpan1
jmp tt
tt6: cjne a,#1, tt
call zyizhou
call zyizhou
call zyizhou
call zyizhou
call zhuanpan1
tt: ret
;=========觸邊旋轉(zhuǎn)判斷====================
zhuanpan0:
mov a, 31h
jnb acc.0, hui0
call zyizhou
ajmp hui
hui0: mov a, 32h
jnb acc.0, hui1
call zyizhou
ajmp hui
hui1: mov a, 33h
jnb acc.0, hui
call zyizhou
hui: ret
;========觸邊旋轉(zhuǎn)判斷====================
zhuanpan1:
mov a, 31h
jnb acc.7, hui3
call yyizhou
ajmp hui2
hui3: mov a, 32h
jnb acc.7, hui4
call yyizhou
ajmp hui2
hui4: mov a, 33h
jnb acc.7, hui2
call yyizhou
hui2: ret
;===========X軸右移一位=================
yyizhou:
mov a, 31h
rl a
mov 31h, a
mov a, 32h
rl a
mov 32h, a
mov a, 33h
rl a
mov 33h, a
ret
;=========X軸左移一位=================
zyizhou:
mov a, 31h
rr a
mov 31h, a
mov a, 32h
rr a
mov 32h, a
mov a, 33h
rr a
mov 33h, a
ret
;==============顯示子程序==========================
xianshi: mov p1, 41h
mov p2, #0feh
call delay
mov p1, #00
mov p1, 42h
mov p2, #0fdh
call delay
mov p1, #00
mov p1, 43h
mov p2, #0fbh
call delay
mov p1, #00
mov p1, 44h
mov p2, #0f7h
call delay
mov p1, #00
mov p1, 45h
mov p2, #0efh
call delay
mov p1, #00
mov p1, 46h
mov p2, #0dfh
call delay
mov p1, #00
mov p1, 47h
mov p2, #0bfh
call delay
mov p1, #00
mov p1, 48h
mov p2, #7fh
call delay
mov p1, #00
ret
;===========消行顯示子程序==================
xiaohang: mov a, 48h
cjne a,#0ffh,zh0
call tiaozhen0
zh0: mov a, 47h
cjne a,#0ffh,zh1
call tiaozhen1
zh1: mov a, 46h
cjne a,#0ffh,zh2
call tiaozhen2
zh2: mov a, 45h
cjne a,#0ffh,zh3
call tiaozhen3
zh3: mov a, 44h
cjne a,#0ffh,zh4
call tiaozhen4
zh4: mov a, 43h
cjne a,#0ffh,zh5
call tiaozhen5
zh5: mov a, 42h
cjne a,#0ffh,zh6
call tiaozhen6
zh6: ret
tiaozhen0: mov 48h, #00
mov 49h, 48h
mov 48h, 47h
mov 47h, 46h
mov 46h, 45h
mov 45h, 44h
mov 44h, 43h
mov 43h, 42h
mov 42h, 41h
mov 41h, 49h
ret
tiaozhen1: mov 47h, #00
mov 49h, 47h
mov 47h, 46h
mov 46h, 45h
mov 45h, 44h
mov 44h, 43h
mov 43h, 42h
mov 42h, 41h
mov 41h, 49h
ret
tiaozhen2: mov 46h, #00
mov 49h, 46h
mov 46h, 45h
mov 45h, 44h
mov 44h, 43h
mov 43h, 42h
mov 42h, 41h
mov 41h, 49h
ret
tiaozhen3: mov 45h, #00
mov 49h, 45h
mov 45h, 44h
mov 44h, 43h
mov 43h, 42h
mov 42h, 41h
mov 41h, 49h
ret
tiaozhen4: mov 44h, #00
mov 49h, 44h
mov 44h, 43h
mov 43h, 42h
mov 42h, 41h
mov 41h, 49h
ret
tiaozhen5: mov 43h, #00
mov 49h, 43h
mov 43h, 42h
mov 42h, 41h
mov 41h, 49h
ret
tiaozhen6: mov 42h, #00
mov 49h, 42h
mov 42h, 41h
mov 41h, 49h
ret
;=================================================
; 延時(shí)1秒子程序
;==================================================
yanshi_1s:
inc r3
mov a, r3
cjne a,4dh, xx
mov r3,#00
setb bt1
xx: ret
yanshi_500ms:
inc r3
mov a, r3
cjne a,#25, xx11
mov r3,#00
setb bt11
xx11: ret
;=================================================
; 延時(shí)40m秒子程序
;==================================================
yanshi_40ms:
inc r4
cjne r4,#3, ee
mov r4, #00
setb bt5
ee: ret
suiji: mov a, tl1
mov b, #5
div ab
mov r1, b
ret
;====================================================
; 觸底子程序
;======================================================
chudi: mov a, 33h
cjne a,#00, bbb0
mov a, 32h
cjne a,#00h, bbb1
ljmp bbb
bbb0: ljmp bbb3
bbb1: mov a, 35h
cjne a,#0bfh,nn7
ljmp nn6
nn7: mov a, 35h
cjne a,#0feh,nn8
ljmp kk0
nn8: mov a, 35h
cjne a,#0fdh,nn9
ljmp kk1
nn9: mov a, 35h
cjne a,#0fbh,nn10
ljmp kk2
nn10: mov a, 35h
cjne a,#0f7h,nn11
ljmp kk3
nn11: mov a, 35h
cjne a,#0efh,nn12
ljmp kk4
nn12: mov a, 35h
cjne a,#0dfh,kk5
ljmp kk5
kk0: mov a, 32h
anl a, 43h
cjne a,#00h, nn0
ljmp bbb
kk1: mov a, 32h
anl a, 44h
cjne a,#00h, nn1
ljmp bbb
kk2: mov a, 32h
anl a, 45h
cjne a,#00h, nn2
ljmp bbb
kk3: mov a, 32h
anl a, 46h
cjne a,#00h, nn3
ljmp bbb
kk4: mov a, 32h
anl a, 47h
cjne a,#00h, nn4
ljmp bbb
kk5: mov a, 32h
anl a, 48h
cjne a,#00h, nn5
ljmp bbb
nn0: mov 35h, #0feh
mov a, 32h
orl a, 42h
mov 42h, a
mov a, 31h
orl a, 41h
mov 41h, a
setb bt10
call suiji
call chuzhi
ljmp bbb
nn1: mov 35h, #0feh
mov a, 32h
orl a, 43h
mov 43h, a
mov a, 31h
orl a, 42h
mov 42h, a
call suiji
call chuzhi
ljmp bbb
nn2: mov 35h, #0feh
mov a, 32h
orl a, 44h
mov 44h, a
mov a, 31h
orl a, 43h
mov 43h, a
call suiji
call chuzhi
ljmp bbb
nn3: mov 35h, #0feh
mov a, 32h
orl a, 45h
mov 45h, a
mov a, 31h
orl a, 44h
mov 44h, a
call suiji
call chuzhi
ljmp bbb
nn4: mov 35h, #0feh
mov a, 32h
orl a, 46h
mov 46h, a
mov a, 31h
orl a, 45h
mov 45h, a
call suiji
call chuzhi
ljmp bbb
nn5: mov 35h, #0feh
mov a, 32h
orl a, 47h
mov 47h, a
mov a, 31h
orl a, 46h
mov 46h, a
call suiji
call chuzhi
ljmp bbb
nn6: mov 35h, #0feh
mov a, 32h
orl a, 48h
mov 48h, a
mov a, 31h
orl a, 47h
mov 47h, a
call suiji
call chuzhi
ljmp bbb
bbb3: mov a, 35h
cjne a,#0dfh,bb6
ljmp bb5
bb6: mov a, 35h
cjne a,#0feh,bb7
ljmp jj0
bb7: mov a, 35h
cjne a,#0fdh,bb8
ljmp jj1
bb8: mov a, 35h
cjne a,#0fbh,bb9
ljmp jj2
bb9: mov a, 35h
cjne a,#0f7h,bb10
ljmp jj3
bb10: mov a, 35h
cjne a,#0efh,bbb9
ljmp jj4
bbb9: ljmp bbb
jj0: mov a, 33h
anl a, 44h
cjne a,#00h, bb0
mov a, 32h
anl a, 43h
cjne a,#00h, bb0
ljmp bbb
jj1: mov a, 33h
anl a, 45h
cjne a,#00h, bb1
mov a, 32h
anl a, 44h
cjne a,#00h, bb1
ljmp bbb
jj2: mov a, 33h
anl a, 46h
cjne a,#00h, bb2
mov a, 32h
anl a, 45h
cjne a,#00h, bb2
ljmp bbb
jj3: mov a, 33h
anl a, 47h
cjne a,#00h, bb3
mov a, 32h
anl a, 46h
cjne a,#00h, bb3
ljmp bbb
jj4: mov a, 33h
anl a, 48h
cjne a,#0
收藏