双龙公司开发版源程序

源代码在线查看: music.s

软件大小: 626 K
上传用户: a1102882595
关键词: 源程序
下载地址: 免注册下载 普通下载 VIP

相关代码

					.module music.c
					.area eeprom(rom, con, rel)
				_sound::
					.byte 'f,39
					.byte 'h,38
					.byte 40,40
					.byte 39,38
					.byte 'G,'C
					.byte 'g,40
					.byte 'i,39
					.byte 41,41
					.byte 40,39
					.byte 'F,'F
					.byte 'J,'M
					.byte 'L,45
					.byte 44,43
					.byte 43,42
					.byte 41,'J
					.byte 'F,32
					.byte 'K,41
					.byte 'j,40
					.byte 39,35
					.byte 40,39
					.byte 'F,'F
					.byte 'J,'M
					.byte 'L,45
					.byte 44,43
					.byte 43,42
					.byte 41,'J
					.byte 'F,32
					.byte 'K,41
					.byte 'j,40
					.byte 39,35
					.byte 40,39
					.byte 'F,'F
					.byte 0
					.dbfile E:\icc\iccavr\mega8\mega8\music\music.c
					.dbsym e sound _sound A[65:65]c
					.area data(ram, con, rel)
					.dbfile E:\icc\iccavr\mega8\mega8\music\music.c
					.area lit(rom, con, rel)
				_TONETABLE::
					.word 64580
					.word 64684
					.word 64777
					.word 64820
					.word 64898
					.word 64968
					.word 65030
					.word 65058
					.word 65110
					.word 65157
					.word 65178
					.word 65217
					.word 65252
					.word 65283
					.word 65297
					.dbsym e TONETABLE _TONETABLE A[30:15]ki
					.area text(rom, con, rel)
					.dbfile E:\icc\iccavr\mega8\mega8\music\music.c
					.dbfunc e delay_us _delay_us fV
				;           time -> R16,R17
					.even
				_delay_us::
					.dbline -1
					.dbline 39
				; /*******************************************/
				; /*            广州天河双龙电子公司         */ 
				; /*            http://www.sl.com.cn         */
				; /*              电子音乐演示程序           */
				; /*            作者:ntzwq@wx88.net          */
				; /*                2002年5月10日            */
				; /*   目标MCU:MEGA8   晶振:外部(EXT) 8MHZ   */
				; /*******************************************/
				; //使用说明:音乐输出端口:PORTC.0,音乐数据存放
				; //于ATMEGA8的EEPROM存贮器中,可以使用music.exe
				; //程序通过RS232通信口进行修改。
				; #include 
				; #include 
				; #include 
				; #include "music.h"
				; extern void uart_init(void);
				; //extern void isp(void);
				; /* 		  音乐数据(卡秒莎)  	  */
				; /* 四分之一拍为0x10, 二分之一拍为0x20, 一拍为0x40*/
				; /* 低1-1 2-2 3-3 4-4 5-5 6-6 7-7 */
				; /* 中1-8 2-9 3-A 4-B 5-C 6-D 7-E */
				; /* 高1-F*/								  	
				; #pragma data:eeprom
				; unsigned char sound[]={0x66,0x27,0x68,0x26,0x28,0x28,0x27,0x26,0x47,0x43,
				; 	  		   		   0x67,0x28,0x69,0x27,0x29,0x29,0x28,0x27,0x46,0x46,
				; 					   0x4a,0x4d,0x4c,0x2d,0x2c,0x2b,0x2b,0x2a,0x29,0x4a,
				; 					   0x46,0x20,0x4b,0x29,0x6a,0x28,0x27,0x23,0x28,0x27,
				; 					   0x46,0x46,0x4a,0x4d,0x4c,0x2d,0x2c,0x2b,0x2b,0x2a,
				; 					   0x29,0x4a,0x46,0x20,0x4b,0x29,0x6a,0x28,0x27,0x23,
				; 					   0x28,0x27,0x46,0x46,0x00};
				; #pragma data:data							  		  						  
				; /*	  		    音阶表				*/	
				; const unsigned int TONETABLE[15]={DO,RE,MI,FA,SO,LA,TI,DO_H,
				; 			    	 	RE_H,MI_H,FA_H,SO_H,LA_H,TI_H,DO_HH};
				; /*			  音阶重装常数			*/						
				; unsigned int toneconst;								  							   						 				 	 	 
				; /*				微秒级延时程序	  		*/
				; void delay_us(int time)
				; 	 {     
				L2:
					.dbline 41
				;   	  do
				; 	  	{
					.dbline 42
				; 		 time--;
					subi R16,1
					sbci R17,0
					.dbline 43
				; 		}	
				L3:
					.dbline 44
				;   	  while (time>1);
					ldi R24,1
					ldi R25,0
					cp R24,R16
					cpc R25,R17
					brlt L2
					.dbline -2
					.dbline 45
				; 	 }
				L1:
					.dbline 0 ; func end
					ret
					.dbsym r time 16 I
					.dbend
					.dbfunc e delay_ms _delay_ms fV
				;           time -> R20,R21
					.even
				_delay_ms::
					rcall push_gset1
					movw R20,R16
					.dbline -1
					.dbline 48
				; /*	  		    毫秒级延时程序			*/	 
				; void delay_ms(unsigned int time)
				; 	 {
					rjmp L7
				L6:
					.dbline 50
					.dbline 51
					ldi R16,1000
					ldi R17,3
					rcall _delay_us
					.dbline 52
					subi R20,1
					sbci R21,0
					.dbline 53
				L7:
					.dbline 49
				; 	  while(time!=0)
					cpi R20,0
					cpc R20,R21
					brne L6
				X0:
					.dbline -2
					.dbline 54
				; 	  	  {		
				; 		   delay_us(1000);
				; 		   time--;
				; 		  }
				; 	 }					
				L5:
					rcall pop_gset1
					.dbline 0 ; func end
					ret
					.dbsym r time 20 i
					.dbend
					.area vector(rom, abs)
					.org 16
					rjmp _timer1_ovf_isr
					.area text(rom, con, rel)
					.dbfile E:\icc\iccavr\mega8\mega8\music\music.c
					.dbfunc e timer1_ovf_isr _timer1_ovf_isr fV
					.even
				_timer1_ovf_isr::
					st -y,R2
					st -y,R3
					st -y,R24
					in R2,0x3f
					st -y,R2
					.dbline -1
					.dbline 57
				; #pragma interrupt_handler timer1_ovf_isr:iv_TIMER1_OVF
				; void timer1_ovf_isr(void)
				; 	 {
					.dbline 58
				; 	  TCNT1=toneconst;
					lds R2,_toneconst
					lds R3,_toneconst+1
					out 0x2d,R3
					out 0x2c,R2
					.dbline 59
				; 	  PORTC^=1;
					ldi R24,1
					in R2,0x15
					eor R2,R24
					out 0x15,R2
					.dbline -2
					.dbline 60
				; 	 }	 	 
				L9:
					ld R2,y+
					out 0x3f,R2
					ld R24,y+
					ld R3,y+
					ld R2,y+
					.dbline 0 ; func end
					reti
					.dbend
					.dbfunc e music _music fV
				;      sound_add -> R20,R21
				;          temp1 -> R22
				;           temp -> R10
					.even
				_music::
					rcall push_gset3
					.dbline -1
					.dbline 62
				; void music(void)
				;  	 {
					.dbline 64
				; 	  unsigned char temp,temp1;
				; 	  unsigned int sound_add=0;
					clr R20
					clr R21
					.dbline 65
				;  	  TCCR1A = 0x00;
					clr R2
					out 0x2f,R2
					.dbline 66
				; 	  TCCR1B =(1					ldi R24,2
					out 0x2e,R24
					.dbline 67
				; 	  temp1=EEPROMread((int)&sound[sound_add]);
					ldi R24,					ldi R25,>_sound
					movw R16,R20
					add R16,R24
					adc R17,R25
					rcall _EEPROMread
					mov R22,R16
					rjmp L12
				L11:
					.dbline 69
				; 	  while(temp1!=0)
				;  	  		{
					.dbline 70
				; 			temp=temp1; 
					mov R10,R22
					.dbline 71
				; 			temp&=0x0f;
					mov R24,R10
					andi R24,15
					mov R10,R24
					.dbline 72
				; 			if(temp!=0)
					tst R24
					breq L14
					.dbline 73
				; 			  {
					.dbline 74
				; 			   TIMSK|=(1					in R24,0x39
					ori R24,4
					out 0x39,R24
					.dbline 75
				; 			   temp--;			   
					dec R10
					.dbline 76
				;         	   toneconst=TONETABLE[temp];
					ldi R24,2
					mul R24,R10
					movw R30,R0
					ldi R24,					ldi R25,>_TONETABLE
					add R30,R24
					adc R31,R25
					lpm R0,Z+
					lpm R1,Z
					movw R30,R0
					sts _toneconst+1,R31
					sts _toneconst,R30
					.dbline 77
				; 			   TCNT1=toneconst;
					out 0x2d,R31
					out 0x2c,R30
					.dbline 78
				;  			  }
				L14:
					.dbline 79
					mov R10,R22
					.dbline 80
					mov R24,R10
					swap R24
					andi R24,#0x0F
					.dbline 81
					andi R24,15
					mov R10,R24
					.dbline 82
					ldi R24,129
					mul R24,R10
					movw R16,R0
					rcall _delay_ms
					.dbline 83
					in R24,0x39
					andi R24,251
					out 0x39,R24
					.dbline 84
					subi R20,255  ; offset = 1
					sbci R21,255
					.dbline 85
					ldi R24,					ldi R25,>_sound
					movw R16,R20
					add R16,R24
					adc R17,R25
					rcall _EEPROMread
					mov R22,R16
					.dbline 86
				L12:
					.dbline 68
					tst R22
					brne L11
					.dbline 87
				; 			temp=temp1;
				; 			temp>>=4;
				; 			temp&=0x0f;
				; 			delay_ms(temp*129);//根据SOUNDTABLE中数据的高四位*5后,为音调持续时间
				; 			TIMSK&=~(1				; 			sound_add++;
				; 			temp1=EEPROMread((int)&sound[sound_add]); 
				; 			}
				; 		delay_ms(1000);	                                         	
					ldi R16,1000
					ldi R17,3
					rcall _delay_ms
					.dbline -2
					.dbline 88
				; 	 }	 	 	 	 
				L10:
					rcall pop_gset3
					.dbline 0 ; func end
					ret
					.dbsym r sound_add 20 i
					.dbsym r temp1 22 c
					.dbsym r temp 10 c
					.dbend
					.dbfunc e main _main fV
					.even
				_main::
					.dbline -1
					.dbline 91
				; /*	  	   		 主程序 	   	  		*/	  
				; void main(void)
				; 	 {
					.dbline 92
				; 	  DDRC=0x01;
					ldi R24,1
					out 0x14,R24
					.dbline 93
				; 	  PORTC=0xff;
					ldi R24,255
					out 0x15,R24
					.dbline 94
				; 	  uart_init();
					rcall _uart_init
					.dbline 95
				; 	  SEI();
					sei
					rjmp L18
				L17:
					.dbline 97
					.dbline 98
					rcall _music
					.dbline 99
				L18:
					.dbline 96
					rjmp L17
				X1:
					.dbline -2
					.dbline 100
				; 	  while(1)
				; 	   	{
				; 	     music();
				; 	    }
				; 	 }
				L16:
					.dbline 0 ; func end
					ret
					.dbend
					.area bss(ram, con, rel)
					.dbfile E:\icc\iccavr\mega8\mega8\music\music.c
				_toneconst::
					.blkb 2
					.dbsym e toneconst _toneconst i
							

相关资源