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

📄 run.asl

📁 一款智能老鼠的玩具源代码
💻 ASL
📖 第 1 页 / 共 3 页
字号:
00ED FD 00          211 	sta	m_offset_ini_h    ;go ahead
00EF F3 00          212 	lda	#<c_offset_f_ini
00F1 FD 00          213 	sta	m_offset_ini
00F3 F3 02          214 	lda	#2
00F5 02 00 D4       215 	br	next_status_set_end1
+                   216 	
+                   217 
+                   218 ;set_rules::
+                   219 ;	;lda	flg_new_random
+                   220 ;	cmpe	#1
+                   221 ;;	brnz	set_rules_end
+                   222 ;	brnz	rules_for_ir		;if the flg_new_random is 2, set some rules for run when received ir.
+                   223 ;	
+                   224 ;;-------------------------------------这是flg_new_random==1时的设置一些规则,即是没有障碍物的情况下。
+                   225 ;rules_for_free_run:			;
+                   226 ;	lda	flg_motor_status	;if the previous status is turning left or right, the next move status is straight forward.
+                   227 ;	cmpe	#c_flg_stop		;if the previous status is stop, not stop next.
+                   228 ;	brz	next_status_not_stop	;前一运行状态是停止
+                   229 ;	cmpe	#c_flg_left
+                   230 ;	brz	next_status_forward	;前一运行状态是向左,则下一个是向前
+                   231 ;	cmpe	#c_flg_right
+                   232 ;	brz	next_status_forward	;前一运行状态是向右,则下一个是向前
+                   233 ;next_status_random:			;if not, the next status is selected from the whole move status.
+                   234 ;	lda	#0
+                   235 ;	sta	m_offset_ini		;add the high 8bit of the offset register	
+                   236 ;	sta	m_offset_ini_h
+                   237 ;	lda	#c_mtr_tab_row
+                   238 ;	sta	m_rnd_range
+                   239 ;	br	set_rules_end
+                   240 ;next_status_forward:			;revise for adding the high 8bit of the offset register
+                   241 ;	lda	#>c_offset_f_ini
+                   242 ;	sta	m_offset_ini_h
+                   243 ;	lda	#<c_offset_f_ini
+                   244 ;	sta	m_offset_ini
+                   245 ;	lda	#c_rnd_range_f
+                   246 ;	sta	m_rnd_range
+                   247 ;	br	set_rules_end
+                   248 ;next_status_not_stop:			;add the rules for not stop continuously
+                   249 ;	lda	#>c_offset_f_ini
+                   250 ;	sta	m_offset_ini_h
+                   251 ;	lda	#<c_offset_f_ini
+                   252 ;	sta	m_offset_ini
+                   253 ;	lda	#c_rnd_range_not_stop
+                   254 ;	sta	m_rnd_range
+                   255 ;	br	set_rules_end
+                   256 ;;--------------------------------------这是flg_new_random==2时的设置一些规则,即是有障碍物的情况下。
+                   257 ;rules_for_ir:
+                   258 ;	lda	temp_flg_ir_received	;上一次的红外状态
+                   259 ;	cmpe	#c_flg_l_rcved		;前一个是左边有障碍物	
+                   260 ;	brz	$1
+                   261 ;	cmpe	#c_flg_f_l_rcved
+                   262 ;	brz	$1
+                   263 ;	cmpe	#c_flg_r_rcved
+                   264 ;	brz	$2
+                   265 ;	cmpe	#c_flg_f_r_rcved
+                   266 ;	brz	$2
+                   267 ;	br	set_rules_end
+                   268 ;$1:
+                   269 ;	lda	flg_ir_received		;对照今次的红外状态
+                   270 ;	cmpe	#c_flg_r_rcved
+                   271 ;	brz	next_status_forward
+                   272 ;	cmpe	#c_flg_f_r_rcved
+                   273 ;	brz	next_status_forward
+                   274 ;	br	set_rules_end
+                   275 ;$2:
+                   276 ;	lda	flg_ir_received
+                   277 ;	cmpe	#c_flg_l_rcved
+                   278 ;	brz	next_status_forward
+                   279 ;	cmpe	#c_flg_f_l_rcved
+                   280 ;	brz	next_status_forward
+                   281 ;	
+                   282 ;set_rules_end:
+                   283 ;	lda	#0
+                   284 ;	sta	flg_new_random
+                   285 ;	lda	flg_ir_received
+                   286 ;	sta	temp_flg_ir_received
+                   287 ;	ret
+                   288 ;;================================================================;
+                   289 ;;****************************************************************;
+                   290 ;; IR Judge
+                   291 ;
+                   292 ;; Carrier Frequency: 38K
+                   293 ;; IR transmit output pin: PRTC[0]
+                   294 ;; IR receive input pins: PRTD[0](front side)
+                   295 ;;                        PRTD[1](left side)
+                   296 ;;                        PRTD[2](right side)
+                   297 ;;
+                   298 ;; Written by: lixy
+                   299 ;; Date: 2004-04-08
+                   300 ;;****************************************************************;
+                   301 ;
+                   302 ;;================================================================;
+                   303 ;;Constant Area
+                   304 ;;================================================================;
+                   305 ;c_prtc012_1		equ	#00000111b
+                   306 ;c_prtc012_0		equ	#11111000b
+                   307 ;
+                   308 ;c_prtd012_1		equ	#00000111b
+                   309 ;c_prtd0_1		equ	#00000001b
+                   310 ;c_prtd0_0		equ	#11111110b
+                   311 ;c_prtd1_1		equ	#00000010b
+                   312 ;c_prtd1_0		equ	#11111101b
+                   313 ;c_prtd2_1		equ	#00000100b
+                   314 ;c_prtd2_0		equ	#11111011b
+                   315 
+                   316 ;;c_38k_pulse		equ	#22		;the total number of 38k IR pulse transmitted(23*26us=598us)
+                   317 ;;//04-03-17// revise the ir groups total number (primer value is 20)
+                   318 ;;c_ir_group		equ	#12		;the interval between 38k pulse groups in one IR group
+                   319 ;;end revise //04-03-17//
+                   320 ;c_ir_rcv_f		equ	#10
+                   321 ;c_ir_rcv_l		equ	#10
+                   322 ;c_ir_rcv_r		equ	#10
+                   323 ;c_flg_f_rcved		equ	#1		;表示前面有障碍物
+                   324 ;c_flg_l_rcved		equ	#2		;表示左面有障碍物
+                   325 ;c_flg_r_rcved		equ	#3		;表示右边有障碍物
+                   326 ;c_flg_f_l_rcved		equ	#4		;表示前左有障碍物
+                   327 ;c_flg_f_r_rcved		equ	#5		;表示前右有障碍物
+                   328 ;c_flg_l_r_rcved		equ	#6		;表示左右有障碍物
+                   329 ;c_flg_f_l_r_rcved	equ	#7		;表示前左右都有障碍物
+                   330 
+                   331 ;c_offset_f		equ	#0
+                   332 ;;--------------------------------------以下为左转的开始偏移
+                   333 ;c_offset_l_20		equ	#72		;=9(row)*8(column) left 20 degree
+                   334 ;c_offset_l_40		equ	#80		;=10(row)*8(column) left 40 degree
+                   335 ;c_offset_l_60		equ	#88		;=11(row)*8(column) left 60 degree
+                   336 ;c_offset_l_80		equ	#96		;=12(row)*8(column) left 80 degree
+                   337 ;c_offset_l_100		equ	#104		;=13(row)*8(column) left 100 degree
+                   338 ;c_offset_l_120		equ	#112		;=14(row)*8(column) left 120 degree
+                   339 ;;--------------------------------------以下为右转的开始偏移
+                   340 ;c_offset_r_20		equ	#144		;=18(row)*8(column) right 20 degree
+                   341 ;c_offset_r_40		equ	#152		;=19(row)*8(column) right 40 degree
+                   342 ;c_offset_r_60		equ	#160		;=20(row)*8(column) right 60 degree
+                   343 ;c_offset_r_80		equ	#168		;=21(row)*8(column) right 80 degree
+                   344 ;c_offset_r_100		equ	#176		;=22(row)*8(column) right 100 degree
+                   345 ;c_offset_r_120		equ	#184		;=23(row)*8(column) right 120 degree
+                   346 ;;;-------------------------------------以下为红外左右转表的开始偏移
+                   347 ;;//04-03-17// add for swerve when detceting the obstacles
+                   348 ;c_offset_l_20_ir	equ	#240		;=30(row)*8(column) left 20 degree
+                   349 ;c_offset_l_40_ir	equ	#248		;=31(row)*8(column) left 40 degree
+                   350 ;c_offset_l_60_ir	equ	#256		;=32(row)*8(column) left 60 degree
+                   351 ;c_offset_r_20_ir	equ	#312		;=39(row)*8(column) right 20 degree
+                   352 ;c_offset_r_40_ir	equ	#320		;=40(row)*8(column) right 40 degree
+                   353 ;c_offset_r_60_ir	equ	#328		;=41(row)*8(column) right 60 degree
+                   354 ;;end adding //04-03-17//
+                   355 
+                   356 ;c_rnd_range_1		equ	#1		;random number range is 1
+                   357 ;c_rnd_range_2		equ	#2		;random number range is 2
+                   358 ;c_rnd_range_3		equ	#3		;random number range is 3
+                   359 ;c_rnd_range_4		equ	#4		;random number range is 4
+                   360 ;c_rnd_range_5		equ	#5		;random number range is 5
+                   361 ;c_rnd_range_6		equ	#6		;random number range is 6
+                   362 ;c_rnd_range_8		equ	#8		;random number range is 8
+                   363 
+                   364 ;c_delay_short		equ	#120		;delay short constant
+                   365 
+                   366 ;;================================================================;
+                   367 ;IR Data Area
+                   368 ;================================================================;
+                   369 ;       .area       ir_judge_var(data)
+                   370 ;
+                   371 ;flg_ir_received::	.ds	1	;接收后的状态(0-7表示)(哪个地方有障外)the flag of received IR
+                   372 ;flg_l_or_r::		.ds	1	;the flag of turn left or turn right when detect obstacles in front or front-left-right of the mouse 
+                   373 ;;cnt_38k_pulse::	.ds	1	;IR transmitted pulse counter
+                   374 ;;cnt_ir_group::		.ds	1
+                   375 ;cnt_ir_rcv_f::		.ds	1
+                   376 ;cnt_ir_rcv_l::		.ds	1
+                   377 ;cnt_ir_rcv_r::		.ds	1
+                   378 ;;temp_delay_short::	.ds	1	;short delay variable
+                   379 
+                   380 ;================================================================;
+                   381 ;IR Code Area
+                   382 ;================================================================;
+                   383 ;       .area       ir_judge_code(code)
+                   384        
+                   385 ;*********************************************************************
+                   386 ; intput:flg_motor_status,flg_ir_judge(接收是否完成)
+                   387 ;	cnt_ir_rcv_f,cnt_ir_rcv_l,cnt_ir_rcv_r(中,左,右接收的红外个数)
+                   388 ;
+                   389 ; output:
+                   390 ;*********************************************************************
+                   391 ;ir_judge::
+                   392 ;
+                   393 ;if_judge_ir:
+                   394 ;	lda	flg_ir_judge		;if judge IR?(是否接收发射完成了?)
+                   395 ;	cmpe	#1
+                   396 ;	brnz	ir_judge_end
+                   397 ;
+                   398 ;	lda	#0
+                   399 ;	sta	flg_ir_judge
+                   400 ;judge_ir:
+                   401 ;	call	ir_received_judge	;接收判断子程序
+                   402 
+                   403 ;;************/*04-02-26*/***************;
+                   404 ;	lda	flg_ir_received
+                   405 ;	cmpe	#c_flg_f_rcved
+                   406 ;	brz	judge_ir_end
+                   407 ;	cmpe	#c_flg_f_l_r_rcved
+                   408 ;	brz	judge_ir_end
+                   409 ;
+                   410 ;	lda	flg_l_or_r
+                   411 ;	xora	#1
+                   412 ;	sta	flg_l_or_r
+                   413 ;;***************************************;
+                   414 ;judge_ir_end:
+                   415 ;;	lda	#0			;clear the flag and the counters
+                   416 ;;	sta	cnt_ir_group
+                   417 ;;	sta	cnt_ir_rcv_f
+                   418 ;;	sta	cnt_ir_rcv_l
+                   419 ;;	sta	cnt_ir_rcv_r
+                   420 ;ir_judge_end:
+                   421 ;	ret
+                   422 	

⌨️ 快捷键说明

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