⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.s

📁 一个单片机的完整开发程序AVR的
💻 S
📖 第 1 页 / 共 5 页
字号:
	.module main.c
	.area data(ram, con, rel)
_table::
	.blkb 2
	.area idata
	.byte 235,96
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.byte 199,143
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.byte 46,189
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.byte 237,11
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.byte 239,175
	.area data(ram, con, rel)
	.dbfile F:\赵一\edu6000_1202\main.c
	.dbsym e table _table A[10:10]c
	.area text(rom, con, rel)
	.dbfile F:\赵一\edu6000_1202\main.c
	.dbfunc e port_init _port_init fV
	.even
_port_init::
	.dbline -1
	.dbline 15
; //ICC-AVR application builder : 2004-11-19 9:42:35
; // Target : M8
; // Crystal: 7.3728Mhz
; #include <eeprom.h>
; #include "head.h"
; 
; unsigned char getchar(void);       //申明函数:串口接收函数;
; void sendchar(unsigned char data); //申明函数:串口发送函数;
; unsigned char table[10]={0xeb,0x60,0xc7,0x8f,0x2e,0xbd,0xed,0x0b,0xef,0xaf};
; unsigned char lcd_buffer[16];      
; unsigned char host_id,guest_id,t,ques[100],data[110],ques_num;
; unsigned int t1;
; 
; void port_init(void)
; {
	.dbline 16
;  PORTB = 0xDF;
	ldi R24,223
	out 0x18,R24
	.dbline 17
;  DDRB  = 0xFF;
	ldi R24,255
	out 0x17,R24
	.dbline 18
;  PORTC = 0x75; //m103 output only
	ldi R24,117
	out 0x15,R24
	.dbline 19
;  DDRC  = 0x77;
	ldi R24,119
	out 0x14,R24
	.dbline 20
;  PORTD = 0xFF;
	ldi R24,255
	out 0x12,R24
	.dbline 21
;  DDRD  = 0x97;
	ldi R24,151
	out 0x11,R24
	.dbline -2
	.dbline 22
; }
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e uart0_init _uart0_init fV
	.even
_uart0_init::
	.dbline -1
	.dbline 30
; 
; //UART0 initialisation
; // desired baud rate: 9600
; // actual: baud rate:9600 (0.0%)
; // char size: 8 bit
; // parity: Disabled
; void uart0_init(void)
; {
	.dbline 31
;  UCSRB = 0x00; //disable while setting baud rate
	clr R2
	out 0xa,R2
	.dbline 32
;  UCSRA = 0x00;
	out 0xb,R2
	.dbline 33
;  UCSRC = 0x86;
	ldi R24,134
	out 0x20,R24
	.dbline 34
;  UBRRL = 0x2F; //set baud rate lo
	ldi R24,47
	out 0x9,R24
	.dbline 35
;  UBRRH = 0x00; //set baud rate hi
	out 0x20,R2
	.dbline 36
;  UCSRB = 0x18;
	ldi R24,24
	out 0xa,R24
	.dbline -2
	.dbline 37
; }
L2:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e timer0_init _timer0_init fV
	.even
_timer0_init::
	.dbline -1
	.dbline 40
; 
; void timer0_init(void)
; {
	.dbline 41
;  TCCR0 = 0x00; //stop
	clr R2
	out 0x33,R2
	.dbline 42
;  TCNT0 = 0x00 /*INVALID SETTING*/; //set count
	out 0x32,R2
	.dbline 43
;  TCCR0 = 0x05; //start timer
	ldi R24,5
	out 0x33,R24
	.dbline -2
	.dbline 44
; }
L3:
	.dbline 0 ; func end
	ret
	.dbend
	.area vector(rom, abs)
	.org 36
	jmp _timer0_ovf_isr
	.area text(rom, con, rel)
	.dbfile F:\赵一\edu6000_1202\main.c
	.dbfunc e timer0_ovf_isr _timer0_ovf_isr fV
	.even
_timer0_ovf_isr::
	st -y,R2
	st -y,R24
	st -y,R25
	in R2,0x3f
	st -y,R2
	.dbline -1
	.dbline 48
	.dbline 49
	clr R2
	out 0x32,R2
	.dbline 50
	lds R24,_t
	subi R24,255    ; addi 1
	sts _t,R24
	.dbline 51
	ldi R24,100
	lds R2,_t
	cp R24,R2
	brsh L5
	.dbline 52
	.dbline 53
	lds R24,_t1
	lds R25,_t1+1
	adiw R24,1
	sts _t1+1,R25
	sts _t1,R24
	.dbline 54
	clr R2
	sts _t,R2
	.dbline 55
