What you learn today
- Read and write another chip's stack
- Clear memory
- clrd with an ID
A chip has 512 slots in its stack. If it needs more, or if two chips should share a big table, it reads and writes the stack of another chip.
get and put with another device
Instead of db you put in the other device: a pin, a register with a ReferenceId or a define with the number.
get value d0 5 # read address 5 in the chip on d0
put d0 5 value # write address 5 in the chip on d0
get value id 5 # the same via a ReferenceId
With an IC housing you end up in the stack of the chip sitting inside it. The order with put is always device, address, value.
Which devices have memory
According to the game data only certain devices have memory:
| Device | slots | read | write |
|---|---|---|---|
| IC housing (chip inside) | 512 | yes | yes |
| Logic Sorter | 32 | yes | yes |
| Autolathe and other fabricators | 64 | yes | yes |
| Satellite dish (medium) | 32 | yes | yes |
| Suit storage | 24 | yes | no |
| Occupancy sensor | 18 | yes | no |
The logic memory has no stack, only its Setting. If you write into a memory that is read-only, the chip reports MemoryNotWriteable.
Clearing memory: clr and clrd
clr d0 # set the whole stack of the device on d0 to 0
clrd id # the same via a ReferenceId
clr takes a pin, clrd a ReferenceId. Both set all slots to 0. They do not change the other chip's sp.
Someone else's memory belongs to the other chip. If you write into addresses it uses itself, you destroy its data. Agree on which addresses belong to whom, like with the mailboxes from day 115. And clr clears everything without asking.
Check the device with bdns beforehand. If it is missing, get stops with an error.
Diagram
Exercise
Task
A second IC housing sits on d0. Your chip keeps a counter in its stack.
- Every tick: read address 0 of the neighbouring chip, add 1, write it back. The value sits in
r0. - A press on the button “Loeschen” (edge) clears the whole memory of the neighbouring chip with
clrdvia its ReferenceId and setsr0to 0. - If the neighbouring chip is missing, nothing happens – without an error.
Hints
Hint 1
First bdns store start – without the neighbouring chip back to the yield.
Hint 2
Counter: get, add, put store ADDRESS count.
Hint 3
Clearing: check the edge, then l id store ReferenceId and clrd id.
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