Skip to main content

Crate h8_asm

Crate h8_asm 

Source
Expand description

A decoder, disassembler, assembler and detour installer for the Renesas H8 family (H8/300, H8/300H, H8S/2000, H8S/2600 and H8SX), operating on a flat big-endian &[u8] image where file offset and load address are the same number.

isa::insn_len, isa::decode_insn, isa::encode_insn and isa::disassemble_insn cover all five targets through the legacy opcode maps and all 8,493 reviewed H8SX manual rows. The original narrow H8/300 and H8SX APIs remain available. Asm, relocate, detour, image and analysis provide checked assembly, patch planning and conservative control-flow analysis. Delayed, PC-indexed and compound relative relocation is explicitly refused where safe rewriting cannot be established.

Instruction-aware APIs require the core (Target) and operating mode (Mode). Both change what bytes mean and must come from the caller’s knowledge of the firmware, not a guess from its byte patterns.

use h8_asm::{isa, Mode, Target};

let bytes = [0x0c, 0x89]; // MOV.B R0L,R1L
let decoded = isa::decode_insn(&bytes, Target::H8_300, Mode::Normal).unwrap();
assert_eq!(decoded.len, 2);
assert_eq!(
    isa::encode_insn(decoded.insn, Target::H8_300, Mode::Normal).unwrap(),
    bytes
);

Every encoding claim in this crate cites its section in Renesas’ software manuals under spec/ (H8/300 ADE-602-025, H8/300H REJ09B0213, H8S REJ09B0139, H8SX REJ09B0102).

Re-exports§

pub use image::find;
pub use image::find_free_space;
pub use image::insert;
pub use image::read_u16;
pub use image::read_u32;
pub use image::read_u8;
pub use image::write;
pub use image::CommandRecord;
pub use image::CommandTable;
pub use image::ImageError;
pub use image::Needle;
pub use image::TableError;
pub use asm::Asm;

Modules§

analysis
Conservative control-flow analysis of recognized H8 instructions.
asm
A label assembler for recognized H8 instruction bytes and relative branches.
detour
Transactional hooks with trampolines in flat images.
image
Checked search and mutation of flat, big-endian firmware images.
isa
Instruction boundaries in a big-endian H8 instruction stream.
relocate
Relocation of recognized instruction streams in flat images.

Enums§

Mode
The CPU operating mode, which sets the width of the address space, of branch and call targets, of vector-table entries and of stacked PCs.
Target
The H8 core an image was written for.