51單片機(jī)匯編語(yǔ)言音樂(lè)程序_第1頁(yè)
51單片機(jī)匯編語(yǔ)言音樂(lè)程序_第2頁(yè)
51單片機(jī)匯編語(yǔ)言音樂(lè)程序_第3頁(yè)
51單片機(jī)匯編語(yǔ)言音樂(lè)程序_第4頁(yè)
51單片機(jī)匯編語(yǔ)言音樂(lè)程序_第5頁(yè)
已閱讀5頁(yè),還剩19頁(yè)未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、MAIN:YD:NEXT BIT 10HORG 0000HJMP MAINORG 000BHJMP TONEORG 001BHJMP BEATORG 0100HMOV TMOD,#11HMOV TH0,R2MOV TL0,R3MOV TH1,#3CHMOV TL1,#0B0HMOV R4,#00HMOV DPTR,#TABMOV A,R4MOVC A,A+DPTRMOV R2,AXRL A,#00HJNZ JPINC R4CALL PDMOV A,R4MOVC A,A+DPTRMOV R3,A01兩只老虎;定義標(biāo)志位;取音調(diào)數(shù)據(jù);直接取節(jié)拍;判斷指針是否溢出XRL A,#OFFHJZ JPMO

2、V A,R2XRL A,#0FFHJNZ MAIN;取節(jié)拍數(shù)據(jù)JP:INC R4CALL PDMOV A,R4MOVC A,A+DPTRMOV R5,ASETB EASETB ET0SETB ET1SETB TR0SETB TR1SETB NEXTJB NEXT,$INC R4CALL PDJMP YDPD:MOV A,R4CJNE A,#00H,L1INC DPHL1:RET;音調(diào)產(chǎn)生子程序TONE: CPL P2.0MOV TH0,R2MOV TL0,R3RETI;節(jié)拍產(chǎn)生子程序BEAT: DJNZ R5,L2MOV TH1,#3CHMOV TL1,#0B0HL3:RETIL2:CLR T

3、R0CLR TR1CLR NEXTJMP L3;兩只老虎音符表TAB: DB0FBH,0F9H,08H,0FCH,066H,08H,0FCH,0C7H,08H,0FBH,0F9H,08HDB0FBH,0F9H,08H,0FCH,066H,08H,0FCH,0C7H,08H,0FBH,0F9H,08HDB0FCH,0C7H,08H,0FCH,0F3H,08H,0FDH,4AH,10H,0FCH,0C7H,08HDB0FCH,0F3H,08H,0FDH,4AH,08H,0FDH,4AH,04H,0FDH,95H,04HDB0FDH,4AH,04H,0FCH,0F3H,04H,0FCH,0C7H,0

4、8H,0FBH,0F9H,08HDB0FDH,4AH,04H,0FDH,95H,04H,0FDH,4AH,04H,0FCH,0F3H,04HDB0FCH,0C7H,08H,0FBH,0F9H,08H,0FCH,66H,08H,0FAH,93H,08HDB0FBH,0F9H,08H,00H,08H,0FCH,66H,04H,0FAH,93H,08HDB 0FBH,0F9H,08H,00H,10H,0FFH,0FFHEND02祝你平安ORG 0000HLJMP STARTORG 000BHINC 20H ;中斷服務(wù),中斷計(jì)數(shù)器加1MOV TH0,#0D8HMOV TL0,#0EFH ;12M 晶振

5、,形成10毫秒中斷RETISTART:MOV SP,#50HMOV TH0,#0D8HMOV TL0,#0EFHMOV TMOD,#01HMOV IE,#82HMUSICO:NOPMOV DPTR,#DAT ;表頭地址送 DPTRMOV 20H,#00H ;中斷計(jì)數(shù)器清 0MOV B,#00H ;表序號(hào)清0MUSIC1:NOPCLR AMOVC A,A+DPTR ;查表取代碼JZ END0 ;是00H,貝U結(jié)束CJNE A,#0FFH,MUSIC5LJMP MUSIC3MUSIC5:NOPMOV R6,AINC DPTRMOV A,BMOVC A,A+DPTR ;取節(jié)拍代碼送 R7MOV R7

