当前位置:网站首页>[Shenzhen IO] precise Food Scale (some understanding of assembly language)
[Shenzhen IO] precise Food Scale (some understanding of assembly language)
2022-07-01 07:09:00 【Messenger big tooth】
Steam game : Shenzhen IO
In the near future , Contact Shenzhen IO This game , In the main task of learning the deep learning network, the branch task of assembly language is started , I found it interesting to learn assembly language , But also quite exercise programming thinking .
As a little white who has never learned embedded system or assembly language , At present already “ play ” 了 38h, Here we go Accurate food scale this , Record some understanding .
Ironically , This “Shenzhen IO” The game cannot be played in the national service , You need to register an overseas account .
Precise food is called functional requirement

It is no different from the electronic scales we use everyday , This scale has “ Turn it on ”,“ To turn it off ”,“ Net weight ”( peel ) These three functions .
Code implementation

The idea of this design and implementation is very simple , The chip on the left is used to judge the current state of the electronic scale , Press down “ Button ” after , It should be turned on (dat Set up 1), Or turn it off (dat Set up 0), Or record the tare weight , And clear the current weight (dat Set up 3).
This design can really meet the requirements , But look at the results , The segment that belongs to the tail of the crane among global players .
The best way to see the product cost is ¥5, There's no doubt about it :
This electronic scale can use a MC6000 Realized !
Code optimization ideas
When learning advanced languages , Will often apply Combine several simple logic , Do complex functions The logic of , in other words , Sometimes code , Fine “ Without brains ”, As long as the conditions , Simply and crudely knock it all out .
But that's how it works , In compiling this “ low-level ” Language , It often doesn't work , Mainly because : The chip limits the number of lines of code , And the ability of assembly language in nested logic , Higher level languages are really hard to use .
At least in Shenzhen IO This game is like this , Involving nested logic , It's really a headache , And high-level languages directly write more layers if That's it
So when using assembly , It has to be “ With brain ”, Before you write a program, think about how the code can be streamlined and smart . And the most important method that I summarize personally is : Conduct Conditional merger , Find the key conditions .
Code optimization methods
Signal Planning
If only one piece is used MC6000 chip , That can be operated acc Must be used for net weight ,dat Used to record tare ( Input as gross weight )
Condition sorting
The core focus of this design task & The difficulty lies in how to distinguish “ Turn it on ”,“ To turn it off ”,“ Zeroing ( peel )” These three functions .
① Startup conditions
- Button =100
- weight ( Gross weight )=0
- tare =999( The state before power on must be turned off , The shutdown status is defined as net weight =-999)
② Shutdown conditions
- Button =100
- weight ( Gross weight )=0
- tare =0
③ Set zero condition
- Button =100
- weight ( Gross weight )>0
- tare =0( The tare weight is still 0, In the next state , The tare weight will be equal to the gross weight at this time )
Now let's start sorting and merging , First , The three functions can be combined into two , Starting and zeroing are essentially a state ( Boot tare is 0)
Next , As long as from the above conditions , find The simplest sufficient condition to distinguish between shutdown and zero setting states That's it .
That's it :
① Set zero condition
- weight ≠ tare
② Shutdown conditions
- weight = tare
Find this condition , You can build a new design .
Design optimization

Running results ,world best design!
边栏推荐
- Is it safe to buy funds on Alipay? Where can I buy funds
- [network planning] (I) hub, bridge, switch, router and other concepts
- Jena default inference query based on OWL
- [Electrical dielectric number] electrical dielectric number and calculation considering HVDC and facts components
- 8 figures | analyze Eureka's first synchronization registry
- 运维管理系统,人性化操作体验
- [lingo] solve quadratic programming
- 运维管理有什么实用的技巧吗
- 在券商账户上买基金安全吗
- 转行做产品经理,如何挑选产品经理课程?
猜你喜欢
![C language implementation [minesweeping game] full version (implementation source code)](/img/70/60f9a61bd99fa5fb5fab679a32528e.png)
C language implementation [minesweeping game] full version (implementation source code)

北漂程序员深夜emo发帖求助:女朋友走了我很孤独 ......

【FPGA帧差】基于VmodCAM摄像头的帧差法目标跟踪FPGA实现

关于图灵测试和中文屋Chinese room的理解
![[Electrical dielectric number] electrical dielectric number and calculation considering HVDC and facts components](/img/7c/2b1d4797f367cced51f36e8a1bb199.png)
[Electrical dielectric number] electrical dielectric number and calculation considering HVDC and facts components

How to draw a product architecture diagram?

Jena default inference query based on OWL

解决无法读取META-INF.services里面定义的类

iNFTnews | 从《雪崩》到百度“希壤”,元宇宙30年的16件大事

Figure out the difference between event coordinates screenx, clientx, pagex and offsetx
随机推荐
Alibaba OSS postman invalid according to policy: policy condition failed: ["starts with", "key", "test/"]
Unity2021-Scene视图中物体无法直接选中的解决办法
Which securities company is better or safer for mobile phone account opening
Problem solving: officeexception: failed to start and connect (I)
Jena基于OWL的默认推理查询
Esp32 - ULP coprocessor reading Hall sensor in low power mode
How the esp32 deep sleep current is lower than 10uA
iNFTnews | 从《雪崩》到百度“希壤”,元宇宙30年的16件大事
The game is real! China software cup releases a new industrial innovation competition, and schools and enterprises can participate in it jointly
Is it safe to buy funds on Alipay? Where can I buy funds
热烈祝贺五行和合酒成功挂牌
AI视频智能平台EasyCVR设备录像出现无法播放现象的问题修复
Système de gestion de l'exploitation et de l'entretien, expérience d'exploitation humanisée
北漂程序员深夜emo发帖求助:女朋友走了我很孤独 ......
How to choose a product manager course when changing to a product manager?
ctfshow-web351(SSRF)
比赛即实战!中国软件杯发布全新产业创新赛项,校企可联合参赛
Using fuseki query when there are multiple models in TDB
Docker installation and deployment redis
【剑指offer&牛客101】中那些高频笔试,面试题——链表篇