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

📄 app.s

📁 易于atmage128和ucos的手动机器人控制程序。
💻 S
📖 第 1 页 / 共 5 页
字号:
L285:
; 				  case 3: hand_cy[1]=hand_st_1[1];hand_whe[1]=0;break;
	lds R2,_hand_st_1+2
	lds R3,_hand_st_1+2+1
	sts _hand_cy+2+1,R3
	sts _hand_cy+2,R2
	clr R2
	clr R3
	sts _hand_whe+2+1,R3
	sts _hand_whe+2,R2
L270:
L271:
; 			   }
; 			}
L263:
; 			
; 			if((~rx_chr[2][2][0])&rx_chr[2][2][1]&(~rx_chr[2][5][1]))
	lds R2,_rx_chr+32+4+1
	lds R3,_rx_chr+32+4
	com R3
	and R3,R2
	lds R2,_rx_chr+32+10+1
	com R2
	and R3,R2
	brne X35
	xjmp L289
X35:
; 			{
; 			   switch(hand_whe[2])
	lds R2,_hand_whe+4
	lds R3,_hand_whe+4+1
	tst R2
	brne X20
	tst R3
	breq L302
X20:
	lds R24,_hand_whe+4
	lds R25,_hand_whe+4+1
	cpi R24,1
	ldi R30,0
	cpc R25,R30
	breq L306
	cpi R24,2
	ldi R30,0
	cpc R25,R30
	breq L310
	cpi R24,3
	ldi R30,0
	cpc R25,R30
	breq L314
	xjmp L299
X21:
; 			   {
L302:
; 			      case 0: hand_cy[2]=hand_st_2[2];hand_whe[2]=1;break;
	lds R2,_hand_st_2+4
	lds R3,_hand_st_2+4+1
	sts _hand_cy+4+1,R3
	sts _hand_cy+4,R2
	ldi R24,1
	ldi R25,0
	sts _hand_whe+4+1,R25
	sts _hand_whe+4,R24
	xjmp L300
L306:
; 				  case 1: hand_cy[2]=hand_st_3[2];hand_whe[2]=2;break;
	lds R2,_hand_st_3+4
	lds R3,_hand_st_3+4+1
	sts _hand_cy+4+1,R3
	sts _hand_cy+4,R2
	ldi R24,2
	ldi R25,0
	sts _hand_whe+4+1,R25
	sts _hand_whe+4,R24
	xjmp L300
L310:
; 				  case 2: hand_cy[2]=hand_st_2[2];hand_whe[2]=3;break;
	lds R2,_hand_st_2+4
	lds R3,_hand_st_2+4+1
	sts _hand_cy+4+1,R3
	sts _hand_cy+4,R2
	ldi R24,3
	ldi R25,0
	sts _hand_whe+4+1,R25
	sts _hand_whe+4,R24
	xjmp L300
L314:
; 				  case 3: hand_cy[2]=hand_st_1[2];hand_whe[2]=0;break;
	lds R2,_hand_st_1+4
	lds R3,_hand_st_1+4+1
	sts _hand_cy+4+1,R3
	sts _hand_cy+4,R2
	clr R2
	clr R3
	sts _hand_whe+4+1,R3
	sts _hand_whe+4,R2
L299:
L300:
; 			   }
; 			}
L289:
; 			
; 			if((~rx_chr[2][0][0])&rx_chr[2][0][1]&(~rx_chr[2][5][1]))
	lds R2,_rx_chr+32+1
	lds R3,_rx_chr+32
	com R3
	and R3,R2
	lds R2,_rx_chr+32+10+1
	com R2
	and R3,R2
	brne X36
	xjmp L318
