lay structure for BCD conversion, store and load memory

This commit is contained in:
Denis-Cosmin NUTIU 2024-12-07 22:02:43 +02:00
parent 63d7fb1464
commit e948d3b5fb
2 changed files with 27 additions and 0 deletions

View file

@ -363,6 +363,15 @@ where
ProcessorInstruction::FontCharacter(vx) => {
self.index_register = 0xF0 + (self.registers[vx as usize] & 0x0F) as u16;
}
ProcessorInstruction::BinaryCodedDecimalConversion(vx) => {
todo!("must implement")
}
ProcessorInstruction::LoadMemory(vx) => {
todo!("must implement")
}
ProcessorInstruction::StoreMemory(vx) => {
todo!("must implement")
}
_ => {
warn!("Unknown instruction: {:04x}, skipping.", instruction);
}

View file

@ -72,6 +72,9 @@ pub enum ProcessorInstruction {
AddToIndex(u8),
/// Sets the index register to the hexadecimal character in VX.
FontCharacter(u8),
BinaryCodedDecimalConversion(u8),
StoreMemory(u8),
LoadMemory(u8),
/// Unknown instruction
UnknownInstruction,
}
@ -214,6 +217,21 @@ impl Instruction {
(0xF, _, 0x2, 0x9) => {
ProcessorInstruction::FontCharacter(Self::grab_first_nibble(data))
}
(0xF, _, 0x3, 0x3) => {
ProcessorInstruction::BinaryCodedDecimalConversion(
Self::grab_first_nibble(data)
)
}
(0xF, _, 0x5, 0x5) => {
ProcessorInstruction::StoreMemory(
Self::grab_first_nibble(data)
)
}
(0xF, _, 0x6, 0x5) => {
ProcessorInstruction::LoadMemory(
Self::grab_first_nibble(data)
)
}
// Unknown instruction
_ => ProcessorInstruction::UnknownInstruction,
}