一个新颖的乐器.我参加西电星火杯的作品.里面有详细的.doc说明

源代码在线查看: music.s

软件大小: 234 K
上传用户: ranzige
关键词:
下载地址: 免注册下载 普通下载 VIP

相关代码

					.module music.c
					.area data(ram, con, rel)
				_T::
					.blkb 2
					.area idata
					.word -256
					.area data(ram, con, rel)
					.dbfile C:\DOCUME~1\asdf\MYDOCU~1\11111111111\music.c
					.dbsym e T _T I
				_N::
					.blkb 2
					.area idata
					.word -256
					.area data(ram, con, rel)
					.dbfile C:\DOCUME~1\asdf\MYDOCU~1\11111111111\music.c
					.dbsym e N _N I
					.area text(rom, con, rel)
					.dbfile C:\DOCUME~1\asdf\MYDOCU~1\11111111111\music.c
					.dbfunc e GPIO_INIT _GPIO_INIT fV
					.even
				_GPIO_INIT::
					.dbline -1
					.dbline 8
				; #include 
				; #include 
				; #include "do_le_mi.h"
				; int T=0xFF00;
				; int N=0xFF00;
				; 
				; void GPIO_INIT(void)
				; {
					.dbline 9
				;   	DDRB=0x00; //定义 PB为输入
					clr R2
					out 0x17,R2
					.dbline 11
				; 	//SFIOR&=~BIT(PUD); // SFIOR寄存器的上拉电阻控制位PUD置0,
				; 	PORTB|=0xFF; // 将 PORT 置1,满足上拉电阻的另一个条件 
					in R24,0x18
					ori R24,255
					out 0x18,R24
					.dbline 12
				; 	DDRC=0x01; //定义 PC0为输出 
					ldi R24,1
					out 0x14,R24
					.dbline 14
				; 	//PORTC=~BIT(0); // PC0 输出高电平
				; 	PORTC=0xFF; // PC0 输出高电平
					ldi R24,255
					out 0x15,R24
					.dbline 15
				; 	DDRD=0x80;
					ldi R24,128
					out 0x11,R24
					.dbline 16
				; 	PORTD=0x80;
					out 0x12,R24
					.dbline -2
					.dbline 19
				; 
				; 
				; }
				L1:
					.dbline 0 ; func end
					ret
					.dbend
					.dbfunc e timer1_init _timer1_init fV
					.even
				_timer1_init::
					.dbline -1
					.dbline 21
				; void timer1_init(void)
				; {
					.dbline 22
				;  		TCCR1B = 0x00; //stop
					clr R2
					out 0x2e,R2
					.dbline 23
				; 		TCNT1=65535-T;
					lds R2,_T
					lds R3,_T+1
					ldi R24,65535
					ldi R25,255
					sub R24,R2
					sbc R25,R3
					out 0x2d,R25
					out 0x2c,R24
					.dbline 24
				;  		TCCR1A = 0x00;//can be ignored
					clr R2
					out 0x2f,R2
					.dbline 25
				;  		TCCR1B = 0x01; //start Timer   devide 1
					ldi R24,1
					out 0x2e,R24
					.dbline -2
					.dbline 27
				;         //TCCR1B = 0x04; //start Timer   devide 256
				; }
				L2:
					.dbline 0 ; func end
					ret
					.dbend
					.area vector(rom, abs)
					.org 16
					rjmp _timer1_ovf_isr
					.area text(rom, con, rel)
					.dbfile C:\DOCUME~1\asdf\MYDOCU~1\11111111111\music.c
					.dbfunc e timer1_ovf_isr _timer1_ovf_isr fV
					.even
				_timer1_ovf_isr::
					st -y,R2
					st -y,R3
					st -y,R24
					st -y,R25
					in R2,0x3f
					st -y,R2
					.dbline -1
					.dbline 30
				; #pragma interrupt_handler timer1_ovf_isr:9
				; void timer1_ovf_isr(void)
				; {
					.dbline 31
				;  TCNT1=65535-T;
					lds R2,_T
					lds R3,_T+1
					ldi R24,65535
					ldi R25,255
					sub R24,R2
					sbc R25,R3
					out 0x2d,R25
					out 0x2c,R24
					.dbline 32
				;  PORTC=~PORTC;
					in R2,0x15
					com R2
					out 0x15,R2
					.dbline -2
					.dbline 33
				; }
				L3:
					ld R2,y+
					out 0x3f,R2
					ld R25,y+
					ld R24,y+
					ld R3,y+
					ld R2,y+
					.dbline 0 ; func end
					reti
					.dbend
					.dbfunc e main _main fV
				;              x -> R20
				;              y -> R22,R23
					.even
				_main::
					.dbline -1
					.dbline 36
				; void main(void)
				; 
				; {
					.dbline 41
				;   char x;
				;   int y;
				;   //int a,b;
				;   //开中断
				;   CLI(); //disable all interrupts
					cli
					.dbline 42
				;   OSCCAL=0XBA;
					ldi R24,186
					out 0x31,R24
					.dbline 43
				;   MCUCR = 0x00;
					clr R2
					out 0x35,R2
					.dbline 44
				;   GICR  = 0x00;
					out 0x3b,R2
					.dbline 45
				;   TIMSK=0x04;
					ldi R24,4
					out 0x39,R24
					.dbline 46
				;   timer1_init();
					rcall _timer1_init
					.dbline 47
				;   SEI(); //re-enable interrupts
					sei
					.dbline 48
				;   GPIO_INIT();
					rcall _GPIO_INIT
					rjmp L6
				L5:
					.dbline 52
				; 
				;   
				;   while(1)
				;   {
					.dbline 54
				;         
				;             x=read_key();	
					rcall _read_key
					mov R20,R16
					.dbline 56
				; 		//x=~0xFF01;
				; 			y=(int)x;
					mov R22,R20
					clr R23
					.dbline 58
				; 			
				;             switch(y)
					cpi R22,223
					ldi R30,0
					cpc R23,R30
					brne X2
					rjmp L15
				X2:
					ldi R24,223
					ldi R25,0
					cp R24,R22
					cpc R25,R23
					brlt L23
				L22:
					cpi R22,189
					ldi R30,0
					cpc R23,R30
					brne X3
					rjmp L19
				X3:
					cpi R22,191
					ldi R30,0
					cpc R23,R30
					brne X4
					rjmp L16
				X4:
					ldi R24,191
					ldi R25,0
					cp R24,R22
					cpc R25,R23
					brlt L25
				L24:
					cpi R22,126
					ldi R30,0
					cpc R23,R30
					brne X5
					rjmp L18
				X5:
					cpi R22,127
					ldi R30,0
					cpc R23,R30
					brne X6
					rjmp L17
				X6:
					rjmp L8
				L25:
					cpi R22,219
					ldi R30,0
					cpc R23,R30
					brne X7
					rjmp L20
				X7:
					rjmp L8
				L23:
					cpi R22,239
					ldi R30,0
					cpc R23,R30
					brne X8
					rjmp L14
				X8:
					ldi R24,239
					ldi R25,0
					cp R24,R22
					cpc R25,R23
					brlt L27
				L26:
					cpi R22,231
					ldi R30,0
					cpc R23,R30
					brne X9
					rjmp L21
				X9:
					rjmp L8
				L27:
					cpi R22,247
					ldi R30,0
					cpc R23,R30
					breq L13
					cpi R22,251
					ldi R30,0
					cpc R23,R30
					breq L12
					cpi R22,253
					ldi R30,0
					cpc R23,R30
					breq L11
					cpi R22,254
					ldi R30,0
					cpc R23,R30
					breq L10
					rjmp L8
				X0:
					.dbline 59
				;             {  
				L10:
					.dbline 60
				;                   case ~0xFF01:N=L7;break;
					ldi R24,1012
					ldi R25,3
					sts _N+1,R25
					sts _N,R24
					.dbline 60
					rjmp L9
				L11:
					.dbline 61
				;                   case ~0xFF02:N=M1;break;
					ldi R24,956
					ldi R25,3
					sts _N+1,R25
					sts _N,R24
					.dbline 61
					rjmp L9
				L12:
					.dbline 62
				;                   case ~0xFF04:N=M2;break;
					ldi R24,842
					ldi R25,3
					sts _N+1,R25
					sts _N,R24
					.dbline 62
					rjmp L9
				L13:
					.dbline 63
				;                   case ~0xFF08:N=M3;break;
					ldi R24,758
					ldi R25,2
					sts _N+1,R25
					sts _N,R24
					.dbline 63
					rjmp L9
				L14:
					.dbline 64
				;                   case ~0xFF10:N=M4;break;
					ldi R24,716
					ldi R25,2
					sts _N+1,R25
					sts _N,R24
					.dbline 64
					rjmp L9
				L15:
					.dbline 65
				;                   case ~0xFF20:N=M5;break;
					ldi R24,637
					ldi R25,2
					sts _N+1,R25
					sts _N,R24
					.dbline 65
					rjmp L9
				L16:
					.dbline 66
				;                   case ~0xFF40:N=M6;break;
					ldi R24,568
					ldi R25,2
					sts _N+1,R25
					sts _N,R24
					.dbline 66
					rjmp L9
				L17:
					.dbline 67
				;                   case ~0xFF80:N=M7;break;
					ldi R24,506
					ldi R25,1
					sts _N+1,R25
					sts _N,R24
					.dbline 67
					rjmp L9
				L18:
					.dbline 68
				;                   case ~0xFF81:N=L5;break;
					ldi R24,1275
					ldi R25,4
					sts _N+1,R25
					sts _N,R24
					.dbline 68
					rjmp L9
				L19:
					.dbline 69
				;                   case ~0xFF42:N=L6;break;
					ldi R24,1136
					ldi R25,4
					sts _N+1,R25
					sts _N,R24
					.dbline 69
					rjmp L9
				L20:
					.dbline 70
				;                   case ~0xFF24:N=H1;break;
					ldi R24,478
					ldi R25,1
					sts _N+1,R25
					sts _N,R24
					.dbline 70
					rjmp L9
				L21:
					.dbline 71
				;                   case ~0xFF18:N=H2;break;
					ldi R24,425
					ldi R25,1
					sts _N+1,R25
					sts _N,R24
					.dbline 71
					rjmp L9
				L8:
					.dbline 72
				;                   default:N=EM;TCCR1B=0x00;PORTC=0x00;
					ldi R24,1000
					ldi R25,3
					sts _N+1,R25
					sts _N,R24
					.dbline 72
					clr R2
					out 0x2e,R2
					.dbline 72
					out 0x15,R2
					.dbline 88
				; 				  /*
				; 				  case ~0xFF01:N=400;break;
				;                   case ~0xFF02:N=401;break;
				;                   case ~0xFF04:N=402;break;
				;                   case ~0xFF08:N=403;break;
				;                   case ~0xFF10:N=404;break;
				;                   case ~0xFF20:N=405;break;
				;                   case ~0xFF40:N=406;break;
				;                   case ~0xFF80:N=407;break;
				;                   case ~0xFF81:N=408;break;
				;                   case ~0xFF42:N=409;break;
				;                   case ~0xFF24:N=410;break;
				;                   case ~0xFF18:N=411;break;
				;                   default:N=399;TCCR1B=0x00;PORTC=0x00;
				; 				  */
				;             }
				L9:
					.dbline 89
				;         if (T==N)
					lds R2,_N
					lds R3,_N+1
					lds R4,_T
					lds R5,_T+1
					cp R4,R2
					cpc R5,R3
					brne L28
					.dbline 90
				;           ;
					rjmp L29
				L28:
					.dbline 92
				;         else
				; 		{
					.dbline 93
				;           T=N;
					lds R2,_N
					lds R3,_N+1
					sts _T+1,R3
					sts _T,R2
					.dbline 94
				; 		  TCCR1B=0x01;
					ldi R24,1
					out 0x2e,R24
					.dbline 95
				;           TCNT1=65535-T;
					lds R2,_T
					lds R3,_T+1
					ldi R24,65535
					ldi R25,255
					sub R24,R2
					sbc R25,R3
					out 0x2d,R25
					out 0x2c,R24
					.dbline 96
				;         }    
				L29:
					.dbline 100
				L6:
					.dbline 51
					rjmp L5
				X1:
					.dbline -2
					.dbline 101
				;            
				;       
				;     
				;   }
				; }
				L4:
					.dbline 0 ; func end
					ret
					.dbsym r x 20 c
					.dbsym r y 22 I
					.dbend
							

相关资源