Crate yaxpeax_avnera

Crate yaxpeax_avnera 

Source
Expand description

§yaxpeax-avnera, a decoder for the Avnera microcontroller instruction sets

“Avnera” is not the documented name of this instruction set, so far as i know there is no published name for the instruction set. instead, it is the name of what was once a fabless semiconductor company seemingly specializing in ASICs for wireless audio purposes.

a quick search online mostly reports “Avnera AV____” parts, like “AV6201”, “AV6301”, “AV6302”, “AV7201”, or “AV7301”. these seem to be device names reported when USB devices are partially functioning and perhaps in a programming mode.

regardless, the instruction set in these parts is entirely undocumented. the disassembler here is a result of staring at a firmware dump and thinking really hard about what might be a coherent interpretation for the bytes that seem like instructions.

that reverse engineering and corresponding note taking is [here]. i am not the first to look at this architecture, both whitequark and prehistorcman have also looked at this and come to very similar conclusions:

§usage

the fastest way to decode an Avnera instruction is through InstDecoder::decode_slice():

use yaxpeax_avnera::InstDecoder;

let inst = InstDecoder::decode_slice(&[0xb9]).unwrap();

assert_eq!("ret", inst.to_string());

opcodes and operands are available on the decoded instruction, as well as its length and operand count:

use yaxpeax_avnera::{InstDecoder, Operand};

let inst = InstDecoder::decode_slice(&[0x28]).unwrap();

assert_eq!("r0 ^= r0", inst.to_string());
assert_eq!(inst.operand_count(), 1);
assert_eq!(inst.len(), 1);
assert_eq!(inst.operand(0).unwrap(), Operand::Register { n: 0 });

additionally, yaxpeax-avnera implements yaxpeax-arch traits for generic use, such as yaxpeax_arch::LengthedInstruction. yaxpeax_arch::Arch is implemented by the unit struct Avnera.

§#![no_std]

yaxpeax-avnera should support no_std usage, but this is entirely untested.

Structs§

Avnera
a trivial struct for yaxpeax_arch::Arch to be implemented on. it’s only interesting for the associated type parameters.
InstDecoder
an avnera instruction decoder.
Instruction
an avnera instruction.

Enums§

Operand
an operand for an avnera instruction. like the instructions themselves, these are not documented in any way i could find. these operands are best guesses from staring at firmware binaries really hard.