fn ld_vx_into_bcd(&mut self, reg: u8)
	{
		let word = self.v[reg as usize].to_string();
		let mut chars = word.chars();
		let start_index = 3 - word.len(); // Starting index for actual digits
		let mut addr = self.i; // Copy, don't modify I

		for i in 0..3 {
			if i < start_index { 
				self.ram.sb(addr, 0x0); 
			} else {
				self.ram.sb(addr, chars.next().unwrap().to_digit(10).unwrap() as u8);
			}
			addr = addr + 1;
		}
	}
/// Store BCD representation of Vreg in memory locations I, I+1, and I+2.
/// The interpreter takes the decimal value of Vreg, and places the hundreds digit in memory at location in I, the tens digit at location I+1, and the ones digit at location I+2.
Store BCD representation of Vreg in memory locations I, I+1, and I+2.
The interpreter takes the decimal value of Vreg, and places the hundreds digit in memory at location in I, the tens digit at location I+1, and the ones digit at location I+2.
Store BCD representation of Vreg in memory locations I I + 1 and I + 2 . The interpreter takes the decimal value of Vreg and places the hundreds digit in memory at location in I the tens digit at location I + 1 and the ones digit at location I + 2 .
fn ld_vx_into_bcd(&mut self, reg: u8)
	{
		let word = self.v[reg as usize].to_string();
		let mut chars = word.chars();
		let start_index = 3 - word.len(); // Starting index for actual digits
		let mut addr = self.i; // Copy, don't modify I
		for i in 0..3 {
			if i < start_index { 
				self.ram.sb(addr, 0x0); 
			} else {
				self.ram.sb(addr, chars.next().unwrap().to_digit(10).unwrap() as u8);
			}
			addr = addr + 1;
		}
	}
fn ld_vx_into_bcd ( & mut self , reg : u8 ) { let word = self . v [ reg as usize ] . to_string ( ) ; let mut chars = word . chars ( ) ; let start_index = 3 - word . len ( ) ; // Starting index for actual digits let mut addr = self . i ; // Copy, don't modify I for i in 0 .. 3 { if i < start_index { self . ram . sb ( addr , 0x0 ) ; } else { self . ram . sb ( addr , chars . next ( ) . unwrap ( ) . to_digit ( 10 ) . unwrap ( ) as u8 ) ; } addr = addr + 1 ; } }
Store BCD representation of Vreg in memory locations I, I+1, and I+2.
Store BCD representation of Vreg in memory locations I I + 1 and I + 2 .
&mut self
reg
u8