wave-decode
Shared instruction decoder for the WAVE ISA. This crate provides:
- Opcode definitions matching
wave-asm's encoding - Instruction decoding from binary to structured Rust types
- WBIN container parsing for reading
.wbinfiles
Usage
Add to your Cargo.toml:
[]
= { = "../wave-decode" }
Decoding Instructions
use ;
// Decode from raw bytes
let code: & = &; // halt instruction
let mut decoder = new;
while decoder.has_more
// Or decode all at once
let instructions = decode_all?;
Reading WBIN Files
use WbinFile;
let data = read?;
let wbin = parse?;
println!;
for kernel in &wbin.kernels
// Decode a specific kernel
if let Some = wbin.kernel_code
Architecture
The crate is organized into four modules:
opcodes- Constants and enums for all WAVE opcodes and modifiersinstruction-DecodedInstructionandOperationtypesdecoder- TheDecoderstruct that reads binary instructionswbin- WBIN container format parser
WBIN Format
The WBIN format is a simple container:
| Offset | Size | Description |
|---|---|---|
| 0x00 | 4 | Magic "WAVE" |
| 0x04 | 2 | Version (0x0001) |
| 0x06 | 2 | Flags (reserved) |
| 0x08 | 4 | Code section offset |
| 0x0C | 4 | Code section size |
| 0x10 | 4 | Symbol table offset |
| 0x14 | 4 | Symbol table size |
| 0x18 | 4 | Metadata offset |
| 0x1C | 4 | Metadata size |
Followed by the code section, symbol table (null-terminated strings), and kernel metadata.
License
Apache 2.0 - see LICENSE