6、,ASETB TR0 ;啟動(dòng)計(jì)數(shù)MUSIC2:NOPCPL P3.3MOV A,R6MOV R3,ALCALL DELMOV A,R7CJNE A,20H,MUSIC2 ;中斷計(jì)數(shù)器(20H)=R7否?;不等則繼 續(xù)循環(huán)MOV 20H,#00H ;等于,則取下一代碼INC DPTR;INC BLJMP MUSIC1MUSIC3:NOPCLR TR0 ;休止100毫秒MOV R2,#0DHMUSIC4:NOPMOV R3,#0FFHLCALL DELDJNZ R2,MUSIC4INC DPTRLJMP MUSIC1END0:NOPMOV R2,#64H ;歌曲結(jié)束,延時(shí)1秒后繼續(xù)MUSIC 6:

7、MOV R3,#00HLCALL DELDJNZ R2,MUSIC6LJMP MUSICODEL:NOPDEL3:MOV R4,#02HDEL4:NOPDJNZ R4,DEL4NOPDJNZ R3,DEL3RETNOPDAT:db26h,20h,20h,20h,20h,20h,26h,10h,20h,10h,20h,80h,26h,20h,30h,20hdb30h,20h,39h,10h,30h,10h,30h,80h,26h,20h,20h,20h,20h,20h,1ch,20 hdb20h,80h,2bh,20h,26h,20h,20h,20h,2bh,10h,26h,10h,2bh,80

8、h,26h,20hdb30h,20h,30h,20h,39h,10h,26h,10h,26h,60h,40h,10h,39h,10h,26h,20hdb30h,20h,30h,20h,39h,10h,26h,10h,26h,80h,26h,20h,2bh,10h,2bh,10 hdb2bh,20h,30h,10h,39h,10h,26h,10h,2bh,10h,2bh,20h,2bh,40h,40h,20 hdb20h,10h,20h,10h,2bh,10h,26h,30h,30h,80h,18h,20h,18h,20h,26h,20 hdb20h,20h,20h,40h,26h,20h,2b

9、h,20h,30h,20h,30h,20h,1ch,20h,20h,20 hdb20h,80h,1ch,20h,1ch,20h,1ch,20h,30h,20h,30h,60h,39h,10h,30h,10h db20h,20h,2bh,10h,26h,10h,2bh,10h,26h,10h,26h,10h,2bh,10h,2bh,80hdb18h,20h,18h,20h,26h,20h,20h,20h,20h,60h,26h,10h,2bh,20h,30h,20hdb30h,20h,1ch,20h,20h,20h,20h,80h,26h,20h,30h,10h,30h,10h,30h,20hd

10、b39h,20h,26h,10h,2bh,10h,2bh,20h,2bh,40h,40h,10h,40h,10h,20h,10hdb 20h,10h,2bh,10h,26h,30h,30h,80h,00HEND03生日歌ORG 0000HJMP STARTORG 000BHJMP TIMOORG 0030HSTART:MOV TMOD,#01HMOV IE,#82HSTARTO:MOV 30H,#00HNEXT:MOV A,30HMOV DPTR,#TABLEMOVC A,A+DPTRMOV R2,AJZ END0ANL A,#0FHMOV R5,AMOV A,R2SWAP AANL A,#0

11、FHJNZ SINGCLR TR0JMP D1SING:DEC AMOV 22H,ARL AMOV DPTR,#TABLE1MOVC A,A+DPTRMOV TH0,AMOV 21H,AMOV A,22HRL AINC AMOVC A,A+DPTRMOV TL0,AMOV 20H,ASETB TR0D1: CALL DELAYINC 30HJMPNEXTEND0:CLR TR0JMP START0TIM0:PUSH ACCPUSH PSWMOVTH0,21HMOVTL0,20HCPLP3.7POPPSWPOPACCRETIDELA Y:MOV R7,#02D2:MOVR4,#187D3:MOV

