stationeers.de Mod workshop · Dominik1199
DE Sign in
  1. Home
  2. IC10 academy
  3. Day 176

Day 176 of 365 · Advanced · Month 6: Atmosphere and control

Recap: network and memory

Looking back at months 4 and 5: batch instructions, device checks, stack and subroutines in one chip – and a list that shows you your gaps.

Lesson 20 min Week 26

What you learn today

  • Connect batch and device checks
  • Combine stack and subroutines
  • Spot gaps

The advanced exam is getting closer. This week connects what you learned separately over the past months. Today: network and memory.

Connecting batch and device checks

ToolWhat forTrap
lbn … Averagevalue of devices with the same nameNaN without a match
lbn … Maximumlargest value−infinity without a match
lb … Counthow many devices of the typeignores the name
lbnsa slot by namean empty slot returns 0
bdnvl, bdnvscan the device do this value?only with a pin or ReferenceId

Together they make a device check: Count says whether all devices are there, NaN says which name is missing.

Combining stack and subroutines

A subroutine measures a room whose name is in a register. lbn also takes the name from a register:

move name HASH("Raum1")
jal measure

If measure itself calls celsius, ra gets overwritten. So push ra at the start, pop ra before j ra. measure stores the readings as a table in the stack – but not at address 0:

add tmp i TABLE     # TABLE = 100
poke tmp val

Spotting gaps

Can you say without looking it up …

  • what lbn … Maximum returns without a match? (day 95)
  • why Count with lbn says nothing about the name? (day 94)
  • in which order put takes its values? (day 123)
  • why a nested subroutine needs push ra? (day 128)
  • when a relative jump tolerates a label? (never, day 106)

Wherever you hesitate, read that day again before the exam comes.

Warning

push, pop and poke share the same memory. If you put the table at address 0, the first poke overwrites exactly the place where push ra just put the return line. pop ra then fetches a reading, and j ra jumps into nowhere.

Tip

max with NaN gives NaN. Replace missing values with a clearly invalid value like −999 first – then the maximum stays usable.

Diagram

The stack with its pointer slot 0 10 slot 1 20 slot 2 30 slot 3 slot 4 sp = 3 next free slot push 40 pop r0 r0 = 30 last in, first out
push and pop work at the bottom end of the stack, the table sits further up from address 100. That way they do not get in each other's way.

Exercise

Task

Three gas sensors “Raum1”, “Raum2”, “Raum3”. The main loop calls measure three times. Add the subroutines and the evaluation.

  • measure: read the temperature of the room in name, convert to °C with celsius, store from stack address 100, count missing values, remember the warmest room
  • Display “Waermster” (°C, −999 if none), “Sensoren” (number of gas sensors), “Raum2” (value from the stack)
  • Flashing light “Raumfehler” on when fewer than 3 sensors are there or a room is missing

Hints

Hint 1

measure calls celsius – so push ra at the start and pop ra before j ra.

Hint 2

Table: add tmp i TABLE, poke tmp val, then add i i 1.

Hint 3

Missing values: snan, add to missing, replace with NONE for max.

Hint 4

Count devices with lb tmp SENSOR Temperature Count, room 2 with get tmp db ROOM2.

Quiz

4 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

Esc
↑ ↓ selectEnter open/ opens search anywhere