code wiki / (root) / nx_emu_riscv32.nx

nx_emu_riscv32.nx

buildroot/runtime/nx_emu_riscv32.nx

4861 B110 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind orphan librarytopic emu
docsdependenciesstructsconstsfunctions

about

nx_emu_riscv32.nx -- sovereign RV32IM interpreter (NX-EMU, 32-bit XLEN). Sibling of nx_emu_rv64 for the 32-bit RISC-V target; nxc2's rv32 backend represents i64 as register PAIRS, so the KAT exercises add/sub/mul/mulhu/sltu (carry) over 32-bit lanes. Flat little-endian guest RAM, Linux rv32 syscalls (exit=93, a7=num, a0..=args). NO qemu -- decode/execute per the RISC-V ISA. license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_syscalls_x86_64.nx nx_emu_riscv32.nx

imports: nx_syscalls_x86_64.nx

imported by: nobody (leaf or entry point)

structs

none

consts

9const R32_GUEST: i64 = 16777216
10const R32_MASK: i64 = 0xFFFFFFFF
11const R32_SYS_EXIT: i64 = 93

functions

13func r32_ld(mem: *u8, va: i64, width: i64) -> i64
called by 1: emu_riscv32_run_mem
19func r32_st(mem: *u8, va: i64, width: i64, val: i64) -> i64
called by 1: emu_riscv32_run_mem
24func r32_sx(v: i64, bits: i64) -> i64 { let m: i64 = 1 << (bits - 1); if (v & m) != 0 { return v - (1 << bits) } return v }
called by 1: emu_riscv32_run_mem
26func emu_riscv32_run_mem(mem: *u8, mem_size: i64, entry: i64, sp0: i64) -> i64
called by 1: emu_riscv32_run calls 3: r32_ldr32_sxr32_st
105func emu_riscv32_run(code: *u8, code_len: i64) -> i64