pub fn init(path: &str) -> Result<Self, std::io::Error> {
        let mut instruction_vec = fs::read(path)?;
        panic_on!(
            instruction_vec.len() % 4 != 0,
            "Can only have a number of bytes in the file which is divisible by 4"
        );
        instruction_vec.resize(MEMORY_SIZE, 0);
        let memory: Box<[u8]> = instruction_vec.into_boxed_slice();
        Ok(Self {
            registers: Box::new([0; REGISTERS_NO]),
            memory,
        })
    }
/// Initializes an ARM Cpu
/// with 17 registers
/// and 65536 bytes of memory
///
/// # Panics
/// Panics if the number of bytes from the binary file isn't divisible by 4
/// (Must mean the file is corrupted)
Initializes an ARM Cpu
with 17 registers
and 65536 bytes of memory
Initializes an ARM Cpu with 17 registers and 65536 bytes of memory
pub fn init(path: &str) -> Result<Self, std::io::Error> {
        let mut instruction_vec = fs::read(path)?;
        panic_on!(
            instruction_vec.len() % 4 != 0,
            "Can only have a number of bytes in the file which is divisible by 4"
        );
        instruction_vec.resize(MEMORY_SIZE, 0);
        let memory: Box<[u8]> = instruction_vec.into_boxed_slice();
        Ok(Self {
            registers: Box::new([0; REGISTERS_NO]),
            memory,
        })
    }
pub fn init ( path : & str ) -> Result < Self , std :: io :: Error > { let mut instruction_vec = fs :: read ( path ) ? ; panic_on ! ( instruction_vec len ( ) 4 0 " " ) ; instruction_vec . resize ( MEMORY_SIZE , 0 ) ; let memory : Box < [ u8 ] > = instruction_vec . into_boxed_slice ( ) ; Ok ( Self { registers : Box :: new ( [ 0 ; REGISTERS_NO ] ) , memory , } ) }
Initializes an ARM Cpu
with 17 registers
and 65536 bytes of memory
Initializes an ARM Cpu with 17 registers and 65536 bytes of memory
path
&str
panics
Panics if the number of bytes from the binary file isn't divisible by 4
(Must mean the file is corrupted)
Panics if the number of bytes from the binary file isn ' t divisible by 4 ( Must mean the file is corrupted )