求80c51单片机音乐设计程序

乐谱是欢乐颂要用汇编语言... 乐谱是欢乐颂
要用汇编语言
展开
 我来答
jcj0606
推荐于2016-05-21 · TA获得超过193个赞
知道答主
回答量:80
采纳率:0%
帮助的人:24.9万
展开全部
/*****************************************/
/*我这有一个程序,你参考一下 */
/* function:唱生日快乐 */
/ */
/*****************************************/
#include<absacc.h>
#include<reg52.h>
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
#define led RD
#define key_rec T1
sbit BUZZER=P3^7;//发声音口
uchar code T0_H[16]={0xFF,0xFB,0xFB,0xFC,0xFC,0xFC,0xFD,0xFD,0xFD,0xFD,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE};
uchar code T0_L[16]={0xF1,0x4,0x90,0xC,0x44,0xAC,0x9,0x34,0x82,0xC8,0x06,0x22,0x56,0x85,0x9A,0xC1};
uchar code music[32]={8,0,8,9,8,0xB,0xA,0,8,0,8,9,8,0xC,0xB,0,8,0,8,0xF,0xD,0xB,0xA,9,0xE,0,0xE,0xD,0xB,0xC,0xB,0x0};
uchar code music_L[32]={2,1,1,4,4,4,4,4,2,1,1,4,4,4,4,4,2,1,1,4,4,4,4,4,2,1,1,4,4,4,4,4};
uchar a,b;
uint second,minute;
long t0count;
void delay_music(uint v)
{
while(v!=0) v--;
}
void delay_music1(uint j)
{
while(j!=0){j--;delay_music(200);}
}
void delay_music2(uint j)
{
while(j!=0){j--;delay_music1(80);}
}
main()
{//uint i;
uchar k,n,m;
delay_music(100);
TMOD=0x11;
TH0=0xfc;
TL0=0x66;
t0count=0;
EA=1;
ET0=0;
TR0=0;
ET1=0;
TR1=0;
while(1)
{
ET1=1;
TR1=1;
for(k=0;k<32;k++)
{
n=music[k];
m=music_L[k];
a=T0_H[n];
b=T0_L[n];
delay_music2(m);
}
}
}
time0() interrupt 1 using 1
{
TH0=0xFC;
TL0=0x66;
t0count=t0count+1;
if (t0count==1000)
{
second++;
if (second==60)
{
minute++;
if (minute==60) minute=0;
second=0;}
t0count=0;
}
}
time1 () interrupt 3 using 3
{
TH1=a;
TL1=b;
BUZZER=!BUZZER;
}

早说嘛!!
改一下不就行了嘛
下面是汇编写的

ORG 0000H
JMP MAIN
ORG 000BH
JMP INTT0
ORG 0100H
MAIN: MOV SP,#60H
MOV TMOD,#01H
SETB ET0
SETB EA
SETB TR0
START0: SETB INT0
MOV 30H,#00H
NEXT: MOV A,30H
MOV DPTR,#TABLE
MOVC A,@A+DPTR
MOV R2,A
JZ ENDD
ANL A,#0FH
MOV R5,A
MOV A,R2
SWAP A
ANL A,#0FH
JNZ SING
CLR TR0
JMP D1
SING: DEC A
MOV 22H,A
RL A
MOV DPTR,#TABLE1
MOVC A,@A+DPTR
MOV TH0,A
MOV 21H,A
MOV A,22H
RL A
INC A
MOVC A,@A+DPTR
MOV TL0,A
MOV 20H,A
SETB TR0
D1: CALL DELAY
INC 30H
JMP NEXT
ENDD: CLR TR0
JMP START0

INTT0:
PUSH PSW
PUSH ACC
MOV TL0,20H
MOV TH0,21H
CPL INT0
POP ACC
POP PSW
RETI
DELAY: MOV R7,#02
DELAY0: MOV R4,#187
DELAY1: MOV R3,#248
DJNZ R3,$
DJNZ R4,DELAY1
DJNZ R7,DELAY0
DJNZ R5,DELAY
RET
TABLE: DB 82H,01H,81H,94H,84H,0B4H,0A4H,04H
DB 82H,01H,81H,94H,84H,0C4H,0B4H,04H
DB 82H,01H,81H,0F4H,0D4H,0B4H,0A4H,94H
DB 0E2H,01H,0E1H,0D4H,0B4H,0C4H,0B4H,04H
DB 82H,01H,81H,94H,84H,0B4H,0A4H,04H
DB 82H,01H,81H,94H,84H,0C4H,0B4H,04H
DB 82H,01H,81H,0F4H,0D4H,0B4H,0A4H,94H
DB 0E2H,01H,0E1H,0D4H,0B4H,0C4H,0B4H,04H
TABLE1: DW 64260,64400,64524,64580,64684,64777,64820,64898
DW 64968,65030,65058,65110,65157,65178,65217
END
贝吉塔4代
2008-11-25 · TA获得超过625个赞
知道答主
回答量:149
采纳率:0%
帮助的人:98.7万
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式