Skip to main content

prelude

Function prelude 

Source
pub fn prelude() -> String
Expand description

Assembler .equ lines naming every device address and register offset.

Prepend this to a guest program so it refers to devices by name instead of by a literal address. The text is generated from the constants in this crate, so a device that moves does not leave a stale number behind in the programs that use it.

let source = format!("{}\n    addi r1, r0, CONSOLE_BASE\n", prelude());
assert!(source.contains(&CONSOLE_BASE.to_string()));