code wiki / (root) / nx_dis.nx

nx_dis.nx

buildroot/runtime/nx_dis.nx

16786 B480 linesdepth 3pulls 3 transitivereach 7 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_dis.nx -- RV64I disassembler (machine bytes -> mnemonic). Inverse of nxasm: takes 4-byte RV64 instructions and prints the canonical mnemonic + operand list. Foundation for sovereign `objdump -d` (the disassembly view), the future nx_dbg.nx stepping debugger, and Wheeler-DDC byte-level audit. Coverage (v0.0.1 -- the instruction set our codegen actually emits): R-type: add, sub, and, or, xor, sll, srl, sra, slt, sltu mul, mulh, div, divu, rem, remu (M extension) I-type: addi, andi, ori, xori, slli, srli, srai, slti, sltiu jalr, ld, lw, lh, lb, lwu, lhu, lbu, ebreak, ecall S-type: sd, sw, sh, sb B-type: beq, bne, blt, bge, bltu, bgeu U-type: lui, auipc J-type: jal Floating-point (F/D extension), atomic (A), compressed (C), vector (V) deferred -- separate commits when nxc2 emits them. Pseudoinstruction recognition (addi rd,zero,N -> li, etc.) is also deferred to nx_dis_pretty.nx.

dependencies 1 imports · 3 importers

syscalls.nx nx_dis.nx nx_dbg.nx nx_rv64_sim.nx nx_toolchain.nx

imports: syscalls.nx

imported by: nx_dbg.nxnx_rv64_sim.nxnx_toolchain.nx

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

main nx_dis_word_at nx_dis_opcode nx_dis_rd nx_dis_rs1 nx_dis_imm_i nx_dis_rs2 nx_dis_imm_s nx_dis_reg_name

structs

none

consts

none

functions

37func nx_dis_word_at(buf: *u8, off: i64) -> i64
45func nx_dis_opcode(w: i64) -> i64 { return w & 0x7F }
46func nx_dis_rd(w: i64) -> i64 { return (w >> 7) & 0x1F }
47func nx_dis_funct3(w: i64) -> i64 { return (w >> 12) & 0x7 }
48func nx_dis_rs1(w: i64) -> i64 { return (w >> 15) & 0x1F }
49func nx_dis_rs2(w: i64) -> i64 { return (w >> 20) & 0x1F }
50func nx_dis_funct7(w: i64) -> i64 { return (w >> 25) & 0x7F }
53func nx_dis_imm_i(w: i64) -> i64
60func nx_dis_imm_s(w: i64) -> i64
67func nx_dis_imm_b(w: i64) -> i64
78func nx_dis_imm_u(w: i64) -> i64
85func nx_dis_imm_j(w: i64) -> i64
100func nx_dis_reg_name(n: i64) -> *u8
139func nx_dis_r_mnem(funct3: i64, funct7: i64, is_w: i64) -> *u8
called by 1: nx_dis_one
177func nx_dis_i_alu_mnem(funct3: i64, funct7: i64, is_w: i64) -> *u8
called by 1: nx_dis_one
201func nx_dis_load_mnem(funct3: i64) -> *u8
called by 1: nx_dis_one
213func nx_dis_store_mnem(funct3: i64) -> *u8
called by 1: nx_dis_one
222func nx_dis_branch_mnem(funct3: i64) -> *u8
called by 1: nx_dis_one
234func nx_dis_puts(fd: i64, s: *u8) -> i64
called by 1: nx_dis_one
241func nx_dis_putdec(fd: i64, v: i64) -> i64
called by 1: nx_dis_one
271func nx_dis_one(buf: *u8, off: i64, fd: i64) -> i64
415func nx_dis_range(buf: *u8, off: i64, len: i64, fd: i64) -> i64
called by 1: main calls 1: nx_dis_one
428func main() -> i64