当前位置:网站首页>[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!
边栏推荐
猜你喜欢

未来互联网人才还稀缺吗?哪些技术方向热门?

C# Newtonsoft.Json中JObject的使用

AI视频智能平台EasyCVR设备录像出现无法播放现象的问题修复

C语言实现【扫雷游戏】完整版(实现源码)

Using fuseki query when there are multiple models in TDB

Open source! Wenxin large model Ernie tiny lightweight technology, accurate and fast, full effect

Understand esp32 sleep mode and its power consumption

Illusory and simple screen raindrop post-processing effect

【推荐技术】基于协同过滤的网络信息推荐技术matlab仿真
![[FPGA frame difference] FPGA implementation of frame difference target tracking based on vmodcam camera](/img/0f/045957961725716435439316078347.png)
[FPGA frame difference] FPGA implementation of frame difference target tracking based on vmodcam camera
随机推荐
熱烈祝賀五行和合酒成功掛牌
Summary of the concept and advantages of 5g massive MIMO
How to permanently configure local opencv4.5.5 for vs2019
Insufficient free space after clearing expired cache entries - consider increasing the maximum cache space
图像风格迁移 CycleGAN原理
Paging in servlets and JSPS
JSP - 分页
为什么这么多人转行产品经理?产品经理发展前景如何?
【推荐技术】基于协同过滤的网络信息推荐技术matlab仿真
Automated test platform (13): interface automation framework and platform comparison, application scenario analysis and design ideas sharing
Rclone Chinese document: a collection of common commands
運維管理系統,人性化操作體驗
[classification model] Q-type cluster analysis
Is the account opening of GF Securities safe and reliable? How to open GF Securities Account
C# Newtonsoft.Json中JObject的使用
【MATLAB】求解非线性规划
Problem: officeexception: failed to start and connect (III)
[image processing] image histogram equalization system with GUI interface
Jena default inference query based on OWL
TDB中多个model情况下使用fuseki查询