X36:
; 			{
; 			   switch(hand_whe[3])
	lds R2,_hand_whe+6
	lds R3,_hand_whe+6+1
	tst R2
	brne X22
	tst R3
	breq L329
X22:
	lds R24,_hand_whe+6
	lds R25,_hand_whe+6+1
	cpi R24,1
	ldi R30,0
	cpc R25,R30
	breq L333
	cpi R24,2
	ldi R30,0
	cpc R25,R30
	breq L337
	cpi R24,3
	ldi R30,0
	cpc R25,R30
	breq L341
	xjmp L326
X23:
; 			   {
L329:
; 			      case 0: hand_cy[3]=hand_st_2[3];hand_whe[3]=1;break;
	lds R2,_hand_st_2+6
	lds R3,_hand_st_2+6+1
	sts _hand_cy+6+1,R3
	sts _hand_cy+6,R2
	ldi R24,1
	ldi R25,0
	sts _hand_whe+6+1,R25
	sts _hand_whe+6,R24
	xjmp L327
L333:
; 				  case 1: hand_cy[3]=hand_st_3[3];hand_whe[3]=2;break;
	lds R2,_hand_st_3+6
	lds R3,_hand_st_3+6+1
	sts _hand_cy+6+1,R3
	sts _hand_cy+6,R2
	ldi R24,2
	ldi R25,0
	sts _hand_whe+6+1,R25
	sts _hand_whe+6,R24
	xjmp L327
L337:
; 				  case 2: hand_cy[3]=hand_st_2[3];hand_whe[3]=3;break;
	lds R2,_hand_st_2+6
	lds R3,_hand_st_2+6+1
	sts _hand_cy+6+1,R3
	sts _hand_cy+6,R2
	ldi R24,3
	ldi R25,0
	sts _hand_whe+6+1,R25
	sts _hand_whe+6,R24
	xjmp L327
L341:
; 				  case 3: hand_cy[3]=hand_st_1[3];hand_whe[3]=0;break;
	lds R2,_hand_st_1+6
	lds R3,_hand_st_1+6+1
	sts _hand_cy+6+1,R3
	sts _hand_cy+6,R2
	clr R2
	clr R3
	sts _hand_whe+6+1,R3
	sts _hand_whe+6,R2
L326:
L327:
; 			   }
; 			}	
L318:
; 			if((~rx_chr[2][3][0])&rx_chr[2][3][1]&rx_chr[2][5][1]) //复合键  手爪全部闭合
	lds R2,_rx_chr+32+6+1
	lds R3,_rx_chr+32+6
	com R3
	and R3,R2
	lds R2,_rx_chr+32+10+1
	and R3,R2
	breq L345
; 			{
; 			   hand_cy[0]=hand_st_3[0];hand_whe[0]=2;
	lds R2,_hand_st_3
	lds R3,_hand_st_3+1
	sts _hand_cy+1,R3
	sts _hand_cy,R2
	ldi R24,2
	ldi R25,0
	sts _hand_whe+1,R25
	sts _hand_whe,R24
; 			   hand_cy[1]=hand_st_3[1];hand_whe[1]=2;
	lds R2,_hand_st_3+2
	lds R3,_hand_st_3+2+1
	sts _hand_cy+2+1,R3
	sts _hand_cy+2,R2
	sts _hand_whe+2+1,R25
	sts _hand_whe+2,R24
; 			   hand_cy[2]=hand_st_3[2];hand_whe[2]=2;
	lds R2,_hand_st_3+4
	lds R3,_hand_st_3+4+1
	sts _hand_cy+4+1,R3
	sts _hand_cy+4,R2
	sts _hand_whe+4+1,R25
	sts _hand_whe+4,R24
; 			   hand_cy[3]=hand_st_3[3];hand_whe[3]=2;
	lds R2,_hand_st_3+6
	lds R3,_hand_st_3+6+1
	sts _hand_cy+6+1,R3
	sts _hand_cy+6,R2
	sts _hand_whe+6+1,R25
	sts _hand_whe+6,R24
; 			}
L345:
; 	//给自动机器人发送信号-------------
; 	if(rx_chr[1][3][1])PORTC|=0x30;
	lds R2,_rx_chr+16+6+1
	tst R2
	breq L364
	in R24,0x15
	ori R24,48
	out 0x15,R24
	xjmp L365
