learn by doing

Guided labs

Small programs with a goal the machine checks for you — from the first OUT to hunting the one wrong instruction. Write, run, and get plain-word feedback until the check goes green; the narrator, the spec, and the playground have already taught you the pieces.

objective

in: — → expected: [42]

The program starts with every register at 0. One value must travel out on the I/O channel: 42.

Two instructions to complete: MOV R1, value loads a constant into R1; OUT R1 sends it out.

ready

hints

  • stuck? the hint button reveals the reasoning one step at a time.

Predict the result

Five tiny programs with one question each. Type your prediction, then watch the machine — and the narrator — prove you right or wrong. The wraps, the jumps, and the loops behave exactly like the spec says.

Add three registers

predict, then run
    MOV  R1, 4
    MOV  R2, 5
    ADD  R1, R2
    HALT

What lands in R1?

One past the edge

predict, then run
    MOV  R1, 364
    ADD  R1, 1
    HALT

What lands in R1 after the wrap?

Does it overflow?

predict, then run
    MOV  R1, 364
    MUL  R1, R1
    HALT

Does OVF get set?

The taken jump

predict, then run
    CMP  R0, R0
    JEQ  SKIP
    MOV  R1, 5
    HALT
SKIP:
    MOV  R1, 7
    HALT

What lands in R1?

Countdown output

predict, then run
    MOV  R1, 3
TOP:
    OUT  R1
    SUB  R1, 1
    CMP  R1, 0
    JGT  TOP
    HALT

What is the second value sent out?

Random add

predict, then run
    MOV  R1, 11
    MOV  R2, 17
    ADD  R1, R2
    HALT

What lands in R1?

Random divide by 7

predict, then run
    MOV  R1, 22
    MOV  R2, 7
    DIV  R1, R2
    HALT

What lands in R1 after the division?

Random shift left

predict, then run
    MOV  R2, 24
    SHL  R1, R2
    HALT

What lands in R1 after the shift?