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

📄 jidong.s

📁 基于m16的寻迹寻光小车程序
💻 S
📖 第 1 页 / 共 3 页
字号:
	lds R5,_count_1+2+1
	lds R2,_count_1
	lds R3,_count_1+1
	add R2,R24
	adc R3,R25
	adc R4,R26
	adc R5,R27
	std y+0,R2
	std y+1,R3
	std y+2,R4
	std y+3,R5
	ldd R2,y+0
	ldd R3,y+1
	ldd R4,y+2
	ldd R5,y+3
	sts _count_1+1,R3
	sts _count_1,R2
	sts _count_1+2+1,R5
	sts _count_1+2,R4
	ldi R24,100
	ldi R25,0
	ldi R26,0
	ldi R27,0
	cp R2,R24
	cpc R3,R25
	cpc R4,R26
	cpc R5,R27
	brge X44
	xjmp L81
X44:
X29:
	.dbline 290
;             {
	.dbline 291
;                 go_ahead();
	xcall _go_ahead
	.dbline 292
;                 if( ++count_1 >= 250 )
	ldi R24,1
	ldi R25,0
	ldi R26,0
	ldi R27,0
	lds R4,_count_1+2
	lds R5,_count_1+2+1
	lds R2,_count_1
	lds R3,_count_1+1
	add R2,R24
	adc R3,R25
	adc R4,R26
	adc R5,R27
	std y+4,R2
	std y+5,R3
	std y+6,R4
	std y+7,R5
	ldd R2,y+4
	ldd R3,y+5
	ldd R4,y+6
	ldd R5,y+7
	sts _count_1+1,R3
	sts _count_1,R2
	sts _count_1+2+1,R5
	sts _count_1+2,R4
	ldi R24,250
	ldi R25,0
	ldi R26,0
	ldi R27,0
	cp R2,R24
	cpc R3,R25
	cpc R4,R26
	cpc R5,R27
	brlt L83
X30:
	.dbline 293
;                 {
	.dbline 294
;                     turn_l();
	xcall _turn_l
	.dbline 295
;                     if( ++count_1 >= 350 )
	ldi R24,1
	ldi R25,0
	ldi R26,0
	ldi R27,0
	lds R4,_count_1+2
	lds R5,_count_1+2+1
	lds R2,_count_1
	lds R3,_count_1+1
	add R2,R24
	adc R3,R25
	adc R4,R26
	adc R5,R27
	std y+8,R2
	std y+9,R3
	std y+10,R4
	std y+11,R5
	ldd R2,y+8
	ldd R3,y+9
	ldd R4,y+10
	ldd R5,y+11
	sts _count_1+1,R3
	sts _count_1,R2
	sts _count_1+2+1,R5
	sts _count_1+2,R4
	ldi R24,94
	ldi R25,1
	ldi R26,0
	ldi R27,0
	cp R2,R24
	cpc R3,R25
	cpc R4,R26
	cpc R5,R27
	brlt L85
X31:
	.dbline 296
;                     {
	.dbline 297
;                         model = 0;
	clr R2
	sts _model,R2
	.dbline 298
;                         count_1 = 0;
	ldi R24,0
	ldi R25,0
	ldi R26,0
	ldi R27,0
	sts _count_1+1,R25
	sts _count_1,R24
	sts _count_1+2+1,R27
	sts _count_1+2,R26
	.dbline 299
;                         flag_zhangai = 0;
	sts _flag_zhangai,R2
	.dbline 300
;                     }
L85:
	.dbline 301
;                 }
L83:
	.dbline 302
;             }	
L81:
	.dbline 303
;         }
L79:
	.dbline 304
;     }
L77:
	.dbline 306
; 
;     if( model == 2 )              //左边有障碍
	lds R24,_model
	cpi R24,2
	breq X45
	xjmp L87
X45:
X32:
	.dbline 307