L5:
	.dbline -2
	.dbline 56
; 
; #pragma interrupt_handler timer0_ovf_isr:10
; void timer0_ovf_isr(void)
; {
;  TCNT0 = 0x00 /*INVALID SETTING*/; //reload counter value
;  t++;
;  if(t>100)
;  {
;   t1++; 
;   t=0;
;  }
; }
L4:
	ld R2,y+
	out 0x3f,R2
	ld R25,y+
	ld R24,y+
	ld R2,y+
	.dbline 0 ; func end
	reti
	.dbend
	.dbfunc e adc_init _adc_init fV
	.even
_adc_init::
	.dbline -1
	.dbline 59
; 
; void adc_init(void)
; {
	.dbline 60
;  DDRC=0x77;
	ldi R24,119
	out 0x14,R24
	.dbline 61
;  PORTC=0x75;
	ldi R24,117
	out 0x15,R24
	.dbline 62
;  ADCSRA = 0x00; //disable adc
	clr R2
	out 0x6,R2
	.dbline 63
;  ADMUX = 0xC3; //select adc input 0
	ldi R24,195
	out 0x7,R24
	.dbline 64
;  ACSR  = 0x80;
	ldi R24,128
	out 0x8,R24
	.dbline 65
;  ADCSRA = 0xC6;
	ldi R24,198
	out 0x6,R24
	.dbline -2
	.dbline 66
; }
L7:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e init_devices _init_devices fV
	.even
_init_devices::
	.dbline -1
	.dbline 70
; 
; //call this routine to initialise all peripherals
; void init_devices(void)
; {
	.dbline 72
;  //stop errant interrupts until set up
;  CLI(); //disable all interrupts
	cli
	.dbline 73
;  port_init();
	xcall _port_init
	.dbline 74
;  uart0_init();
	xcall _uart0_init
	.dbline 75
;  timer0_init();
	xcall _timer0_init
	.dbline 76
;  adc_init();
	xcall _adc_init
	.dbline 78
; 
;  MCUCR = 0x00;
	clr R2
	out 0x35,R2
	.dbline 79
;  GICR  = 0x00;
	out 0x3b,R2
	.dbline 80
;  TIMSK = 0x01; //timer interrupt sources
	ldi R24,1
	out 0x39,R24
	.dbline 81
;  SEI(); //re-enable interrupts
	sei
	.dbline -2
	.dbline 83
;  //all peripherals are now initialised
; }
L8:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e sendchar _sendchar fV
;           data -> R16
	.even
_sendchar::
	.dbline -1
	.dbline 87
; 
; //send data from the UART.
; void sendchar(unsigned char data)
; {
L10:
	.dbline 88
L11:
	.dbline 88
;  while(!(UCSRA&(1<<UDRE)));
	sbis 0xb,5
	rjmp L10
	.dbline 89
;  UDR=data;
	out 0xc,R16
	.dbline -2
	.dbline 90
; }
L9:
	.dbline 0 ; func end
	ret
	.dbsym r data 16 c
	.dbend
	.dbfunc e getchar _getchar fc
	.even
_getchar::
	.dbline -1
	.dbline 93
