use c-like struct for JumpWithOffset instruction
This commit is contained in:
parent
517628ced6
commit
2842c55cf8
2 changed files with 6 additions and 4 deletions
|
@ -335,7 +335,7 @@ where
|
||||||
self.registers[0xF] = self.registers[vx as usize] & 0x1;
|
self.registers[0xF] = self.registers[vx as usize] & 0x1;
|
||||||
self.registers[vx as usize] >>= 1;
|
self.registers[vx as usize] >>= 1;
|
||||||
}
|
}
|
||||||
ProcessorInstruction::JumpWithOffset(address) => {
|
ProcessorInstruction::JumpWithOffset { address } => {
|
||||||
let offset = self.registers[0x0];
|
let offset = self.registers[0x0];
|
||||||
trace!("Jump With offset Address={address:04x} Offset={offset:04x}");
|
trace!("Jump With offset Address={address:04x} Offset={offset:04x}");
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ pub enum ProcessorInstruction {
|
||||||
/// This instruction has different behaviour on CHIP-48 and SUPER-CHIP.
|
/// This instruction has different behaviour on CHIP-48 and SUPER-CHIP.
|
||||||
ShiftLeft { vx: u8, vy: u8 },
|
ShiftLeft { vx: u8, vy: u8 },
|
||||||
/// Jumps to the address and adds V0 offset.
|
/// Jumps to the address and adds V0 offset.
|
||||||
JumpWithOffset(u16),
|
JumpWithOffset { address: u16 },
|
||||||
/// Generates a random number ANDed with the data and stores it in VX.
|
/// Generates a random number ANDed with the data and stores it in VX.
|
||||||
GenerateRandomNumber(u8, u8),
|
GenerateRandomNumber(u8, u8),
|
||||||
/// Skips the next instruction if VX is equal to data.
|
/// Skips the next instruction if VX is equal to data.
|
||||||
|
@ -198,7 +198,9 @@ impl Instruction {
|
||||||
vx: Self::grab_first_nibble(data),
|
vx: Self::grab_first_nibble(data),
|
||||||
vy: Self::grab_middle_nibble(data),
|
vy: Self::grab_middle_nibble(data),
|
||||||
},
|
},
|
||||||
(0xB, _, _, _) => ProcessorInstruction::JumpWithOffset(Self::grab_inner_data(data)),
|
(0xB, _, _, _) => ProcessorInstruction::JumpWithOffset {
|
||||||
|
address: Self::grab_inner_data(data),
|
||||||
|
},
|
||||||
(0xC, _, _, _) => ProcessorInstruction::GenerateRandomNumber(
|
(0xC, _, _, _) => ProcessorInstruction::GenerateRandomNumber(
|
||||||
Self::grab_first_nibble(data),
|
Self::grab_first_nibble(data),
|
||||||
Self::grab_last_byte(data),
|
Self::grab_last_byte(data),
|
||||||
|
@ -513,7 +515,7 @@ mod tests {
|
||||||
let instruction = Instruction::new([0xBA, 0xBC]);
|
let instruction = Instruction::new([0xBA, 0xBC]);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
instruction.processor_instruction,
|
instruction.processor_instruction,
|
||||||
ProcessorInstruction::JumpWithOffset(0xABC)
|
ProcessorInstruction::JumpWithOffset { address: 0xABC }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue