nx_dis_c.nx
buildroot/runtime/nx_dis_c.nx
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
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
structs
| none |
consts
| none |
functions
| 40 | func nx_dis_c_reg_name(r: i64, out: *u8) -> i64 called by 1: nx_dis_c_emit_reg |
| 74 | func nx_dis_c_dec(buf: *u8, off: i64, v: i64) -> i64 called by 1: nx_dis_c_to_text |
| 100 | func nx_dis_c_mnemonic(buf: *u8, off: i64, m: *u8) -> i64 called by 1: nx_dis_c_to_text |
| 111 | func nx_dis_c_emit_reg(buf: *u8, off: i64, r: i64) -> i64 |
| 123 | func nx_dis_c_field(insn: i64, hi: i64, lo: i64) -> i64 called by 1: nx_dis_c_to_text |
| 128 | func nx_dis_c_reg3(r3: i64) -> i64 |
| 132 | func nx_dis_c_sext(value: i64, bits: i64) -> i64 called by 1: nx_dis_c_to_text |
| 143 | func nx_dis_c_to_text(insn: i64, buf: *u8) -> i64 called by 1: main calls 5: nx_dis_c_fieldnx_dis_c_sextnx_dis_c_mnemonicnx_dis_c_emit_regnx_dis_c_dec |
| 234 | func main() -> i64 calls 1: nx_dis_c_to_text |