;     {
	.dbline 308
; 		model_a = model;
	mov R2,R24
	sts _model_a,R2
	.dbline 309
; 	    flag_zhangai = 1;
	ldi R24,1
	sts _flag_zhangai,R24
	.dbline 310
; 	    turn_r();
	xcall _turn_r
	.dbline 311
; 	    if( int_scan() == 0 )
	xcall _int_scan
	tst R16
	breq X46
	xjmp L89
X46:
X33:
	.dbline 312
; 	    {
	.dbline 313
;             if( ++count_2 >= 100 )
	ldi R24,1
	ldi R25,0
	ldi R26,0
	ldi R27,0
	lds R4,_count_2+2
	lds R5,_count_2+2+1
	lds R2,_count_2
	lds R3,_count_2+1
	add R2,R24
	adc R3,R25
	adc R4,R26
	adc R5,R27
	std y+0,R2
	std y+1,R3
	std y+2,R4
	std y+3,R5
	ldd R2,y+0
	ldd R3,y+1
	ldd R4,y+2
	ldd R5,y+3
	sts _count_2+1,R3
	sts _count_2,R2
	sts _count_2+2+1,R5
	sts _count_2+2,R4
	ldi R24,100
	ldi R25,0
	ldi R26,0
	ldi R27,0
	cp R2,R24
	cpc R3,R25
	cpc R4,R26
	cpc R5,R27
	brge X47
	xjmp L91
X47:
X34:
	.dbline 314
;             {
	.dbline 315
;                 go_ahead();
	xcall _go_ahead
	.dbline 316
;                 if( ++count_2 >= 250 )
	ldi R24,1
	ldi R25,0
	ldi R26,0
	ldi R27,0
	lds R4,_count_2+2
	lds R5,_count_2+2+1
	lds R2,_count_2
	lds R3,_count_2+1
	add R2,R24
	adc R3,R25
	adc R4,R26
	adc R5,R27
	std y+4,R2
	std y+5,R3
	std y+6,R4
	std y+7,R5
	ldd R2,y+4
	ldd R3,y+5
	ldd R4,y+6
	ldd R5,y+7
	sts _count_2+1,R3
	sts _count_2,R2
	sts _count_2+2+1,R5
	sts _count_2+2,R4
	ldi R24,250
	ldi R25,0
	ldi R26,0
	ldi R27,0
	cp R2,R24
	cpc R3,R25
	cpc R4,R26
	cpc R5,R27
	brlt L93
X35:
	.dbline 317
;                 {
	.dbline 318
;                     turn_l();
	xcall _turn_l
	.dbline 319
;                     if( ++count_2 >= 350 )
	ldi R24,1
	ldi R25,0
	ldi R26,0
	ldi R27,0
	lds R4,_count_2+2
	lds R5,_count_2+2+1
	lds R2,_count_2
	lds R3,_count_2+1
	add R2,R24
	adc R3,R25
	adc R4,R26
	adc R5,R27
	std y+8,R2
	std y+9,R3
	std y+10,R4
	std y+11,R5
	ldd R2,y+8
	ldd R3,y+9
	ldd R4,y+10
	ldd R5,y+11
	sts _count_2+1,R3
	sts _count_2,R2
	sts _count_2+2+1,R5
	sts _count_2+2,R4
	ldi R24,94
	ldi R25,1
	ldi R26,0
	ldi R27,0
	cp R2,R24
	cpc R3,R25
	cpc R4,R26
	cpc R5,R27
	brlt L95
X36:
	.dbline 320
;                     {
	.dbline 321
;                         model = 0;
	clr R2
	sts _model,R2
	.dbline 322
;                         count_2 = 0;
	ldi R24,0
	ldi R25,0
	ldi R26,0
	ldi R27,0
	sts _count_2+1,R25
	sts _count_2,R24
	sts _count_2+2+1,R27
	sts _count_2+2,R26
	.dbline 323
;                         flag_zhangai = 0;
	sts _flag_zhangai,R2
	.dbline 324
;                     }
L95:
	.dbline 325
;                 }
L93:
	.dbline 326
;             }	
L91:
	.dbline 327
;         }
L89:
	.dbline 328
;     }
L87:
	.dbline 330
; 
;     if( model == 3 )                 //右边有障碍
	lds R24,_model
	cpi R24,3
	breq X48
	xjmp L97
X48:
X37:
	.dbline 331
