Some errors the chip reports right away with an error code. The nasty ones report nothing at all: the program runs but does not do what it should. Here are the classics, sorted by nastiness.
The silent errors
Program runs past the last line
Symptom: The chip worked once and has done nothing since. No error light.
Cause: When the chip reaches the end of the program, it stays there. It does not start again from the top on its own. Only taking the chip out and putting it back in resets it.
Fix: Every main loop ends with a jump back, for example j start.
NaN because no device matches
Symptom: A control loop never switches, even though the value is clearly over the limit.
Cause: lbn with batch mode 0 (Average) returns NaN if no device with that type and name is on the data network. One wrong letter, one space too many, upper case instead of lower case, wrong prefab hash, and there you are. Every comparison with NaN is false, so neither blt nor bgt jumps.
Fix: Check after every read:
lbn tRaum SENSOR HASH("Raum") Temperature 0
bnan tRaum start
To count, there is batch mode 4 (Count). It returns the number of matching devices:
lbn anzahl SENSOR HASH("Raum") Temperature 4
If it returns 0, the name or the type is wrong.
Without a match, batch mode 3 (Maximum) does not return NaN but negative infinity. Minimum and Sum return 0. That looks harmless as well, and it is not.
Sum instead of Average
Symptom: Everything worked until someone built a second sensor with the same name. Since then the room reads 600 K.
Cause: Batch mode 1 (Sum) adds up. With one device you do not notice, with two the value doubles.
Fix: For measurements always 0 (Average).
Exact comparison with decimals
Symptom: beq tRaum 293.15 ziel never jumps.
Cause: Measurements and calculation results practically never land exactly on a number. 293.1500001 is not 293.15.
Fix: Work with limits (blt, bgt) or compare with a tolerance (bap, sap):
bap tRaum 293.15 0.01 ziel
Relative jump with a label
Symptom: The program jumps somewhere.
Cause: Commands with r in the name (jr, breq, brlt …) jump relatively, that is, by a number of lines. A label after them is taken as a number and added to the current line. No error, just chaos.
Fix: With labels, only use j, jal and the b… commands without r.
Line numbers as jump targets
Symptom: After inserting a comment line, everything is broken.
Cause: j 12 jumps to line 12. Every inserted line, even an empty one or a comment, shifts everything below it.
Fix: Labels.
No yield
Symptom: None, or strangely twitchy behaviour.
Cause: Without yield the chip executes 128 instructions per tick and carries on in the middle of the loop in the next tick. It keeps reading the same not-yet-updated values.
Fix: yield at the start of the main loop.
Umlauts in HASH
Symptom: HASH("Küche") does not find the device "Küche" (kitchen).
Cause: The chip only stores plain characters. When the code is written to the chip, the umlaut turns into something else, and the hash no longer matches the name on the device.
Fix: Name devices without umlauts: "Kueche".
LED display shows 294 °C
Cause: In Celsius mode the LED display only appends "°C" to the value, it does not convert.
Fix: Subtract 273.15 before writing.
sleep waits far too long
Cause: sleep counts in seconds, not ticks. sleep 10 is 10 seconds, so 20 ticks.
The loud errors
Unknown command
Commands are exact and lowercase. L r0 d0 Setting is wrong, l r0 d0 Setting is right. Common mix-ups from other languages:
| Wrong | Right |
|---|---|
mov | move |
jmp | j |
call, ret | jal and j ra |
inc r0 | add r0 r0 1 |
log10 | does not exist; log is the natural logarithm |
nop | does not exist |
Number with an exponent
1e5 is not a number to the chip. Write it out: 100000.
LogicType at a number position
Where a LogicType is expected, the name is enough: l r0 d0 Temperature. Everywhere else it needs the prefix: move r0 LogicType.Temperature.
Device cannot handle the value
Not every device knows every LogicType, and by no means every value can be written. If the chip reads or writes something the device cannot handle, it halts. The Stationpedia in game shows which values a device has.
Register outside r0 to r15
r16 is sp, r17 is ra. Use them as normal registers and you wreck your stack and subroutines. There is nothing beyond r17.
No data cable on the housing
lbn, sbn and the like run over the data network. If the IC housing is not connected to a data cable, the chip halts with an error.
Duplicate names
The same define twice or the same label twice gives an error.
put with swapped values
The order is put device address value. Swap address and value and you write to the wrong place.
Program too long
| Limit | Value |
|---|---|
| Lines | 128 |
| Characters per line | 90 |
| Characters in total | 4096 |
Everything counts, comments and blank lines included. With lots of comments, the character limit usually breaks first.
The error codes
When the chip aborts with an error, it comes with an error code. The most important ones:
| Code | Name | Meaning |
|---|---|---|
| 2 | IncorrectVariable | operand is wrong at this position |
| 3 | IncorrectVariableType | wrong type, for example a register instead of a device |
| 4 | IncorrectLogicType | unknown or unsuitable LogicType |
| 6 | IncorrectArgumentCount | too many or too few operands |
| 7 | DeviceNotSet | no device on the pin |
| 8 | JumpTagDuplicate | duplicate label |
| 9 | UnrecognisedInstruction | unknown command (typo, upper case) |
| 11 | OutOfRegisterBounds | register out of range |
| 12 | OutOfDeviceBounds | pin outside d0–d5 |
| 17 | StackOverFlow | stack full |
| 18 | StackUnderFlow | pop on an empty stack |
| 19 | ExtraDefine | name already taken |
| 20 | DeviceListNull | no data network on the housing |
| 25 | DeviceNotFound | no device found with this ReferenceId |
| 38 | AliasNotFound | unknown alias name |
Finding errors faster
- Make values visible: write intermediate results to an LED display (
sbnwithSetting) or into the housing withs db Setting r0. - Start small: first only read and display, then switch.
- Count with Count whether the devices are found at all.
- Test in the tablet: the IC10 Editor Tablet shows errors and warnings as you type, knows the silent traps from above and has a simulator with the game's real interpreter.