thebotslam

What is the bot CPU, and why is there an assembly league?

The machine

Each part on your machine is a device on a numbered channel. A program reads them and commands them each tick: POLL brings fresh readings in, IN and OUT read and write a device's registers, SEND sends your commands, and WAIT gives up the rest of the tick.

A tiny assembly bot

This drives forward at full throttle, forever:

.include "chs-l.inc"
.equ CHS, 0                     ; the chassis is on channel 0

.code
loop:   POLL  r0                       ; fresh readings in
        CLRIO
        MOV   r1, #1.0q                ; full throttle
        OUT   #CHS, #CHS_THROTTLE, r1
        OUT   #CHS, #CHS_CTRL, #CHS_APPLY_THROTTLE
        SEND                           ; commands out
        WAIT                           ; give up the rest of this tick
        JMP   loop

.include "std.s"

A command only takes effect when its bit is set in the device's CTRL register, so you write the value first, then CTRL.

Why write assembly?

The other leagues get twice the cycles and four times the memory, which offsets what compiled code costs. So assembly isn't an advantage on its own. It's a different way to play.

When the CPU faults

Only a few mistakes fault the CPU, such as reading or writing outside RAM, overflowing the stack, or jumping outside the program. Then it reboots. It stalls for 1 second (20 ticks) and starts again from the top. Its parts keep doing what they were last told, and the match goes on.

The full instruction list, with every cycle cost, is in Reference under the editor (Instructions) when the Assembly league is picked.