c-like struct for SetIndexRegister instruction
This commit is contained in:
parent
7f07d3b184
commit
a464c00836
2 changed files with 6 additions and 4 deletions
|
@ -217,7 +217,7 @@ where
|
|||
let (result, _) = self.registers[register as usize].overflowing_add(value);
|
||||
self.registers[register as usize] = result;
|
||||
}
|
||||
ProcessorInstruction::SetIndexRegister(data) => {
|
||||
ProcessorInstruction::SetIndexRegister { data } => {
|
||||
trace!("Set index register to data {:04x}", data);
|
||||
self.index_register = data;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ pub enum ProcessorInstruction {
|
|||
/// Adds the value to the register
|
||||
AddValueToRegister { register: u8, value: u8 },
|
||||
/// Sets the index register
|
||||
SetIndexRegister(u16),
|
||||
SetIndexRegister { data: u16 },
|
||||
/// Draws to the screen.
|
||||
Draw(u8, u8, u8),
|
||||
/// Call sets PC to the address and saves the return address on the stack
|
||||
|
@ -146,7 +146,9 @@ impl Instruction {
|
|||
}
|
||||
}
|
||||
// Set index register
|
||||
(0xA, _, _, _) => ProcessorInstruction::SetIndexRegister(Self::grab_inner_data(data)),
|
||||
(0xA, _, _, _) => ProcessorInstruction::SetIndexRegister {
|
||||
data: Self::grab_inner_data(data),
|
||||
},
|
||||
// Draw on screen
|
||||
(0xD, _, _, _) => {
|
||||
// DXYN
|
||||
|
@ -500,7 +502,7 @@ mod tests {
|
|||
let instruction = Instruction::new([0xAA, 0xBC]);
|
||||
assert_eq!(
|
||||
instruction.processor_instruction,
|
||||
ProcessorInstruction::SetIndexRegister(0xABC)
|
||||
ProcessorInstruction::SetIndexRegister { data: 0xABC }
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue