Struct State

Source
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

Source

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

Source

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

Retrieve the value of a register register_id: u8 representing the id of the register

Source

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

Source

pub fn get_condition_code(&self) -> u8

Gets the current set condition codes

Source

pub fn set_condition_code(&mut self, value: u8)

Sets the condition codes value: u8 representing the new value

Source

pub fn get_program_size(&self) -> u64

Gets the program size

Source

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

Source

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

Source

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

Sets the value of the program counter new_pc: u64 representing the new pc to set

Source

pub fn get_pc(&self) -> u64

Gets the current PC

Source

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

Reads a single byte in memory address: u64 representing the address to the value to read

Auto Trait Implementations§

§

impl Freeze for State

§

impl RefUnwindSafe for State

§

impl Send for State

§

impl Sync for State

§

impl Unpin for State

§

impl UnwindSafe for State

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, 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, 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.