;     {
	.dbline 332
; 		model_a = model;
	mov R2,R24
	sts _model_a,R2
	.dbline 333
; 	    flag_zhangai = 1;
	ldi R24,1
	sts _flag_zhangai,R24
	.dbline 334
; 	    turn_l();
	xcall _turn_l
	.dbline 335
; 	    if( int_scan() == 0 )
	xcall _int_scan
	mov R10,R16
	tst R16
	breq X49
	xjmp L99
X49:
X38:
	.dbline 336
; 	    {
	.dbline 337
;             if( ++count_3 >= 100 )
	ldi R24,1
	ldi R25,0
	ldi R26,0
	ldi R27,0
	lds R4,_count_3+2
	lds R5,_count_3+2+1
	lds R2,_count_3
	lds R3,_count_3+1
	add R2,R24
	adc R3,R25
	adc R4,R26
	adc R5,R27
	std y+0,R2
	std y+1,R3
	std y+2,R4
	std y+3,R5
	ldd R2,y+0
	ldd R3,y+1
	ldd R4,y+2
	ldd R5,y+3
	sts _count_3+1,R3
	sts _count_3,R2
	sts _count_3+2+1,R5
	sts _count_3+2,R4
	ldi R24,100
	ldi R25,0
	ldi R26,0
	ldi R27,0
	cp R2,R24
	cpc R3,R25
	cpc R4,R26
	cpc R5,R27
	brge X50
	xjmp L101
X50:
X39:
	.dbline 338
;             {
	.dbline 339
;                 go_ahead();
	xcall _go_ahead
	.dbline 340
;                 if( ++count_3 >= 250 )
	ldi R24,1
	ldi R25,0
	ldi R26,0
	ldi R27,0
	lds R4,_count_3+2
	lds R5,_count_3+2+1
	lds R2,_count_3
	lds R3,_count_3+1
	add R2,R24
	adc R3,R25
	adc R4,R26
	adc R5,R27
	std y+4,R2
	std y+5,R3
	std y+6,R4
	std y+7,R5
	ldd R2,y+4
	ldd R3,y+5
	ldd R4,y+6
	ldd R5,y+7
	sts _count_3+1,R3
	sts _count_3,R2
	sts _count_3+2+1,R5
	sts _count_3+2,R4
	ldi R24,250
	ldi R25,0
	ldi R26,0
	ldi R27,0
	cp R2,R24
	cpc R3,R25
	cpc R4,R26
	cpc R5,R27
	brlt L103
X40:
	.dbline 341
;                 {
	.dbline 342
;                     turn_r();
	xcall _turn_r
	.dbline 343
;                     if( ++count_3 >= 350 )
	ldi R24,1
	ldi R25,0
	ldi R26,0
	ldi R27,0
	lds R4,_count_3+2
	lds R5,_count_3+2+1
	lds R2,_count_3
	lds R3,_count_3+1
	add R2,R24
	adc R3,R25
	adc R4,R26
	adc R5,R27
	std y+8,R2
	std y+9,R3
	std y+10,R4
	std y+11,R5
	ldd R2,y+8
	ldd R3,y+9
	ldd R4,y+10
	ldd R5,y+11
	sts _count_3+1,R3
	sts _count_3,R2
	sts _count_3+2+1,R5
	sts _count_3+2,R4
	ldi R24,94
	ldi R25,1
	ldi R26,0
	ldi R27,0
	cp R2,R24
	cpc R3,R25
	cpc R4,R26
	cpc R5,R27
	brlt L105
X41:
	.dbline 344
;                     {
	.dbline 345
;                         model = 0;
	clr R2
	sts _model,R2
	.dbline 346
;                         count_3 = 0;
	ldi R24,0
	ldi R25,0
	ldi R26,0
	ldi R27,0
	sts _count_3+1,R25
	sts _count_3,R24
	sts _count_3+2+1,R27
	sts _count_3+2,R26
	.dbline 347
;                         flag_zhangai = 0;
	sts _flag_zhangai,R2
	.dbline 348
;                     }
L105:
	.dbline 349
;                 }
L103:
	.dbline 350
;             }	
L101:
	.dbline 351
;         }
L99:
	.dbline 352
;     }
L97:
	.dbline -2
L72:
	.dbline 0 ; func end
	adiw R28,12
	ld R11,y+
	ld R10,y+
	ld R0,y+
	out 0x3f,R0
	ld R31,y+
	ld R30,y+
	ld R27,y+
	ld R26,y+
	ld R25,y+
	ld R24,y+
	ld R19,y+
	ld R18,y+
	ld R17,y+
	ld R16,y+
	ld R9,y+
	ld R8,y+
	ld R7,y+
	ld R6,y+
	ld R5,y+
	ld R4,y+
	ld R3,y+
	ld R2,y+
	ld R1,y+
	ld R0,y+
	reti
	.dbend
	.dbfunc e init_devices _init_devices fV
	.even
_init_devices::
	.dbline -1
	.dbline 364