L364:
; 	else PORTC&=0xcf;
	in R24,0x15
	andi R24,207
	out 0x15,R24
L365:
; }
L38:
	adiw R28,3
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.even
_reset_action:
	xcall push_gset1
	sbiw R28,3
; 
; /*
; *********************************************************************************************************
; *                                            复位
; *********************************************************************************************************
; */
; 
; static void  reset_action(void)
; {
;     robot_model_key++;
	lds R24,_robot_model_key
	subi R24,255    ; addi 1
	sts _robot_model_key,R24
; 	
; 	//数码管显示---------------------------
; 	LED_send_16b(0x0100|(robot_model_key/3));
	ldi R18,3
	ldi R19,0
	mov R16,R24
	clr R17
	xcall div16s
	ori R17,1
	xcall _LED_send_16b
; 	LED_send_16b(0x0200|(robot_model_key/3));
	ldi R18,3
	ldi R19,0
	lds R16,_robot_model_key
	clr R17
	xcall div16s
	ori R17,2
	xcall _LED_send_16b
; 	LED_send_16b(0x0300|(robot_model_key/3));
	ldi R18,3
	ldi R19,0
	lds R16,_robot_model_key
	clr R17
	xcall div16s
	ori R17,3
	xcall _LED_send_16b
; 	LED_send_16b(0x0400|(robot_model_key/3));
	ldi R18,3
	ldi R19,0
	lds R16,_robot_model_key
	clr R17
	xcall div16s
	ori R17,4
	xcall _LED_send_16b
; 	LED_send_16b(0x0500|(robot_model_key/3));
	ldi R18,3
	ldi R19,0
	lds R16,_robot_model_key
	clr R17
	xcall div16s
	ori R17,5
	xcall _LED_send_16b
; 	LED_send_16b(0x0600|(robot_model_key/3));
	ldi R18,3
	ldi R19,0
	lds R16,_robot_model_key
	clr R17
	xcall div16s
	ori R17,6
	xcall _LED_send_16b
; 	LED_send_16b(0x0700|(robot_model_key/3));
	ldi R18,3
	ldi R19,0
	lds R16,_robot_model_key
	clr R17
	xcall div16s
	ori R17,7
	xcall _LED_send_16b
; 	LED_send_16b(0x0800|(robot_model_key/3));
	ldi R18,3
	ldi R19,0
	lds R16,_robot_model_key
	clr R17
	xcall div16s
	ori R17,8
	xcall _LED_send_16b
; 	//行进电机--------------
; 	switch(robot_model_key)
	lds R20,_robot_model_key
	clr R21
	cpi R20,7
	ldi R30,0
	cpc R21,R30
	breq L374
	ldi R24,7
	ldi R25,0
	cp R24,R20
	cpc R25,R21
	brlt L377
L376:
	cpi R20,2
	ldi R30,0
	cpc R21,R30
	breq L373
	xjmp L370
L377:
	cpi R20,12
	ldi R30,0
	cpc R21,R30
	breq L375
	xjmp L370
X37:
; 	{
L373:
; 	case 2: motor_l_msg=0;motor_r_msg=0;break;
	clr R2
	clr R3
	sts _motor_l_msg+1,R3
	sts _motor_l_msg,R2
	sts _motor_r_msg+1,R3
	sts _motor_r_msg,R2
	xjmp L371
L374:
; 	case 7: motor_l_msg=1;motor_r_msg=1;break;
	ldi R24,1
	ldi R25,0
	sts _motor_l_msg+1,R25
	sts _motor_l_msg,R24
	sts _motor_r_msg+1,R25
	sts _motor_r_msg,R24
	xjmp L371
L375:
; 	case 12:motor_l_msg=10;motor_r_msg=10;break;
	ldi R24,10
	ldi R25,0
	sts _motor_l_msg+1,R25
	sts _motor_l_msg,R24
	sts _motor_r_msg+1,R25
	sts _motor_r_msg,R24
L370:
L371:
; 	}
; 	OSMboxPost(motor_l_Box,&motor_l_msg);  //发送左电机驱动邮件				  
	ldi R18,<_motor_l_msg
	ldi R19,>_motor_l_msg
	lds R16,_motor_l_Box
	lds R17,_motor_l_Box+1
	xcall _OSMboxPost
; 	OSMboxPost(motor_r_Box,&motor_r_msg);  //发送右电机驱动邮件	
	ldi R18,<_motor_r_msg
	ldi R19,>_motor_r_msg
	lds R16,_motor_r_Box
	lds R17,_motor_r_Box+1
	xcall _OSMboxPost
; 	//手爪----------------------------
; 	switch(robot_model_key)
	lds R20,_robot_model_key
	clr R21
	cpi R20,12
	ldi R30,0
	cpc R21,R30
	breq L388
	ldi R24,12
	ldi R25,0
	cp R24,R20
	cpc R25,R21
	brlt L406
L405:
	cpi R20,2
	ldi R30,0
	cpc R21,R30
	breq L381
	xjmp L378
L406:
	cpi R20,22
	ldi R30,0
	cpc R21,R30
	brne X49
	xjmp L395
X49:
	xjmp L378
X38:
; 	{
L381:
; 	case  2:hand_cy[0]=hand_st_3[0];hand_cy[1]=hand_st_3[1];hand_cy[2]=hand_st_3[2];hand_cy[3]=hand_st_3[3];break;
	lds R2,_hand_st_3
	lds R3,_hand_st_3+1
	sts _hand_cy+1,R3
	sts _hand_cy,R2
	lds R2,_hand_st_3+2
	lds R3,_hand_st_3+2+1
	sts _hand_cy+2+1,R3
	sts _hand_cy+2,R2
	lds R2,_hand_st_3+4
	lds R3,_hand_st_3+4+1
	sts _hand_cy+4+1,R3
	sts _hand_cy+4,R2
	lds R2,_hand_st_3+6
	lds R3,_hand_st_3+6+1
	sts _hand_cy+6+1,R3
	sts _hand_cy+6,R2
	xjmp L379
L388:
; 	case 12:hand_cy[0]=hand_st_2[0];hand_cy[1]=hand_st_2[1];hand_cy[2]=hand_st_2[2];hand_cy[3]=hand_st_2[3];break;
	lds R2,_hand_st_2
	lds R3,_hand_st_2+1
	sts _hand_cy+1,R3
	sts _hand_cy,R2
	lds R2,_hand_st_2+2
	lds R3,_hand_st_2+2+1
	sts _hand_cy+2+1,R3
	sts _hand_cy+2,R2
	lds R2,_hand_st_2+4
	lds R3,_hand_st_2+4+1
	sts _hand_cy+4+1,R3
	sts _hand_cy+4,R2
	lds R2,_hand_st_2+6
	lds R3,_hand_st_2+6+1
	sts _hand_cy+6+1,R3
	sts _hand_cy+6,R2
	xjmp L379
L395:
; 	case 22:hand_cy[0]=hand_st_1[0];hand_cy[1]=hand_st_1[1];hand_cy[2]=hand_st_1[2];hand_cy[3]=hand_st_1[3];hand_whe[0]=0;hand_whe[1]=0;hand_whe[2]=0;hand_whe[3]=0;break;
	lds R2,_hand_st_1
	lds R3,_hand_st_1+1
	sts _hand_cy+1,R3
	sts _hand_cy,R2
	lds R2,_hand_st_1+2
	lds R3,_hand_st_1+2+1
	sts _hand_cy+2+1,R3
	sts _hand_cy+2,R2
	lds R2,_hand_st_1+4
	lds R3,_hand_st_1+4+1
	sts _hand_cy+4+1,R3
	sts _hand_cy+4,R2
	lds R2,_hand_st_1+6
	lds R3,_hand_st_1+6+1
	sts _hand_cy+6+1,R3
	sts _hand_cy+6,R2
	clr R2
	clr R3
	sts _hand_whe+1,R3
	sts _hand_whe,R2
	sts _hand_whe+2+1,R3
	sts _hand_whe+2,R2
	sts _hand_whe+4+1,R3
	sts _hand_whe+4,R2
	sts _hand_whe+6+1,R3
	sts _hand_whe+6,R2
L378:
L379:
; 	}
; 	//提升-----------------------
; 	
; 	switch(robot_model_tmp)
	lds R20,_robot_model_tmp
	clr R21
	cpi R20,0
	cpc R20,R21
	breq L410
X39:
	cpi R20,1
	ldi R30,0
	cpc R21,R30
	brne X50
	xjmp L414
X50:
	cpi R20,2
	ldi R30,0
	cpc R21,R30
	brne X51
	xjmp L422
X51:
	cpi R20,3
	ldi R30,0
	cpc R21,R30
	brne X52
	xjmp L425
X52:
	cpi R20,4
	ldi R30,0
	cpc R21,R30
	brne X53
	xjmp L433
X53:
	cpi R20,5
	ldi R30,0
	cpc R21,R30
	brne X54
	xjmp L436
X54:
	cpi R20,6
	ldi R30,0
	cpc R21,R30
	brne X55
	xjmp L441
X55:
	cpi R20,7
	ldi R30,0
	cpc R21,R30
	brne X56
	xjmp L449
X56:
	xjmp L407
X40:
; 	{
L410:
; 	   case 0: motor_t_msg=12; if(!contact_t[0][1]) {robot_model_tmp=1;motor_t_msg=11;}break;
	ldi R24,12
	ldi R25,0
	sts _motor_t_msg+1,R25
	sts _motor_t_msg,R24
	lds R2,_contact_t+2
	lds R3,_contact_t+2+1
	tst R2
	breq X57
	xjmp L408
X57:
	tst R3
	breq X58
	xjmp L408
X58:
X41:
	ldi R24,1
	sts _robot_model_tmp,R24
	ldi R24,11
	ldi R25,0
	sts _motor_t_msg+1,R25
	sts _motor_t_msg,R24
	xjmp L408
L414:
; 	   case 1: motor_t_msg=11; if((!contact_t[3][1])&contact_t[3][0]) {robot_model_tmp=2;motor_t_msg=10;	}break;
	ldi R24,11
	ldi R25,0
	sts _motor_t_msg+1,R25
	sts _motor_t_msg,R24
	lds R2,_contact_t+12+2
	lds R3,_contact_t+12+2+1
	tst R2
	brne L420
	tst R3
	brne L420
X42:
	ldi R20,1
	ldi R21,0
	xjmp L421
L420:
	clr R20
	clr R21
L421:
	lds R2,_contact_t+12
	lds R3,_contact_t+12+1
	movw R4,R20
	and R4,R2
	and R5,R3
	tst R4
	brne X43
	tst R5
	brne X59
	xjmp L408
X59:
X43:
	ldi R24,2
	sts _robot_model_tmp,R24
	ldi R24,10
	ldi R25,0
	sts _motor_t_msg+1,R25
	sts _motor_t_msg,R24
	xjmp L408
L422:
; 	   case 2: motor_t_msg=10; robot_model_dly++; if(robot_model_dly==5) robot_model_tmp=3;break;
	ldi R24,10
	ldi R25,0
	sts _motor_t_msg+1,R25
	sts _motor_t_msg,R24
	lds R24,_robot_model_dly
	lds R25,_rob

⌨️ 快捷键说明

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