pub fn init_mem(&mut self, memory: &[u16]) {
		assert!(memory.len() <= (256 / 2)); // program cannot be larger than memory
		let mut next_cell = 0x00;

		// zero memory
		self.ip  = 0;
		self.ir  = 0;
		self.mem = [0; 256];
		for op in memory.iter() {
			let byte_1 = (*op >> 8) as u8;
			let byte_2 = *op as u8;

			self.mem[next_cell]     = byte_1;
			self.mem[next_cell + 1] = byte_2;
			next_cell += 2
		}
	}
/// Read an array of instructions into main memory
/// This reads two bytes at a time from the `memory` array
/// and loads them into the P150s RAM bank, starting from address 0.
Read an array of instructions into main memory
This reads two bytes at a time from the `memory` array
and loads them into the P150s RAM bank, starting from address 0.
Read an array of instructions into main memory This reads two bytes at a time from the ` memory ` array and loads them into the P150s RAM bank starting from address 0 .
pub fn init_mem(&mut self, memory: &[u16]) {
		assert!(memory.len() <= (256 / 2)); // program cannot be larger than memory
		let mut next_cell = 0x00;
		// zero memory
		self.ip  = 0;
		self.ir  = 0;
		self.mem = [0; 256];
		for op in memory.iter() {
			let byte_1 = (*op >> 8) as u8;
			let byte_2 = *op as u8;
			self.mem[next_cell]     = byte_1;
			self.mem[next_cell + 1] = byte_2;
			next_cell += 2
		}
	}
pub fn init_mem ( & mut self , memory : & [ u16 ] ) { assert ! ( memory len ( ) ( 256 2 ) ) ; // program cannot be larger than memory let mut next_cell = 0x00 ; // zero memory self . ip = 0 ; self . ir = 0 ; self . mem = [ 0 ; 256 ] ; for op in memory . iter ( ) { let byte_1 = ( * op >> 8 ) as u8 ; let byte_2 = * op as u8 ; self . mem [ next_cell ] = byte_1 ; self . mem [ next_cell + 1 ] = byte_2 ; next_cell += 2 } }
Read an array of instructions into main memory
This reads two bytes at a time from the `memory` array
and loads them into the P150s RAM bank, starting from address 0.
Read an array of instructions into main memory This reads two bytes at a time from the ` memory ` array and loads them into the P150s RAM bank starting from address 0 .
&mut self
memory
&[u16]