《89s51演奏祝你平安.doc》由会员分享,可在线阅读,更多相关《89s51演奏祝你平安.doc(3页珍藏版)》请在三一办公上搜索。
1、蜂鸣器唱祝你平安 * ; *;*/SPK bit P2.3 ORG 0000H LJMP START ORG 000BH INC 20H ;中断服务,中断计数器加1 MOV TH0,#0D8H MOV TL0,#0EFH ;12M晶振,形成10毫秒中断 RETISTART: MOV SP,#50H MOV TH0,#0D8H MOV TL0,#0EFH MOV TMOD,#01H MOV IE,#82HMUSIC0: NOP MOV DPTR,#DAT ;表头地址送DPTR MOV 20H,#00H ;中断计数器清0 MOV B,#00H ;表序号清0MUSIC1: NOP CLR A MOV
2、C A,A+DPTR ;查表取代码 JZ END0 ;是00H,则结束 CJNE A,#0FFH,MUSIC5 LJMP MUSIC3MUSIC5: NOP MOV R6,A INC DPTR MOV A,B MOVC A,A+DPTR ;取节拍代码送R7 MOV R7,A SETB TR0 ;启动计数MUSIC2: NOP CPL SPK MOV A,R6 MOV R3,A LCALL DEL MOV A,R7 CJNE A,20H,MUSIC2 ;中断计数器(20H)=R7否?;不等,则继续循环 MOV 20H,#00H ;等于,则取下一代码 INC DPTR; INC B LJMP MU
3、SIC1MUSIC3: NOP CLR TR0 ;休止100毫秒 MOV R2,#0DHMUSIC4: NOP MOV R3,#0FFH LCALL DEL DJNZ R2,MUSIC4 INC DPTR LJMP MUSIC1END0: NOP MOV R2,#64H ;歌曲结束,延时1秒后继续MUSIC6: MOV R3,#00H LCALL DEL DJNZ R2,MUSIC6 LJMP MUSIC0DEL:待添加的隐藏文字内容3 NOPDEL3: MOV R4,#02HDEL4: NOP DJNZ R4,DEL4 NOP DJNZ R3,DEL3 RET NOPDAT:db 26h,2
4、0h,20h,20h,20h,20h,26h,10h,20h,10h,20h,80h,26h,20h,30h,20hdb 30h,20h,39h,10h,30h,10h,30h,80h,26h,20h,20h,20h,20h,20h,1ch,20hdb 20h,80h,2bh,20h,26h,20h,20h,20h,2bh,10h,26h,10h,2bh,80h,26h,20hdb 30h,20h,30h,20h,39h,10h,26h,10h,26h,60h,40h,10h,39h,10h,26h,20hdb 30h,20h,30h,20h,39h,10h,26h,10h,26h,80h,2
5、6h,20h,2bh,10h,2bh,10hdb 2bh,20h,30h,10h,39h,10h,26h,10h,2bh,10h,2bh,20h,2bh,40h,40h,20hdb 20h,10h,20h,10h,2bh,10h,26h,30h,30h,80h,18h,20h,18h,20h,26h,20hdb 20h,20h,20h,40h,26h,20h,2bh,20h,30h,20h,30h,20h,1ch,20h,20h,20hdb 20h,80h,1ch,20h,1ch,20h,1ch,20h,30h,20h,30h,60h,39h,10h,30h,10hdb 20h,20h,2bh,10h,26h,10h,2bh,10h,26h,10h,26h,10h,2bh,10h,2bh,80hdb 18h,20h,18h,20h,26h,20h,20h,20h,20h,60h,26h,10h,2bh,20h,30h,20hdb 30h,20h,1ch,20h,20h,20h,20h,80h,26h,20h,30h,10h,30h,10h,30h,20hdb 39h,20h,26h,10h,2bh,10h,2bh,20h,2bh,40h,40h,10h,40h,10h,20h,10hdb 20h,10h,2bh,10h,26h,30h,30h,80h,00H END
链接地址:https://www.31ppt.com/p-2915363.html