Clean up load8::transfer

jsmoo
Nick Krichevsky 2022-04-09 14:02:59 -04:00
parent 034811c54e
commit 30e45bee72
1 changed files with 54 additions and 245 deletions

View File

@ -10,259 +10,68 @@ pub struct Between8BitRegisterParser;
impl OpcodeParser for Between8BitRegisterParser {
/// Parses an opcode that transfers an 8bit values between single 8 bit registers.
fn parse_opcode(data: &[u8]) -> ParseResult {
// I don't normally like doing this but this function was ridiculous with the line length wrapping
// caused by not doing it
#[allow(clippy::enum_glob_use)]
use register::SingleEightBit::*;
let opcode = parse::get_opcode_from_data(data)?;
match opcode {
0x7f => make_ldr1r2_data(
register::SingleEightBit::A,
register::SingleEightBit::A,
data,
),
0x78 => make_ldr1r2_data(
register::SingleEightBit::A,
register::SingleEightBit::B,
data,
),
0x79 => make_ldr1r2_data(
register::SingleEightBit::A,
register::SingleEightBit::C,
data,
),
0x7A => make_ldr1r2_data(
register::SingleEightBit::A,
register::SingleEightBit::D,
data,
),
0x7B => make_ldr1r2_data(
register::SingleEightBit::A,
register::SingleEightBit::E,
data,
),
0x7C => make_ldr1r2_data(
register::SingleEightBit::A,
register::SingleEightBit::H,
data,
),
0x7D => make_ldr1r2_data(
register::SingleEightBit::A,
register::SingleEightBit::L,
data,
),
0x7f => make_ldr1r2_data(A, A, data),
0x78 => make_ldr1r2_data(A, B, data),
0x79 => make_ldr1r2_data(A, C, data),
0x7A => make_ldr1r2_data(A, D, data),
0x7B => make_ldr1r2_data(A, E, data),
0x7C => make_ldr1r2_data(A, H, data),
0x7D => make_ldr1r2_data(A, L, data),
0x47 => make_ldr1r2_data(
register::SingleEightBit::B,
register::SingleEightBit::A,
data,
),
0x40 => make_ldr1r2_data(
register::SingleEightBit::B,
register::SingleEightBit::B,
data,
),
0x41 => make_ldr1r2_data(
register::SingleEightBit::B,
register::SingleEightBit::C,
data,
),
0x42 => make_ldr1r2_data(
register::SingleEightBit::B,
register::SingleEightBit::D,
data,
),
0x43 => make_ldr1r2_data(
register::SingleEightBit::B,
register::SingleEightBit::E,
data,
),
0x44 => make_ldr1r2_data(
register::SingleEightBit::B,
register::SingleEightBit::H,
data,
),
0x45 => make_ldr1r2_data(
register::SingleEightBit::B,
register::SingleEightBit::L,
data,
),
0x47 => make_ldr1r2_data(B, A, data),
0x40 => make_ldr1r2_data(B, B, data),
0x41 => make_ldr1r2_data(B, C, data),
0x42 => make_ldr1r2_data(B, D, data),
0x43 => make_ldr1r2_data(B, E, data),
0x44 => make_ldr1r2_data(B, H, data),
0x45 => make_ldr1r2_data(B, L, data),
0x4F => make_ldr1r2_data(
register::SingleEightBit::C,
register::SingleEightBit::A,
data,
),
0x48 => make_ldr1r2_data(
register::SingleEightBit::C,
register::SingleEightBit::B,
data,
),
0x49 => make_ldr1r2_data(
register::SingleEightBit::C,
register::SingleEightBit::C,
data,
),
0x4A => make_ldr1r2_data(
register::SingleEightBit::C,
register::SingleEightBit::D,
data,
),
0x4B => make_ldr1r2_data(
register::SingleEightBit::C,
register::SingleEightBit::E,
data,
),
0x4C => make_ldr1r2_data(
register::SingleEightBit::C,
register::SingleEightBit::H,
data,
),
0x4D => make_ldr1r2_data(
register::SingleEightBit::C,
register::SingleEightBit::L,
data,
),
0x4F => make_ldr1r2_data(C, A, data),
0x48 => make_ldr1r2_data(C, B, data),
0x49 => make_ldr1r2_data(C, C, data),
0x4A => make_ldr1r2_data(C, D, data),
0x4B => make_ldr1r2_data(C, E, data),
0x4C => make_ldr1r2_data(C, H, data),
0x4D => make_ldr1r2_data(C, L, data),
0x57 => make_ldr1r2_data(
register::SingleEightBit::D,
register::SingleEightBit::A,
data,
),
0x50 => make_ldr1r2_data(
register::SingleEightBit::D,
register::SingleEightBit::B,
data,
),
0x51 => make_ldr1r2_data(
register::SingleEightBit::D,
register::SingleEightBit::C,
data,
),
0x52 => make_ldr1r2_data(
register::SingleEightBit::D,
register::SingleEightBit::D,
data,
),
0x53 => make_ldr1r2_data(
register::SingleEightBit::D,
register::SingleEightBit::E,
data,
),
0x54 => make_ldr1r2_data(
register::SingleEightBit::D,
register::SingleEightBit::H,
data,
),
0x55 => make_ldr1r2_data(
register::SingleEightBit::D,
register::SingleEightBit::L,
data,
),
0x57 => make_ldr1r2_data(D, A, data),
0x50 => make_ldr1r2_data(D, B, data),
0x51 => make_ldr1r2_data(D, C, data),
0x52 => make_ldr1r2_data(D, D, data),
0x53 => make_ldr1r2_data(D, E, data),
0x54 => make_ldr1r2_data(D, H, data),
0x55 => make_ldr1r2_data(D, L, data),
0x5F => make_ldr1r2_data(
register::SingleEightBit::E,
register::SingleEightBit::A,
data,
),
0x58 => make_ldr1r2_data(
register::SingleEightBit::E,
register::SingleEightBit::B,
data,
),
0x59 => make_ldr1r2_data(
register::SingleEightBit::E,
register::SingleEightBit::C,
data,
),
0x5A => make_ldr1r2_data(
register::SingleEightBit::E,
register::SingleEightBit::D,
data,
),
0x5B => make_ldr1r2_data(
register::SingleEightBit::E,
register::SingleEightBit::E,
data,
),
0x5C => make_ldr1r2_data(
register::SingleEightBit::E,
register::SingleEightBit::H,
data,
),
0x5D => make_ldr1r2_data(
register::SingleEightBit::E,
register::SingleEightBit::L,
data,
),
0x5F => make_ldr1r2_data(E, A, data),
0x58 => make_ldr1r2_data(E, B, data),
0x59 => make_ldr1r2_data(E, C, data),
0x5A => make_ldr1r2_data(E, D, data),
0x5B => make_ldr1r2_data(E, E, data),
0x5C => make_ldr1r2_data(E, H, data),
0x5D => make_ldr1r2_data(E, L, data),
0x67 => make_ldr1r2_data(
register::SingleEightBit::H,
register::SingleEightBit::A,
data,
),
0x60 => make_ldr1r2_data(
register::SingleEightBit::H,
register::SingleEightBit::B,
data,
),
0x61 => make_ldr1r2_data(
register::SingleEightBit::H,
register::SingleEightBit::C,
data,
),
0x62 => make_ldr1r2_data(
register::SingleEightBit::H,
register::SingleEightBit::D,
data,
),
0x63 => make_ldr1r2_data(
register::SingleEightBit::H,
register::SingleEightBit::E,
data,
),
0x64 => make_ldr1r2_data(
register::SingleEightBit::H,
register::SingleEightBit::H,
data,
),
0x65 => make_ldr1r2_data(
register::SingleEightBit::H,
register::SingleEightBit::L,
data,
),
0x67 => make_ldr1r2_data(H, A, data),
0x60 => make_ldr1r2_data(H, B, data),
0x61 => make_ldr1r2_data(H, C, data),
0x62 => make_ldr1r2_data(H, D, data),
0x63 => make_ldr1r2_data(H, E, data),
0x64 => make_ldr1r2_data(H, H, data),
0x65 => make_ldr1r2_data(H, L, data),
0x6F => make_ldr1r2_data(
register::SingleEightBit::L,
register::SingleEightBit::A,
data,
),
0x68 => make_ldr1r2_data(
register::SingleEightBit::L,
register::SingleEightBit::B,
data,
),
0x69 => make_ldr1r2_data(
register::SingleEightBit::L,
register::SingleEightBit::C,
data,
),
0x6A => make_ldr1r2_data(
register::SingleEightBit::L,
register::SingleEightBit::D,
data,
),
0x6B => make_ldr1r2_data(
register::SingleEightBit::L,
register::SingleEightBit::E,
data,
),
0x6c => make_ldr1r2_data(
register::SingleEightBit::L,
register::SingleEightBit::H,
data,
),
0x6D => make_ldr1r2_data(
register::SingleEightBit::L,
register::SingleEightBit::L,
data,
),
0x6F => make_ldr1r2_data(L, A, data),
0x68 => make_ldr1r2_data(L, B, data),
0x69 => make_ldr1r2_data(L, C, data),
0x6A => make_ldr1r2_data(L, D, data),
0x6B => make_ldr1r2_data(L, E, data),
0x6c => make_ldr1r2_data(L, H, data),
0x6D => make_ldr1r2_data(L, L, data),
_ => Err(Error::UnknownOpcode(opcode)),
}