This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize
for the AI-speak, we are working on rewriting it!
The program’s map: every function and which calls which.
There’s no recorded run of this program yet.
Shift+Enter in a cell runs it and moves to the next. Running a cell runs every cell above it too, as one program.
[1]lines 1–35
# Assemble a program, load it into a fresh machine and run it: the three# steps every test of lib/rv32 and lib/cc takes.from rv32.asm import assemble, Program
from rv32.sim import INSTR_BYTES, Machine, machine, run
STEP_LIMIT:Int=10000000# instructions before a run is cut off#| The address of label `name` in an assembled program, or 0 when it has none.defentry(p: Program, name:Str) ->Int {
for k tolen(p.labels) {
if p.labels[k] == name {
return p.addrs[k]
}
}
return0
}
#| Assemble `text`, start at `_start` (or address 0) and run until the#| program exits or `limit` instructions have run.defrun_asm(text:Str, limit:Int) -> Machine {
p =assemble(text)
returnrun(machine(p.image, entry(p, "_start")), limit)
}
test"a program starts at _start and exits with a0" {
text ="j _start\nli a0, 1\n_start: li a0, 7\nli a7, 93\necall\n"assert_true(entry(assemble(text), "_start") ==2* INSTR_BYTES)
m =run_asm(text, STEP_LIMIT)
assert_true(m.halted)
assert_true(m.exit_code ==7)
}
# SPDX-License-Identifier: MIT OR Apache-2.0# SPDX-FileCopyrightText: 2026 The Viv authors