; //receive data from the UART.
; unsigned char getchar(void)
; {
L14:
	.dbline 94
L15:
	.dbline 94
;  while(!(UCSRA&(1<<RXC)));
	sbis 0xb,7
	rjmp L14
	.dbline 95
;  return UDR;
	in R16,0xc
	.dbline -2
L13:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e send_ans _send_ans fV
;            chk -> R20
;              i -> R22
;        ans_num -> R10
;       star_num -> R12
;      star_flag -> R22
	.even
_send_ans::
	xcall push_gset4
	mov R12,R18
	mov R22,R16
	ldd R10,y+8
	.dbline -1
	.dbline 99
; }
; 
; void send_ans(unsigned char star_flag,unsigned char star_num,unsigned char ans_num)
; {
	.dbline 101
;  unsigned char i,chk;
;  chk=0xFF;
	ldi R20,255
	.dbline 102
;  chk=0xFF^star_flag;
	ldi R24,255
	ldi R25,0
	mov R20,R22
	clr R21
	eor R20,R24
	eor R21,R25
	.dbline 103
; 	sendchar(star_flag);
	mov R16,R22
	xcall _sendchar
	.dbline 104
; 	chk^=0x78;
	ldi R24,120
	eor R20,R24
	.dbline 105
; 	sendchar(0x78);
	ldi R16,120
	xcall _sendchar
	.dbline 106
; 	chk^=0xAB;
	ldi R24,171
	ldi R25,0
	mov R2,R20
	clr R3
	eor R2,R24
	eor R3,R25
	mov R20,R2
	.dbline 107
; 	sendchar(0xAB);
	ldi R16,171
	xcall _sendchar
	.dbline 108
; 	chk^=0xEF;
	ldi R24,239
	ldi R25,0
	mov R2,R20
	clr R3
	eor R2,R24
	eor R3,R25
	mov R20,R2
	.dbline 109
; 	sendchar(0xEF);
	ldi R16,239
	xcall _sendchar
	.dbline 110
; 	chk^=host_id;
	lds R2,_host_id
	eor R20,R2
	.dbline 111
; 	sendchar(host_id);
	mov R16,R2
	xcall _sendchar
	.dbline 112
; 	chk^=guest_id;
	lds R2,_guest_id
	eor R20,R2
	.dbline 113
; 	sendchar(guest_id);
	mov R16,R2
	xcall _sendchar
	.dbline 114
; 	chk^=0x01;
	ldi R24,1
	eor R20,R24
	.dbline 115
; 	sendchar(0x01);
	ldi R16,1
	xcall _sendchar
	.dbline 116
; 	chk^=ques_num;
	lds R2,_ques_num
	eor R20,R2
	.dbline 117
; 	sendchar(ques_num);
	mov R16,R2
	xcall _sendchar
	.dbline 118
; 	for(i=star_num;i<ans_num;i++)
	mov R22,R12
	xjmp L21
L18:
	.dbline 119
	.dbline 120
	ldi R24,<_ques
	ldi R25,>_ques
	mov R30,R22
	clr R31
	add R30,R24
	adc R31,R25
	ldd R16,z+0
	xcall _sendchar
	.dbline 121
	ldi R24,<_ques
	ldi R25,>_ques
	mov R30,R22
	clr R31
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	eor R20,R2
	.dbline 122
L19:
	.dbline 118
	inc R22
L21:
	.dbline 118
	cp R22,R10
	brlo L18
	.dbline 123
; 	{
; 	 sendchar(ques[i]);
; 	 chk^=ques[i];
; 	}
; 	chk^=0xF0;
	ldi R24,240
	ldi R25,0
	mov R2,R20
	clr R3
	eor R2,R24
	eor R3,R25
	mov R20,R2
	.dbline 124
; 	sendchar(0xF0);
	ldi R16,240
	xcall _sendchar
	.dbline 125
; 	chk^=0x0F;
	ldi R24,15
	eor R20,R24
	.dbline 126
; 	sendchar(0x0F);
	ldi R16,15
	xcall _sendchar
	.dbline 127
; 	sendchar(chk);
	mov R16,R20
	xcall _sendchar
	.dbline -2
	.dbline 128
; }
L17:
	xcall pop_gset4
	.dbline 0 ; func end
	ret
	.dbsym r chk 20 c
	.dbsym r i 22 c
	.dbsym r ans_num 10 c
	.dbsym r star_num 12 c
	.dbsym r star_flag 22 c
	.dbend
	.dbfunc e send_answer _send_answer fV
	.even
_send_answer::
	sbiw R28,1
	.dbline -1
	.dbline 131
; 
; void send_answer()
; {
	.dbline 133
; 
;  if(ques_num<38)
	lds R24,_ques_num
	cpi R24,38
	brsh L23
	.dbline 134
;  	send_ans(0x12,0,ques_num);			
	mov R2,R24
	std y+0,R2
	clr R18
	ldi R16,18
	xcall _send_ans
	xjmp L24
L23:
	.dbline 135
; 	else if(ques_num>37&&ques_num<75)
	ldi R24,37
	lds R2,_ques_num
	cp R24,R2
	brsh L25
	mov R24,R2
	cpi R24,75
	brsh L25
	.dbline 136
; 	{
	.dbline 137
; 	send_ans(0x12,0,37);
	ldi R24,37
	std y+0,R24
	clr R18
	ldi R16,18
	xcall _send_ans
	.dbline 138
; 	send_ans(0x13,37,ques_num);
	lds R2,_ques_num
	std y+0,R2
	ldi R18,37
	ldi R16,19
	xcall _send_ans
	.dbline 139
; 	}
	xjmp L26
L25:
	.dbline 141
; 	else
; 	{
	.dbline 142
; 	 send_ans(0x12,0,37);
	ldi R24,37
	std y+0,R24
	clr R18
	ldi R16,18
	xcall _send_ans
	.dbline 143
; 	 send_ans(0x13,37,74);
	ldi R24,74
	std y+0,R24
	ldi R18,37
	ldi R16,19
	xcall _send_ans
	.dbline 144
; 	 send_ans(0x14,74,ques_num); 
	lds R2,_ques_num
	std y+0,R2
	ldi R18,74
	ldi R16,20
	xcall _send_ans
	.dbline 145
; 	}
L26:
L24:
	.dbline -2
	.dbline 146
; }
L22:
	adiw R28,1
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e receive _receive fc
;              j -> R20
;              i -> R20
	.even
