Implement decode for all x=1 unprefixed opcodes.
This commit is contained in:
parent
146e2dc066
commit
378a559106
|
@ -21,6 +21,7 @@ pub enum Instruction {
|
||||||
CPL,
|
CPL,
|
||||||
SCF,
|
SCF,
|
||||||
CCF,
|
CCF,
|
||||||
|
HALT,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum AllRegisters {
|
pub enum AllRegisters {
|
||||||
|
@ -126,13 +127,7 @@ impl Instruction {
|
||||||
(0, 5, _, y, _) => Instruction::DEC(Self::table_r(y)), // DEC r[y]
|
(0, 5, _, y, _) => Instruction::DEC(Self::table_r(y)), // DEC r[y]
|
||||||
(0, 6, _, y, _) => Instruction::LD(
|
(0, 6, _, y, _) => Instruction::LD(
|
||||||
// LD r[y], n
|
// LD r[y], n
|
||||||
{
|
Self::ld_table_r(y),
|
||||||
match Self::table_r(y) {
|
|
||||||
AllRegisters::U8(reg) => Argument::Register(reg),
|
|
||||||
AllRegisters::IndirectHL => Argument::IndirectRegister(RegisterPair::HL),
|
|
||||||
_ => unreachable!(),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Argument::ImmediateByte(n),
|
Argument::ImmediateByte(n),
|
||||||
),
|
),
|
||||||
(0, 7, _, 0, _) => Instruction::RLCA,
|
(0, 7, _, 0, _) => Instruction::RLCA,
|
||||||
|
@ -143,6 +138,12 @@ impl Instruction {
|
||||||
(0, 7, _, 5, _) => Instruction::CPL,
|
(0, 7, _, 5, _) => Instruction::CPL,
|
||||||
(0, 7, _, 6, _) => Instruction::SCF,
|
(0, 7, _, 6, _) => Instruction::SCF,
|
||||||
(0, 7, _, 7, _) => Instruction::CCF,
|
(0, 7, _, 7, _) => Instruction::CCF,
|
||||||
|
(1, 6, _, 6, _) => Instruction::HALT,
|
||||||
|
(1, z, _, y, _) => Instruction::LD(
|
||||||
|
// LD r[y], r[z]
|
||||||
|
Self::ld_table_r(y),
|
||||||
|
Self::ld_table_r(z),
|
||||||
|
),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -151,6 +152,14 @@ impl Instruction {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn ld_table_r(index: u8) -> Argument {
|
||||||
|
match Self::table_r(index) {
|
||||||
|
AllRegisters::U8(register) => Argument::Register(register),
|
||||||
|
AllRegisters::IndirectHL => Argument::IndirectRegister(RegisterPair::HL),
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn table_r(index: u8) -> AllRegisters {
|
fn table_r(index: u8) -> AllRegisters {
|
||||||
match index {
|
match index {
|
||||||
0 => AllRegisters::U8(Register::B),
|
0 => AllRegisters::U8(Register::B),
|
||||||
|
|
Loading…
Reference in New Issue