12、 R3,#248DJNZ R3,$DJNZ R4,D3DJNZ R7,D2DJNZ R5,DELAYRETTABLE1:DW 64260,64400,64524,64580DW 64684,64777,64820,64898DW 64968,65030,65058,65110DW 65157,65178,65217TABLE:DB 82H,01H,81H,94H,84HDB 0B4H,0A4H,04HDB 82H,01H,81H,94H,84HDB 0C4H,0B4H,04HDB 82H,01H,81H,0F4H,0D4HDB 0B4H,0A4H,94HDB 0E2H,01H,0E1H,0D4

13、H,0B4HDB 0C4H,0B4H,04HDB 82H,01H,81H,94H,84HDB 0B4H,0A4H,04HDB 82H,01H,81H,94H,84HDB 0C4H,0B4H,04HDB 82H,01H,81H,0F4H,0D4HDB 0B4H,0A4H,94HDB 0E2H,01H,0E1H,0D4H,0B4HDB 0C4H,0B4H,04HDB 00HEND04八月桂花香ORG 0000HLJMP STARTORG 000BHINC 20H ;中斷服務(wù),中斷計(jì)數(shù)器加1MOV TH0,#0D8HMOV TL0,#0EFH ;12M 晶振,形成10毫秒中斷RETISTART:MO

14、V SP,#50HMOV TH0,#0D8HMOV TL0,#0EFHMOV TMOD,#01HMOV IE,#82HMUSIC0:NOPMOV DPTR,#DAT ;表頭地址送 DPTRMOV 20H,#00H ;中斷計(jì)數(shù)器清0MUSIC1:NOPCLR A ;A清零MOVC A,A+DPTR ;查表取代碼JZ ENDO ;是00H,貝y結(jié)束CJNE A,#0FFH,MUSIC5 ;如果是休止符,往下執(zhí)行LJMP MUSIC3MUSIC5:NOPMOV R6,A ;R6=18H 音符的頻率INC DPTR ;DPTR 加一MOV A,#0MOVC A,A+DPTR ;取節(jié)拍代碼送 R7MOV

15、 R7,A ;R7=30H音符發(fā)音的時(shí)間SETB TR0 ;啟動(dòng)計(jì)數(shù)MUSIC2:NOPCPL P2.3 ;P2.3是音樂(lè)輸出引腳MOV A,R6MOV R3,A ;籤 3=R6=18HLCALL DELMOV A,R7CJNE A,20H,MUSIC2 ;中斷計(jì)數(shù)器(20H)=R7 否?;不等,則繼續(xù)循環(huán)MOV 20H,#00H ;等于,則取下一代碼INC DPTRLJMP MUSIC1MUSIC3:NOP ;休止100毫秒CLR TROMOV R2,#0DH ;R2=13MUSIC4:NOPMOV R3,#0FFH ;R3=255LCALL DELDJNZ R2,MUSIC4INC DPT

16、RLJMP MUSIC1END0:NOPMOV R2,#0FFH ;歌曲結(jié)束,延時(shí)1秒后繼續(xù)MUSIC 6:MOV R3,#00HLCALL DELDJNZ R2,MUSIC6LJMP MUSIC0DEL:NOPDEL3:MOV R4,#02HDEL4:NOPDJNZ R4,DEL4NOPDJNZ R3,DEL3RETNOPDAT:DB 18H, 30H, 1CH, 10HDB 20H, 40H, 1CH, 10HDB 18H, 10H, 20H, 10HDB 1CH, 10H, 18H, 40HDB 1CH, 20H, 20H, 20HDB 1CH, 20H, 18H, 20HDB 20H,

17、 80H, OFFH, 20HDB 30H, 1CH, 10H , 18HDB 20H, 15H, 20H , 1CHDB 20H, 20H, 20H , 26HDB 40H, 20H , 20H , 2BHDB 20H, 26H, 20H , 20HDB 20H, 30H , 80H , 0FFHDB 20H, 20H, 1CH , 10HDB 18H, 10H, 20H , 20HDB 26H, 20H , 2BH , 20HDB 30H, 20H , 2BH , 40HDB 20H, 20H , 1CH , 10HDB 18H, 10H, 20H, 20HDB 26H, 20H , 2B