_receive::
	xcall push_gset1
	.dbline -1
	.dbline 149
; 
; unsigned char receive()//
; {
L28:
	.dbline 151
;  unsigned char i,j;
;  begin:	if(t>18)    return 0;//goto A;
	ldi R24,18
	lds R2,_t
	cp R24,R2
	brsh L29
	.dbline 151
	clr R16
	xjmp L27
L29:
	.dbline 152
; 	i=getchar();     //get data from RF
	xcall _getchar
	mov R20,R16
	.dbline 153
;   	if(i==0x0f)      //get the start signal
	cpi R16,15
	brne L28
	.dbline 154
;   	{
	.dbline 155
; 	 data[0]=getchar();
	xcall _getchar
	sts _data,R16
	.dbline 156
; 	 if(data[0]==0xf0)
	cpi R16,240
	brne L28
	.dbline 157
; 	 {
	.dbline 158
;       data[1]=getchar();
	xcall _getchar
	sts _data+1,R16
	.dbline 159
; 	  if(data[1]==0xdd)
	cpi R16,221
	brne L28
	.dbline 160
; 	  {
	.dbline 161
; 	   data[2]=getchar();
	xcall _getchar
	sts _data+2,R16
	.dbline 162
; 	   if(data[2]==0xbb)
	cpi R16,187
	brne L28
	.dbline 163
; 	   {
	.dbline 164
; 	   	data[3]=getchar();
	xcall _getchar
	sts _data+3,R16
	.dbline 165
; 	  	if(data[3]==host_id)
	lds R2,_host_id
	cp R16,R2
	brne L28
	.dbline 166
; 	  	{
	.dbline 167
; 	  	 data[4]=getchar();
	xcall _getchar
	sts _data+4,R16
	.dbline 168
; 	  	 if(data[4]==guest_id||data[4]==0xfe||data[4]==0xdb)
	lds R2,_guest_id
	cp R16,R2
	breq L54
	cpi R16,254
	breq L54
	cpi R16,219
	brne L28
L54:
	.dbline 169
; 	 	 {
	.dbline 170
; 	  	  for(j=5;j<12+ques_num;j++)   //
	ldi R20,5
	xjmp L58
L55:
	.dbline 171
	xcall _getchar
	ldi R24,<_data
	ldi R25,>_data
	mov R30,R20
	clr R31
	add R30,R24
	adc R31,R25
	std z+0,R16
L56:
	.dbline 170
	inc R20
L58:
	.dbline 170
	lds R24,_ques_num
	subi R24,244    ; addi 12
	cp R20,R24
	brlo L55
	.dbline 172
; 	  	  data[j]=getchar();
;   	 	 }
	.dbline 173
; 		 else goto begin;
	.dbline 174
; 		}
	.dbline 175
; 		else goto begin;
	.dbline 176
; 	   }
	.dbline 177
; 	   else goto begin;
	.dbline 178
; 	  }
	.dbline 179
; 	  else goto begin;
	.dbline 180
; 	 }
	.dbline 181
; 	 else goto begin; 
	.dbline 182
; 	}
	.dbline 183
; 	else goto begin;
L32:
	.dbline 184
;    return 1;
	ldi R16,1
	.dbline -2
L27:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r j 20 c
	.dbsym r i 20 c
	.dbend
	.dbfunc e main _main fV
;             d1 -> <dead>
;          score -> R10
;           temp -> y+217
;      keye_flag -> y+216
;      keyd_flag -> y+215
;      keyb_flag -> y+214
;      keya_flag -> y+213

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -