《可隨機編程的小巧機器人》源程序.doc_第1頁
《可隨機編程的小巧機器人》源程序.doc_第2頁
《可隨機編程的小巧機器人》源程序.doc_第3頁
《可隨機編程的小巧機器人》源程序.doc_第4頁
《可隨機編程的小巧機器人》源程序.doc_第5頁
已閱讀5頁,還剩5頁未讀 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

89c2051 匯編語言源程序 ljmp 0003h; mov p0,#0fh; mov p3,#0c7h; mov r0,#30h; mov r3,#0h;start: mov p1,#0ffh ;初始 clr p1.7 ;第1行l(wèi)call l0; setb p1.7; clr p1.6 ;第2行 jnb p1.2,key5; jnb p1.1,key6; jnb p1.0,key7;lcall l0; setb p1.6; clr p1.5 ;第3行 jnb p1.2,key9; jnb p1.1,keya; jnb p1.0,keyb;lcall l0; setb p1.5; clr p1.4;第4行 jnb p1.2,keyd; jnb p1.1,keye; jnb p1.0,keyf;lcall l0; ljmp start ;循環(huán)key5:mov a,#1h; push p3; lcall sound; pop p3; ljmp start ;key6:mov a,#4h; push p3; lcall sound; pop p3; ljmp start;key9:mov a,#2h; push p3; lcall sound; pop p3; ljmp start;key7: lcall l0;數(shù)據(jù)寫入程序 cjne a,#0h,ss; ljmp start; ss:mov r0,a; inc r3; push p3; lcall sound; pop p3; cpl p3.5; inc r0; mov a,#0h; lcall l0; ljmp start;keya:mov a,#5h; push p3; lcall sound; pop p3; ljmp start;keyb: ljmp auto;keye:mov a,#6h; push p3; lcall sound; pop p3; ljmp start;keyd:mov a,#3h; push p3; lcall sound; pop p3; ljmp start;keyf: inc r3;數(shù)據(jù)調出程序 lcall sound; mov r0,#2fh; run: lcall sound; inc r0; mov a,r0; djnz r3,run1; lcall sound; lcall sound; lcall sound; lcall sound; ljmp start; run1: cjne a,#1h,ma; mov p3,#0c7h; ljmp time; ma:cjne a,#2h,mb; mov p3,#0fdh; ljmp time; mb:cjne a,#3h,mc; lcall sound; ljmp time; mc:cjne a,#4h,md; mov p3,#0cch; ljmp time; md:cjne a,#5h,me; mov p3,#46h; ljmp time; me:cjne a,#6h,time; mov p3,#6dh; time: dec r3; inc r0; mov a,r0; cjne a,#1h,tm1; lcall ti1; ljmp run; tm1:cjne a,#2h,tm2; lcall ti1; lcall ti1; lcall ti1; ljmp run; tm2:cjne a,#3h,tm3; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; ljmp run; tm3:cjne a,#4h,tm4; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; ljmp run; tm4:cjne a,#5h,tm5; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; ljmp run; tm5: lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; ljmp run ;auto:自動運行子程序 lcall test; lcall sound; lcall walk; mov p3,#0fdh; lcall ti3; mov p3,#0c7h; lcall ti10; mov p3,#46h; lcall ti3; mov p3,#0d6h; lcall ti3; mov p3,#0c7h; lcall ti5; lcall walk; mov p3,#0c7h; lcall ti10; lcall sound; mov p3,#77h; lcall ti5; mov p3,#0e7h; lcall ti5; mov p3,#0fdh; lcall sound; lcall ti5; mov p3,#0c7h; lcall ti10; mov p3,#0dfh; lcall ti3; lcall sound; mov p3,#0fdh; lcall ti10; mov p3,#0d6h; lcall ti3; mov p3,#0c7h; lcall ti5; mov p3,#0c7h; lcall ti10; mov p3,#46h; lcall ti3;ljmp auto;keys: mov p1,#0ffh ;初始(運行時開關檢測程序) clr p1.7 ;第1行 lcall l0; setb p1.7; clr p1.6 ;2行 jnb p1.3,key_4 ;4鍵按下 lcall l0; setb p1.6; clr p1.5; jnb p1.3,key_8 ;8鍵按下 lcall l0; setb p1.5; clr p1.4; jnb p1.3,key_c ;c鍵按下 jnb p1.0,key_f; lcall l0; ret ;循環(huán)key_c:lcall sound; mov p3,#46h; lcall delay; mov p3,#77h; lcall delay; mov p3,#0fdh; lcall delay; ljmp keys ;key_4:lcall sound; mov p3,#0e7h; lcall delay; mov p3,#46h; lcall delay; mov p3,#6dh; lcall delay; mov p3,#0fdh; lcall delay; mov p3,#0cch; lcall delay; mov p3,#0fdh; lcall delay; ljmp keys;key_8:lcall sound; mov p3,#0e7h; lcall delay; mov p3,#046h; lcall delay; mov p3,#0cch; lcall delay; mov p3,#0fdh; lcall delay; mov p3,#06dh; lcall delay; mov p3,#0fdh; lcall delay; ljmp keys;key_f:lcall sound; lcall test; ljmp start;l0: mov b,#0ffh; l1:nop; nop; djnz b,l1;ret;walk:走步動作子程序 mov p3,#6dh; go-1 lcall ti1; mov p3,#0cch; lcall ti1; mov p3,#6dh; go-2 lcall ti1; mov p3,#0cch; lcall ti1; mov p3,#6dh; go-3 lcall ti1; mov p3,#0cch; lcall ti1; mov p3,#6dh; go-4 lcall ti1; mov p3,#0cch; lcall ti1; mov p3,#6dh; go-5 lcall ti1; mov p3,#0cch; lcall ti1; mov p3,#6dh; go-6 lcall ti1; mov p3,#0cch; lcall ti1; mov p3,#6dh; go-7 lcall ti1; mov p3,#0cch; lcall ti1; mov p3,#6dh; go-8 lcall ti1; mov p3,#0cch; lcall ti1; mov p3,#6dh; go-9 lcall ti1; mov p3,#0cch; lcall ti1; mov p3,#6dh; go-10 lcall ti1; mov p3,#0cch; lcall ti1; ret;sound:鳴叫子程序 mov r1,#0ffh; w4:nop; mov p3,#0dfh; mov r2,#0ffh; w5:nop; nop; djnz r2,w5; mov r2,#0ffh; w6:nop; nop; djnz r2,w6; mov r2,#0ffh; w7:nop; nop; djnz r2,w7; mov p3,#0c7h; nop; djnz r1,w4; ret;test: mov p3,#0ffh;指示燈測試子程序 lcall ti3; mov p3,#11101111b; lcall ti3; mov p3,#11110111b; lcall ti3; mov p3,#11010111b; lcall ti3; mov p3,#11001111b; lcall ti3; ret;ti1:延時子程序 mov r5,#08fh; w0:nop; lcall keys; nop; djnz r5,w0; ret;ti3: lcall ti1; lcall ti1; lcall ti1; ret;ti5: lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; ret;ti10: lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall ti1; lcall

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論