What you learn today
- Repeat all instructions of the level
- Go through the traps once more
- Practice questions
The beginner exam is the day after tomorrow. Today you go through everything you need for it once more. Write down where you are unsure and look up the matching lesson.
The instructions of the level
| Family | Instructions |
|---|---|
| math | move add sub mul div mod abs min max sgn lerp |
| rounding | round trunc floor ceil |
| comparing | slt sgt sle sge seq sne and the z forms, select |
| logic | and or xor nor |
| NaN | snan snanz bnan |
| jumps | j beq bne blt bgt ble bge, z forms such as beqz |
| flow | yield sleep |
| devices | l s lb sb lbn sbn ls lbs |
| order | define alias HASH("…") |
The traps
- Program end: if the chip runs past the last line, it stops for good. Every control needs
j start. - No yield: the chip runs 128 instructions and continues in the middle of the loop during the next tick. No error, but all values are the same 128 times.
- sleep on line 0: never put it at the very beginning.
- Numbers: dot instead of comma, no
1e5.$FFand%1010are allowed. - define with define:
define B Agives NaN, without an error message. - Batch modes:
Averagereturns NaN when no device matches,Sumadds up sensors with the same name. For readings always useAverage. - Names: with
lbntype and name must match. Device names ASCII only. - Bare LogicTypes:
move r0 Temperatureis an error, at number positions it isLogicType.Temperature.
How the exam works
The exam on day 91 draws 20 questions from a larger pool, you have 40 minutes and need 70 %. You do not have to write code, but you do have to read it. Work along line by line, as in lesson 85.
move r0 7
div r0 r0 2 # r0 = 3.5
floor r1 r0 # r1 = 3
sgt r2 r0 3 # r2 = 1
select r3 r2 10 20 # r3 = 10
Always work out Kelvin tasks via the difference: 20 °C is 293.15 K because 0 °C is 273.15 K. An error of 273 stands out at once if you expect it.
With round and numbers ending exactly in .5, do not rely on your expectation. Exam questions avoid this case, and your own scripts should too.
Exercise
Task
A warm-up calculation, without devices. r0 holds a temperature in Kelvin, r1 a pressure in kPa. Work out:
r2= temperature in °Cr3= 1 if the temperature is between 18 and 25 °C (limits included), otherwise 0r4= 1 if the pressure is below 90 or above 110 kPa or is NaN, otherwise 0r5= pressure limited to the range 0 to 100r6=Color.Redifr4= 1, otherwiseColor.Green
The program may stop at the end.
Hints
Hint 1
Band with sge and sle, combined with and.
Hint 2
Pressure warning: slt, sgt, or, then also snan and one more or.
Hint 3
Limit with max … 0 and min … 100, colour with select colour warn Color.Red Color.Green.
Quiz
5 questions. You pass from 60 % – the server does the grading.
Complete the day
- Passed the simulator exercise
- Passed the quiz with at least 60 %
Without an account progress is saved in this browser only.
Report a mistake in this lesson
Please sign in to report. Sign in