Skip to content

How the processor works

The program runs top to bottom and starts over. Lines count from zero, speed is measured in instructions per tick

easy

A processor is not started and not stopped: as long as it stands there with a program in it, it runs that program. Instructions go top to bottom, one after another; when it reaches the last one it starts again. Almost everything written in mlog works this way: it is not a script that runs once and ends, but an endless loop.

tick 0
Set0
=
Operation1
=
@counter0number
speednullnull
loopsnullnull

Press “step”: the frame walks through both lines and returns to the top, and loops goes up by one each time.

The first instruction is number zero, the second is number one. You see it everywhere: in the numbers to the left of the blocks, in jumps, in @counter.

Time in the game goes in ticks — sixty a second. In one tick a processor runs not one instruction but as many as its kind is allowed:

Processor Instructions per tick
micro processor 2
logic processor 8
hyper processor 25

That number lives in @ipt — the first line of the example puts it into a variable. A simple consequence follows: a twenty-instruction program on a micro processor takes ten ticks per iteration, that is six times a second, and on a hyper processor seventy-five times.

The same program therefore behaves differently on different processors: one watching a store simply reacts more slowly, while one drawing on a display starts to flicker.

The “step” button in the examples runs one instruction, not one tick: a tick is too coarse to see the program move, especially on a hyper.

The variables window has @counter — the number of the instruction the processor will run next. For now it is enough to know it is there: it shows where the program currently is.

The counter does not only show — you can write to it, and writing to it is a jump. Jumps are normally written with the jump instruction, and the counter as a variable gets its own lesson: @counter: a jump as a value”.

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.