Today has no practice yet.0/30 daily XP0 Sparks0 XP

Crossover mission · Silicon Lab × Robot Lab

Your CPU drives the robot

The 8-bit CPU you built in Silicon Lab can run a robot. Its RAM address 15 is wired to a distance sensor: every instruction, the sensor writes the distance to the wall there, in tenths of a metre (0–15).

Whatever the program sends to OUT sets the motor speed: 0 stops the base, and each step above 0 adds 0.05 m/s. Each instruction takes 10 ms of simulated time.

The starter program drives forward forever. Change it so the base stops between 0.2 m and 0.5 m from the wall. That is the sense → think → act loop, written in your own instruction set.

Simplified: the base starts and stops instantly and the sensor has no noise.

Best after Silicon Lab Level 6, Robot Lab Level 2.

Instructions you will need
LDI n
Load the four-bit operand into A.
LDA n
Load A from the RAM address.
SUBI n
Subtract the operand from A.
JZ n
Jump to a program address if Z is set.
JMP n
Jump to a program address.
OUT
Append A to the output port.
HLT
Halt execution.
time (s)distance (m)