Search the wiki

Loading guides…↑ ↓ to navigate · Esc to close

IT THINKS Build Your Own GPU CPU Assembly Guide

Start with a short NIB program on the CPU bench and step it while watching PC, R0–R3, and RAM. On a freshly reset core, run SET 7, ADD R1, R0 twice, then HALT. The expected final register values are R0 = 7 and R1 = 14.

SET 7
ADD R1, R0
ADD R1, R0
HALT

Use SET and check the destination register

SET takes a value from 0 to 15 and writes it to R0. ADD, SUB, and MUL take a destination and a source register, in that order. Each updates the destination with a four-bit result. Step through the smoke test and look at R1 after each ADD to see where execution first differs from what you expect.

Read and write RAM

LOAD Rd, [Rs] reads the memory cell addressed by Rs into Rd. STORE Rd, [Rs] writes the value in Rd to that address. When debugging either instruction, inspect the address register as well as the data register. Compare the affected RAM cell with the one specified by the contract.

Follow branches and stop execution

JMP n branches to a program address. BZ n takes the branch when R0 is zero, so look at R0 just before stepping that instruction. The inspected assembler has 16 instruction slots and accepts labels for branch targets. HALT stops execution.

Adapt the test to your contract

The smoke test checks a small arithmetic sequence on a reset core. For delivery, check the expected register, output, or RAM cell in the actual brief. The CPU build and its test determine whether the complete contract passes. For parallel programs, TID Rd exposes the thread ID and lets you see which thread is running.

Sources