; 	
; 	//time_on();
; 	
; 	//SEI();		   	        	
; }
; 
; 
; //***************避障部分结束*******************
; 
; //call this routine to initialize all peripherals
; void init_devices(void)
; {
	.dbline 366
;  //stop errant interrupts until set up
;  CLI(); //disable all interrupts
	cli
	.dbline 369
;  
;  //LCD_init();
;  L298_port_init();       //L298端口初始化
	xcall _L298_port_init
	.dbline 370
;  hw_port_init();         //红外感应端口初始化
	xcall _hw_port_init
	.dbline 371
;  timer0_init();          //定时器0初始化
	xcall _timer0_init
	.dbline 373
;  
;  ADC_REG_init();
	xcall _ADC_REG_init
	.dbline 374
;  ADC_port_init();
	xcall _ADC_port_init
	.dbline 376
;  
;  DDRD &=~ ( 1 << PD2 );   //int0中断初始化 用于充电
	cbi 0x11,2
	.dbline 377
;  PORTD |= ( 1 << PD2 );
	sbi 0x12,2
	.dbline 379
; 
;  MCUCR = 0x00;
	clr R2
	out 0x35,R2
	.dbline 380
;  GICR  = 0x40;            //INT0开启
	ldi R24,64
	out 0x3b,R24
	.dbline 381
;  TIMSK = 0x02; //timer interrupt sources
	ldi R24,2
	out 0x39,R24
	.dbline 383
;  //LCD_write_string( 1, 2, "car test...." );
;  SEI(); //re-enable interrupts
	sei
	.dbline -2
L107:
	.dbline 0 ; func end
	ret
	.dbend
	.area vector(rom, abs)
	.org 4
	jmp _int0_isr
	.area text(rom, con, rel)
	.dbfile C:\DOCUME~1\Administrator\桌面\复件自~1\自动充电小车\298\jidong.c
	.dbfunc e int0_isr _int0_isr fV
	.even
_int0_isr::
	st -y,R0
	st -y,R1
	st -y,R2
	st -y,R3
	st -y,R4
	st -y,R5
	st -y,R6
	st -y,R7
	st -y,R8
	st -y,R9
	st -y,R16
	st -y,R17
	st -y,R18
	st -y,R19
	st -y,R24
	st -y,R25
	st -y,R26
	st -y,R27
	st -y,R30
	st -y,R31
	in R0,0x3f
	st -y,R0
	.dbline -1
	.dbline 390
;  //all peripherals are now initialized
; }
; ////////////////////////////////////////////
; //取电中断
; #pragma interrupt_handler int0_isr:iv_INT0
; void int0_isr(void)
; {
	.dbline 392
;  //external interupt on INT0
;  CLI();
	cli
	.dbline 393
;  car_stop();
	xcall _car_stop
	.dbline 394
;  delay_ns( 20 );
	ldi R16,20
	xcall _delay_ns
	.dbline 395
;  go_back();
	xcall _go_back
	.dbline 396
;  delay_ns( 10 );
	ldi R16,10
	xcall _delay_ns
	.dbline 397
;  SEI();
	sei
	.dbline -2
L108:
	.dbline 0 ; func end
	ld R0,y+
	out 0x3f,R0
	ld R31,y+
	ld R30,y+
	ld R27,y+
	ld R26,y+
	ld R25,y+
	ld R24,y+
	ld R19,y+
	ld R18,y+
	ld R17,y+
	ld R16,y+
	ld R9,y+
	ld R8,y+
	ld R7,y+
	ld R6,y+
	ld R5,y+
	ld R4,y+
	ld R3,y+
	ld R2,y+
	ld R1,y+
	ld R0,y+
	reti
	.dbend
	.dbfunc e main _main fV
	.even
_main::
	.dbline -1
	.dbline 401
; }
; 
; void main( void )
; {
	.dbline 402
;     init_devices();
	xcall _init_devices
	xjmp L111
L110:
	.dbline 405
; 	
;     while( 1 )
;     {
	.dbline 406
;         model = int_scan();
	xcall _int_scan
	sts _model,R16
	.dbline 407
;     }
L111:
	.dbline 404
	xjmp L110
X51:
	.dbline -2
L109:
	.dbline 0 ; func end
	ret
	.dbend
	.area bss(ram, con, rel)
	.dbfile C:\DOCUME~1\Administrator\桌面\复件自~1\自动充电小车\298\jidong.c
_flag_zhangai::
	.blkb 1
	.dbsym e flag_zhangai _flag_zhangai c
	.area lit(rom, con, rel)
L49:
	.word 0x0,0x4480
L48:
	.word 0xd70a,0x4023
L8:
	.word 0x0,0x0
; }

⌨️ 快捷键说明

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