MMix

Struct MMix 

Source
pub struct MMix { /* private fields */ }

Implementations§

Source§

impl MMix

Source

pub fn new() -> Self

Create a new MMIX computer with all registers and memory initialized to zero.

Source

pub fn get_register(&self, reg: u8) -> u64

Get the value of a general-purpose register.

Source

pub fn set_register(&mut self, reg: u8, value: u64)

Set the value of a general-purpose register.

Source

pub fn get_special(&self, reg: SpecialReg) -> u64

Get the value of a special-purpose register.

Source

pub fn set_special(&mut self, reg: SpecialReg, value: u64)

Set the value of a special-purpose register.

Source

pub fn read_byte(&self, addr: u64) -> u8

Read a byte from memory at the given address. Uninitialized memory reads as zero.

Source

pub fn write_byte(&mut self, addr: u64, value: u8)

Write a byte to memory at the given address.

Source

pub fn read_wyde(&self, addr: u64) -> u16

Read a wyde (2 bytes) from memory starting at the given address.

Source

pub fn write_wyde(&mut self, addr: u64, value: u16)

Write a wyde (2 bytes) to memory starting at the given address.

Source

pub fn read_tetra(&self, addr: u64) -> u32

Read a tetra (4 bytes) from memory starting at the given address.

Source

pub fn write_tetra(&mut self, addr: u64, value: u32)

Write a tetra (4 bytes) to memory starting at the given address.

Source

pub fn read_octa(&self, addr: u64) -> u64

Read an octa (8 bytes) from memory starting at the given address.

Source

pub fn write_octa(&mut self, addr: u64, value: u64)

Write an octa (8 bytes) to memory starting at the given address.

Source

pub fn fetch_instruction(&self) -> (u8, u8, u8, u8)

Fetch the next instruction from memory and decode it. Returns (OP, X, Y, Z) where:

  • OP is the opcode
  • X, Y, Z are the operand bytes
Source

pub fn get_pc(&self) -> u64

Get the current program counter.

Source

pub fn set_pc(&mut self, pc: u64)

Set the program counter.

Source

pub fn advance_pc(&mut self)

Advance the program counter by 4 bytes (one instruction).

Source

pub fn get_exit_code(&self) -> u64

Get the exit code set by TRAP 0 (Halt).

Source

pub fn execute_instruction(&mut self) -> bool

Execute a single instruction at the current program counter. Returns true if execution should continue, false if halted.

Source

pub fn run(&mut self) -> usize

Execute instructions starting from the current PC until a halt condition. Returns the number of instructions executed.

Source§

impl MMix

Source

pub fn display_with(&self, format: ValueFormat) -> MMixDisplay<'_>

Trait Implementations§

Source§

impl Default for MMix

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for MMix

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for MMix

§

impl RefUnwindSafe for MMix

§

impl Send for MMix

§

impl Sync for MMix

§

impl Unpin for MMix

§

impl UnwindSafe for MMix

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more