code wiki / (root) / nx_dis_c.nx

nx_dis_c.nx

buildroot/runtime/nx_dis_c.nx

9626 B259 linesdepth 4pulls 4 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_dis_c.nx -- RV64C compressed-instruction disassembler. Companion to nx_dis.nx (RV64I disassembler). When walking an instruction stream, callers should: if (low2 & 3) != 3: insn16 = read_u16(pc); pc += 2 nx_dis_c_print(insn16, pc, fd) OR nx_dis_c_to_text(insn16, buf) else: insn32 = read_u32(pc); pc += 4 nx_dis_print(insn32, pc, fd) (existing path) Reuse strategy: c.* instructions all expand to a 32-bit RV64I/M equivalent via nx_rv64c_decode. We could expand and pretty-print the EXPANSION, but readers tracing crashed binaries want to see "c.addi a0, 5" not "addi a0, a0, 5" -- the compressed form is shorter and matches what objdump prints. So this module emits the canonical compressed mnemonic. 26 mnemonics covered: Q0: c.addi4spn / c.lw / c.ld / c.sw / c.sd Q1: c.nop / c.addi / c.addiw / c.li / c.addi16sp / c.lui / c.srli / c.srai / c.andi / c.sub / c.xor / c.or / c.and / c.subw / c.addw / c.j / c.beqz / c.bnez Q2: c.slli / c.lwsp / c.ldsp / c.jr / c.mv / c.ebreak / c.jalr / c.add / c.swsp / c.sdsp

dependencies 2 imports · 0 importers

syscalls.nx nx_rv64c.nx nx_dis_c.nx

imports: syscalls.nxnx_rv64c.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main nx_dis_c_to_text nx_dis_c_field nx_dis_c_sext nx_dis_c_mnemonic nx_dis_c_emit_reg nx_dis_c_reg_name nx_dis_c_dec

structs

none

consts

none

functions

40func nx_dis_c_reg_name(r: i64, out: *u8) -> i64
called by 1: nx_dis_c_emit_reg
74func nx_dis_c_dec(buf: *u8, off: i64, v: i64) -> i64
called by 1: nx_dis_c_to_text
100func nx_dis_c_mnemonic(buf: *u8, off: i64, m: *u8) -> i64
called by 1: nx_dis_c_to_text
111func nx_dis_c_emit_reg(buf: *u8, off: i64, r: i64) -> i64
called by 1: nx_dis_c_to_text calls 1: nx_dis_c_reg_name
123func nx_dis_c_field(insn: i64, hi: i64, lo: i64) -> i64
called by 1: nx_dis_c_to_text
128func nx_dis_c_reg3(r3: i64) -> i64
132func nx_dis_c_sext(value: i64, bits: i64) -> i64
called by 1: nx_dis_c_to_text
143func nx_dis_c_to_text(insn: i64, buf: *u8) -> i64
234func main() -> i64