Skip to content

Jump

Until a program has a jump in it, it runs top to bottom and, on reaching the end, starts from the top again — doing the same thing whatever the circumstances. jump is the instruction that changes that: one check, and execution goes off to the side. Writing to @counter does the same job, but that is used rarely and deliberately.

The line is built like this: where to jump, which condition and what to compare with what. If the condition holds, the next line to run is the one the arrow points at; if not, the ordinary next one.

Everything else is assembled from that:

  • a branch — a jump forward, over a piece of the program;
  • a loop — a jump backwards, to a line that has already run.

To the processor there is no difference between them: in both cases the number of the next line simply changes. That is why there are only three lessons.

  1. Condition and branchingOne check — two roads. How a program stops being a straight line
  2. LoopsThe same jump, only the arrow points up — and the program starts repeating a piece of itself
  3. Nested conditions and early exitA jump has one condition and one target. Everything else — «and», «or», else, leaving a loop — is assembled out of several jumps

«How the processor works» — that a program runs in an endless loop, and what @counter is. The comparisons are the same as op’s, so «Comparisons and logic» will come in handy, though it is not required.

Unofficial fan project, not affiliated with Anuke. Mindustry sprites, fonts and translations © Anuke, used under GPL-3.0; Fira Code under OFL-1.1. Site code is GPL-3.0.