We are currently experiencing issues with email delivery; this is being resolved as quickly as possible.

stationeers.de Mod workshop · Dominik1199
DE Sign in
  1. Home
  2. IC10 academy
  3. Labels and jumps

Chapter 3 · Decisions & style

Labels and jumps

With j, beq, bgt & co. the chip makes decisions.

Lesson 7 of 18 9 min

IC10 has no if and no loop instructions. Everything works through jumps to labels.

Labels

A label is a name with a colon, alone on its line:

hot:

It does nothing by itself, but marks the line as a jump target. If something follows it (hot: s d1 On 1), the chip does not understand the line.

Unconditional jump: j

j start always jumps. That is how you build the main loop.

Conditional jumps

Instructionjumps if
beq a b targeta = b
bne a b targeta ≠ b
bgt a b targeta > b
bge a b targeta ≥ b
blt a b targeta < b
ble a b targeta ≤ b
beqz a target / bnez a targeta = 0 / a ≠ 0

If the condition is false, the chip simply continues with the next line.

start:
yield
l r0 d0 Temperature
bgt r0 303.15 hot   # warmer than 30 C?
s d1 On 0           # no: light off
j start
hot:
s d1 On 1           # yes: light on
j start
Warning

Instructions starting with br (breq, brgt …) and jr jump relatively by a number of lines. A label is almost always wrong there, because its line number simply gets added. For labels always use the variants without r.

Tip

Never jump to line numbers like j 5. Insert a line above and the jump lands somewhere else. Labels move along.

Diagram

Flow with a conditional jump start: yield · l r0 r0 > 303.15? hot: On 1 On 0 yes: bgt jumps no: next line j start
A conditional jump splits the flow: if the condition is true, execution continues at the label, otherwise on the next line.

Exercise

Task

A warning light on d1 should be on when the sensor on d0 reads more than 30 °C (303.15 K) – otherwise off. Solve it with a conditional jump (bgt, blt …) inside an endless loop.

Hints

Hint 1

bgt r0 303.15 hot jumps to the label hot: when it is warmer.

Hint 2

Do not forget the j start after each branch – otherwise the chip falls through into the other branch.

Esc
↑ ↓ selectEnter open/ opens search anywhere