pub struct MMix { /* private fields */ }Implementations§
Source§impl MMix
impl MMix
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new MMIX computer with all registers and memory initialized to zero.
Sourcepub fn get_register(&self, reg: u8) -> u64
pub fn get_register(&self, reg: u8) -> u64
Get the value of a general-purpose register.
Sourcepub fn set_register(&mut self, reg: u8, value: u64)
pub fn set_register(&mut self, reg: u8, value: u64)
Set the value of a general-purpose register.
Sourcepub fn get_special(&self, reg: SpecialReg) -> u64
pub fn get_special(&self, reg: SpecialReg) -> u64
Get the value of a special-purpose register.
Sourcepub fn set_special(&mut self, reg: SpecialReg, value: u64)
pub fn set_special(&mut self, reg: SpecialReg, value: u64)
Set the value of a special-purpose register.
Sourcepub fn read_byte(&self, addr: u64) -> u8
pub fn read_byte(&self, addr: u64) -> u8
Read a byte from memory at the given address. Uninitialized memory reads as zero.
Sourcepub fn write_byte(&mut self, addr: u64, value: u8)
pub fn write_byte(&mut self, addr: u64, value: u8)
Write a byte to memory at the given address.
Sourcepub fn read_wyde(&self, addr: u64) -> u16
pub fn read_wyde(&self, addr: u64) -> u16
Read a wyde (2 bytes) from memory starting at the given address.
Sourcepub fn write_wyde(&mut self, addr: u64, value: u16)
pub fn write_wyde(&mut self, addr: u64, value: u16)
Write a wyde (2 bytes) to memory starting at the given address.
Sourcepub fn read_tetra(&self, addr: u64) -> u32
pub fn read_tetra(&self, addr: u64) -> u32
Read a tetra (4 bytes) from memory starting at the given address.
Sourcepub fn write_tetra(&mut self, addr: u64, value: u32)
pub fn write_tetra(&mut self, addr: u64, value: u32)
Write a tetra (4 bytes) to memory starting at the given address.
Sourcepub fn read_octa(&self, addr: u64) -> u64
pub fn read_octa(&self, addr: u64) -> u64
Read an octa (8 bytes) from memory starting at the given address.
Sourcepub fn write_octa(&mut self, addr: u64, value: u64)
pub fn write_octa(&mut self, addr: u64, value: u64)
Write an octa (8 bytes) to memory starting at the given address.
Sourcepub fn fetch_instruction(&self) -> (u8, u8, u8, u8)
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
Sourcepub fn advance_pc(&mut self)
pub fn advance_pc(&mut self)
Advance the program counter by 4 bytes (one instruction).
Sourcepub fn get_exit_code(&self) -> u64
pub fn get_exit_code(&self) -> u64
Get the exit code set by TRAP 0 (Halt).
Sourcepub fn execute_instruction(&mut self) -> bool
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.