fix binary coded decimal instruction
This commit is contained in:
parent
5818815981
commit
0ce357b8ce
2 changed files with 5 additions and 4 deletions
|
@ -362,9 +362,10 @@ where
|
||||||
self.index_register = 0xF0 + (self.registers[vx as usize] & 0x0F) as u16;
|
self.index_register = 0xF0 + (self.registers[vx as usize] & 0x0F) as u16;
|
||||||
}
|
}
|
||||||
ProcessorInstruction::BinaryCodedDecimalConversion(vx) => {
|
ProcessorInstruction::BinaryCodedDecimalConversion(vx) => {
|
||||||
self.memory[self.index_register as usize] = vx / 100;
|
let number = self.registers[vx as usize];
|
||||||
self.memory[self.index_register as usize + 1] = (vx / 10) % 10;
|
self.memory[self.index_register as usize] = number / 100;
|
||||||
self.memory[self.index_register as usize + 2] = ((vx) % 100) % 10;
|
self.memory[self.index_register as usize + 1] = (number / 10) % 10;
|
||||||
|
self.memory[self.index_register as usize + 2] = ((number) % 100) % 10;
|
||||||
}
|
}
|
||||||
ProcessorInstruction::LoadMemory(vx) => {
|
ProcessorInstruction::LoadMemory(vx) => {
|
||||||
for i in 0..=vx {
|
for i in 0..=vx {
|
||||||
|
|
|
@ -13,7 +13,7 @@ fn main() -> Result<(), anyhow::Error> {
|
||||||
|
|
||||||
let mut emulator = Emulator::new(RatatuiDisplay::new());
|
let mut emulator = Emulator::new(RatatuiDisplay::new());
|
||||||
|
|
||||||
emulator.emulate(String::from("./roms/1-chip8-logo.ch8"))?;
|
emulator.emulate(String::from("./roms/3-corax+.ch8"))?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue