Skip to main content

Module disasm

Module disasm 

Source
Expand description

RV32IMA disassembler — objdump-compatible output.

Converts a 32-bit instruction word into a human-readable string using ABI register names and common pseudo-instructions. When a SymbolTable is provided, branch and jump targets are annotated with symbol names.

§Output format

The format matches GNU objdump (-M no-aliases disabled, i.e. pseudos on):

80000014  510010ef  jal     ra, <main>
80001524  ff010113  addi    sp, sp, -16
80001528  00112623  sw      ra, 12(sp)

§Pseudo-instructions

The following common pseudos are emitted when the encoding matches:

PseudoCanonical form
nopaddi zero, zero, 0
mv rd, rsaddi rd, rs, 0
li rd, immaddi rd, zero, imm
not rd, rsxori rd, rs, -1
neg rd, rssub rd, zero, rs
snez rd, rssltu rd, zero, rs
retjalr zero, 0(ra)
jr rsjalr zero, 0(rs)
j offsetjal zero, offset
beqz/bnez/bltz/bgezbranch with zero as one operand

§Static disassembly

disasm_elf disassembles an entire ELF image segment by segment, with symbol labels printed before each function — equivalent to objdump -d.

Functions§

disasm_elf
Disassemble an entire ELF image, segment by segment, like objdump -d.
disassemble
Disassemble one RV32IMA instruction into an objdump-compatible string.