Rename 8 bit immediate load isntructions

jsmoo
Nick Krichevsky 2022-04-09 13:09:27 -04:00
parent e2365aec7e
commit 1795d652fa
3 changed files with 11 additions and 11 deletions

View File

@ -38,7 +38,7 @@ macro_rules! assert_ok {
impl Processor {
fn run(&mut self, instruction: &RunnableInstruction) {
match instruction.instruction {
Instruction::LDnnn { value, register } => {
Instruction::LD8BitImmediateToRegister { value, register } => {
self.registers.set_single_register(register, value);
}

View File

@ -5,7 +5,7 @@ use super::register;
// http://marc.rawer.de/Gameboy/Docs/GBCPUman.pdf
pub enum Instruction {
// 3.3.1.1
LDnnn {
LD8BitImmediateToRegister {
value: u8,
register: register::Single,
},

View File

@ -15,26 +15,26 @@ impl OpcodeParser for Immediate8BitLoadParser {
let opcode = parse::get_opcode_from_data(data)?;
match opcode {
0x3E => make_ldnn_data(register::Single::A, data),
0x06 => make_ldnn_data(register::Single::B, data),
0x0E => make_ldnn_data(register::Single::C, data),
0x16 => make_ldnn_data(register::Single::D, data),
0x1E => make_ldnn_data(register::Single::E, data),
0x26 => make_ldnn_data(register::Single::H, data),
0x2E => make_ldnn_data(register::Single::L, data),
0x3E => make_load_immediate_data(register::Single::A, data),
0x06 => make_load_immediate_data(register::Single::B, data),
0x0E => make_load_immediate_data(register::Single::C, data),
0x16 => make_load_immediate_data(register::Single::D, data),
0x1E => make_load_immediate_data(register::Single::E, data),
0x26 => make_load_immediate_data(register::Single::H, data),
0x2E => make_load_immediate_data(register::Single::L, data),
_ => Err(Error::UnknownOpcode(opcode)),
}
}
}
fn make_ldnn_data(register: register::Single, data: &[u8]) -> ParseResult {
fn make_load_immediate_data(register: register::Single, data: &[u8]) -> ParseResult {
let opcode = parse::get_opcode_from_data(data)?;
let value = data.get(1).ok_or(Error::NotEnoughArgs(opcode))?;
Ok((
RunnableInstruction {
instruction: Instruction::LDnnn {
instruction: Instruction::LD8BitImmediateToRegister {
register,
value: *value,
},