[shenzhen io]simplest and cheapest electronics engineering training just in the game

Look

Before solve the following electronics engineering problem, here have some point you should know

  1. only have few components could be given. For example, the game only have two type micro-controller MC4000 and MC6000 ,both of them had limit the assembly code size,which the forth only allow 9 rows and 16 characters a column for you to coding assembly language, another only allow 14 rows and column’s size is same as forth.
  2. only have Simple io and XBUS as micro-controller’s interfaces. MC4000 have p0 and p1 as it’s simple io,MC6000 same. simple io values are continous signal levels from 0 to 100. MC4000 have x0 , x1 as it’s xbus, while MC600 have x0,x1,x2,x3 as it’s xbus. Xbus values are discrete data packets from -999 to 999.
Here have a simple usage of MC4000.

在这里插入图片描述

Assembly Language in the game

#move instruction
	mov 100 p1      #take 100 to p1 that means port register 
	
#null instruction	
	nop             #no effect
	
#arithmetic instructions
	add 3           #add 3 to acc that means accumulator register
	sub 4           #sub 4 by acc
	mul 1  			#mul 1 by acc 
	not             #if the value in acc is 0,store a value of 100 in acc.
					   otherwise,store a value of 0 in acc.
#sleep instructions			   
	slp 6           #sleep for 6 time units 
	slx x0          #sleep until data is available to be read on the x0

#test instructions
	teq x0 1        #query whether x0 is equal to 1
	                     if x0 is equal to 1,enable + instruction.
	                     Otherwise,enable - instruction.
	tgt p1 p0       #query whether p1 is greater than p0
	                     ....
	tlt p1 p0       #query whether p1 is less than p0
	                     ....
	tcp x0,p1       #compare x0 and p1 and comes three results.
					     if x0 is greater than p1,enabled + instruction.
					     if x0 is equal to p1,enabled neither + or - instruction.
					     if x0 is less than p1,enable - instruction,
	
#decimal bit operation instructions
	dgt 2           #store the number in position 3.if the value in acc is 734,
	                   store 7 to acc.
	dst  0 9        #store a changed number.if the value in acc is 123, 
	                   store 129 to acc.


	

a infrared alarm

The following picture is the question details.

在这里插入图片描述

在这里插入图片描述

So, we have this messages:

  1. current time,maybe a number.
  2. a start time and a end time,could used as constant.
  3. a sensor input and a alarm output.
  4. the alarm should actived in a time period and meanwhile sensor input the number that larger than 19.

   \;
   \;
   \;
   \;

Here is the solution below.

在这里插入图片描述

  slx x0 
  teq x0 1
+ tgt p0 19
+ mov 100 p1
- mov 0 p1
off:
  teq p1 x2
+ jmp on
  mov 0 x1
  slp 1
  jmp off
on:
  teq p1 x3
+ jmp off
  mov 1 x1
  slp 1
  jmp on

module in assembly code

label_A:
	query whether something happened
	if something commit then jump to label_B
	otherwise run the following code
	...
	...
	at the end of the module,jump back to label_A with out query 
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

念心科道尊

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值