Skip to main content

Crate procem

Crate procem 

Source
Expand description

procem provides a Processor structure, which emulates a real-world processor architecture.

The design is loosely based on the ARM architecture.

The processor operates by loading and executing an assembly Program. A Program is a collection of assembly instructions that the processor iterates over and executes. The instruction set in use must implement the Instruction trait. A default instruction set is available in the procem_default crate.

The Registers and Stack use Word as their data type.

The processor’s Registers, Flags and Stack are directly accessible and modifiable through the Processor structure.

let r0 = processor.registers.get_reg(Register::R0);
processor.registers.set_reg(Register::R1, r0);

let overflow = processor.registers.get_flag(Flag::V);

processor.stack.write(processor.registers.get_reg(Register::SP), 10.into());
let val = processor.stack.read(processor.registers.get_reg(Register::SP));
assert_eq!(val, 10.into());

Modules§

instruction
The Instruction trait.
processor
The Processor and ProcessorBuilder structs.
program
The Program struct.
register
The Registers struct, Register enum and Flag enum.
stack
The processor’s Stack.
word
The Word trait, its super traits and its implementations for all signed integer types.