pub struct State { /* private fields */ }
Expand description
A state representing the Y86 program registers: a vector representing the registers condition_code: u8 representing the current set condition codes program_map: a vector holding the byte contents of the program program_size: u64, the size of the program memory program_counter: the program counter at all times, pointing to an address in memory
Implementations§
Source§impl State
impl State
Sourcepub fn new(file_name: String) -> Result<Self, Box<dyn Error>>
pub fn new(file_name: String) -> Result<Self, Box<dyn Error>>
Creates a new state of the program from a machine code file file_name: string representing the file name of a Y86 Machine code file
Sourcepub fn get_register(&self, register_id: u8) -> u64
pub fn get_register(&self, register_id: u8) -> u64
Retrieve the value of a register register_id: u8 representing the id of the register
Sourcepub fn set_register(&mut self, register_id: u8, value: u64)
pub fn set_register(&mut self, register_id: u8, value: u64)
sets the value of a register register_id: u8 representing the id of the register value: u64 representing the new value to put in the register
Sourcepub fn get_condition_code(&self) -> u8
pub fn get_condition_code(&self) -> u8
Gets the current set condition codes
Sourcepub fn set_condition_code(&mut self, value: u8)
pub fn set_condition_code(&mut self, value: u8)
Sets the condition codes value: u8 representing the new value
Sourcepub fn get_program_size(&self) -> u64
pub fn get_program_size(&self) -> u64
Gets the program size
Sourcepub fn read_le(&self, address: u64) -> Result<u64, Box<dyn Error>>
pub fn read_le(&self, address: u64) -> Result<u64, Box<dyn Error>>
Reads a memory address in little-endian address: u64 representing the address Returns a Result, fails if memory is out of bounds
Sourcepub fn write_le(
&mut self,
address: u64,
value: u64,
) -> Result<(), Box<dyn Error>>
pub fn write_le( &mut self, address: u64, value: u64, ) -> Result<(), Box<dyn Error>>
Writes to memory address in little-endian address: u64 representing the address value: u64 representing the value to insert into memory Returns a result, fails if memory is out of bounds