18、H, 20HDB 30H, 20H, 2BH , 40HDB 20H, 30H, 1CH , 10HDB 18H, 20H , 15H , 20HDB 1CH, 20H , 20H , 20HDB 26H, 40H, 20H , 20HDB 2BH, 20H, 26H , 20HDB 20H, 20H, 30H , 80HDB 20H, 30H, 1CH , 10HDB 20H, 10H, 1CH , 10HDB 20H, 20H, 26H , 20HDB 2BH, 20H, 30H , 20HDB 2BH, 40H, 20H , 15HDB 1FH, 05H, 20H , 10HDB 1CH

19、, 10H, 20H , 20HDB 26H, 20H, 2BH , 20HDB 30H, 20H, 2BH , 40HDB 20H, 30H, 1CH , 10HDB 18H, 20H , 15H , 20HDB 1CH, 20H , 20H , 20HDB 26H, 40H, 20H , 20HDB 2BH, 20H, 26H , 20HDB 20H, 20H, 30H, 30HDB 20H, 30H, 1CH, 10HDB 18H, 40H, 1CH, 20HDB 20H, 20H, 26H, 40HDB 13H, 60H, 18H , 20HDB 15H, 40H, 13H , 40H

20、DB 18H, 80H, 00Hend05蘭花草SPK EQU P3.3;蜂鳴器所在端口ORG 0000HJMP STARTSTART:MOV R3,#00HNEXT:MOV A,R3MOV DPTR,#TABLEMOVC A,A+DPTRJZ STARTMOV R7,AINC R3MOV A,R3MOVC A,A+DPTRMOV R2,AACALL SONGINC R3SJMPNEXT;= 歌曲播放子程序 =SONG:取出節(jié)拍MOV A,R2RL AJNZ KEEPMOV A,#01HKEEP:MOV R2,AREPEAT:ACALL EIGHTHDJNZ R2,REPEATRET;= 產(chǎn)生

21、1/8拍延時(shí)子程序=EIGHTH:MOV A,R7;查表取出廷時(shí)參數(shù),保存到R4MOV DPTR,#DELAY_TMOVC A,A+DPTRMOV R4,AMOV A,R7;查表取出1/8拍周期數(shù),保存到R5MOV DPTR,#S_PARAMOVC A,A+DPTRMOV R5,ANEXTC YC:ACALL SOUNDDJNZR5,NEXTC YCRET;= 發(fā)聲子程序 =SOUND:SETBSPKACALLSDELA YCLR SPKACALLSDELA YRET;= 延時(shí)子程序 =SDELA Y:廷時(shí)值在R4內(nèi)MOV A,R4MOV R0,AXL2:MOV R1,#03HDL1:NOPD

22、JNZR1,DL1DJNZR0,XL2RET;=1/8拍周期表=S_PARA:DS1DHDB15H,16H,00DB19H,00H,1CH,00H,1FH,21H,00H,25HDB00H,29H,2CH,00H,31H,34H,37H,00HDB3EH,41H,00H,49H,00H,52H,57H,00HDB62H;= 延時(shí)參數(shù)表DELAY T:DS1DHDB7EH,77H,00HDB6AH,00H,5EH,00H,54H,4FH,00H,46HDB00H,3FH,3BH,00H,35H,32H,2FH,00HDB2AH,27H,00H,23H,00H,1FH,1DH,0C0HDB1AH;

23、= 歌曲表 =TABLE:DW 2202H,2902H,2902H,2902H,2906H,2702H;我從山中來(lái)DW 2502H,2702H,2502H,2402H,2208H;帶著蘭花草DW 2E02H,2E02H,2E02H,2E02H,2E06H,2C02H;種在小園中DW2902H,2C02H,2D02H,2A02H,2908H;祈禱花開早DW2902H,2E02H,2E02H,2C02H,2906H,2702H;日看三回DW2502H,2702H,2502H,2402H,2206H,1D02H;看得花時(shí)過(guò)DW 1D02H,2502H,2502H,2402H,2206H,2902H;蘭花卻依然DW 2702H,2502H,2402H,2002H,2208H;苞也無(wú)一個(gè)DW 00

溫馨提示

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

評(píng)論

0/150

提交評(píng)論