Expand description
An emulator for the ARMv4T instruction set.
§Example
use armv4t_emu::{reg, Cpu, ExampleMem, Mode, Memory};
let prog = &[
0x06, 0x00, 0xa0, 0xe3, // mov r0, #6
0x01, 0x10, 0xa0, 0xe3, // mov r1, #1
0x01, 0x10, 0x81, 0xe0, // l: add r1, r1, r1
0x01, 0x00, 0x50, 0xe2, // subs r0, #1
0xfc, 0xff, 0xff, 0x1a, // bne l
0x01, 0x6c, 0xa0, 0xe3, // mov r6, #0x100
0x00, 0x10, 0x86, 0xe5, // str r1, [r6]
0xf7, 0xf0, 0xde, 0xad // ; trigger undefined instr exception
];
let mut mem = ExampleMem::new_with_data(prog);
let mut cpu = Cpu::new();
cpu.reg_set(Mode::User, reg::PC, 0x00);
cpu.reg_set(Mode::User, reg::CPSR, 0x10);
while cpu.step(&mut mem) {}
assert_eq!(64, mem.r32(0x100));
Modules§
- Register identifiers.
Structs§
- An emulated CPU which implements the ARMv4T instruction set.
- Example memory device backed by a BTreeMap<u32, u8>.
Enums§
- An ARMv4T processor exception.
- An ARMv4T processor mode.
Traits§
- Encodes how the
Cpu
accesses external memory / memory-mapped devices.