Skip to content
Snippets Groups Projects
Verified Commit b6e722cc authored by João Magalhães's avatar João Magalhães :rocket:
Browse files

feat: more ld instructions

parent f39ceff5
No related branches found
No related tags found
No related merge requests found
Pipeline #861 passed
...@@ -75,7 +75,7 @@ pub const INSTRUCTIONS: [(fn(&mut Cpu), u8, &'static str); 256] = [ ...@@ -75,7 +75,7 @@ pub const INSTRUCTIONS: [(fn(&mut Cpu), u8, &'static str); 256] = [
(ld_b_d, 4, "LD B, D"), (ld_b_d, 4, "LD B, D"),
(ld_b_e, 4, "LD B, E"), (ld_b_e, 4, "LD B, E"),
(ld_b_h, 4, "LD B, H"), (ld_b_h, 4, "LD B, H"),
(noimpl, 4, "! UNIMP !"), (ld_b_l, 4, "LD B, L"),
(ld_b_mhl, 8, "LD B, [HL]"), (ld_b_mhl, 8, "LD B, [HL]"),
(ld_b_a, 4, "LD B, A"), (ld_b_a, 4, "LD B, A"),
(ld_c_b, 4, "LD C, B"), (ld_c_b, 4, "LD C, B"),
...@@ -87,21 +87,21 @@ pub const INSTRUCTIONS: [(fn(&mut Cpu), u8, &'static str); 256] = [ ...@@ -87,21 +87,21 @@ pub const INSTRUCTIONS: [(fn(&mut Cpu), u8, &'static str); 256] = [
(ld_c_mhl, 8, "LD C, [HL]"), (ld_c_mhl, 8, "LD C, [HL]"),
(ld_c_a, 4, "LD C, A"), (ld_c_a, 4, "LD C, A"),
// 0x5 opcodes // 0x5 opcodes
(noimpl, 4, "! UNIMP !"), (ld_d_b, 4, "LD D, B"),
(noimpl, 4, "! UNIMP !"), (ld_d_c, 4, "LD D, C"),
(noimpl, 4, "! UNIMP !"), (ld_d_d, 4, "LD D, D"),
(noimpl, 4, "! UNIMP !"), (ld_d_e, 4, "LD D, E"),
(noimpl, 4, "! UNIMP !"), (ld_d_h, 4, "LD D, H"),
(noimpl, 4, "! UNIMP !"), (ld_d_l, 4, "LD D, L"),
(ld_d_mhl, 8, "LD D, [HL]"), (ld_d_mhl, 8, "LD D, [HL]"),
(ld_d_a, 4, "LD D, A"), (ld_d_a, 4, "LD D, A"),
(noimpl, 4, "! UNIMP !"), (ld_e_b, 4, "LD E, B"),
(noimpl, 4, "! UNIMP !"), (ld_e_c, 4, "LD E, C"),
(noimpl, 4, "! UNIMP !"), (ld_e_d, 4, "LD E, D"),
(noimpl, 4, "! UNIMP !"), (ld_e_e, 4, "LD E, E"),
(noimpl, 4, "! UNIMP !"), (ld_e_h, 4, "LD E, H"),
(ld_e_l, 4, "LD E, L"), (ld_e_l, 4, "LD E, L"),
(noimpl, 4, "! UNIMP !"), (ld_e_mhl, 8, "LD E, [HL]"),
(ld_e_a, 4, "LD E, A"), (ld_e_a, 4, "LD E, A"),
// 0x6 opcodes // 0x6 opcodes
(noimpl, 4, "! UNIMP !"), (noimpl, 4, "! UNIMP !"),
...@@ -124,7 +124,7 @@ pub const INSTRUCTIONS: [(fn(&mut Cpu), u8, &'static str); 256] = [ ...@@ -124,7 +124,7 @@ pub const INSTRUCTIONS: [(fn(&mut Cpu), u8, &'static str); 256] = [
(ld_mhl_b, 8, "LD [HL], B"), (ld_mhl_b, 8, "LD [HL], B"),
(ld_mhl_c, 8, "LD [HL], C"), (ld_mhl_c, 8, "LD [HL], C"),
(ld_mhl_d, 8, "LD [HL], D"), (ld_mhl_d, 8, "LD [HL], D"),
(noimpl, 4, "! UNIMP !"), (ld_mhl_e, 8, "LD [HL], E"),
(noimpl, 4, "! UNIMP !"), (noimpl, 4, "! UNIMP !"),
(noimpl, 4, "! UNIMP !"), (noimpl, 4, "! UNIMP !"),
(halt, 4, "HALT"), (halt, 4, "HALT"),
...@@ -185,7 +185,7 @@ pub const INSTRUCTIONS: [(fn(&mut Cpu), u8, &'static str); 256] = [ ...@@ -185,7 +185,7 @@ pub const INSTRUCTIONS: [(fn(&mut Cpu), u8, &'static str); 256] = [
(noimpl, 4, "! UNIMP !"), (noimpl, 4, "! UNIMP !"),
(noimpl, 4, "! UNIMP !"), (noimpl, 4, "! UNIMP !"),
(noimpl, 4, "! UNIMP !"), (noimpl, 4, "! UNIMP !"),
(noimpl, 4, "! UNIMP !"), (xor_a_l, 4, "XOR A, L"),
(xor_a_mhl, 8, "XOR A, [HL]"), (xor_a_mhl, 8, "XOR A, [HL]"),
(xor_a_a, 4, "XOR A, A"), (xor_a_a, 4, "XOR A, A"),
// 0xb opcodes // 0xb opcodes
...@@ -969,6 +969,10 @@ fn ld_b_h(cpu: &mut Cpu) { ...@@ -969,6 +969,10 @@ fn ld_b_h(cpu: &mut Cpu) {
cpu.b = cpu.h; cpu.b = cpu.h;
} }
fn ld_b_l(cpu: &mut Cpu) {
cpu.b = cpu.l;
}
fn ld_b_mhl(cpu: &mut Cpu) { fn ld_b_mhl(cpu: &mut Cpu) {
let byte = cpu.mmu.read(cpu.hl()); let byte = cpu.mmu.read(cpu.hl());
cpu.b = byte; cpu.b = byte;
...@@ -1011,6 +1015,30 @@ fn ld_c_a(cpu: &mut Cpu) { ...@@ -1011,6 +1015,30 @@ fn ld_c_a(cpu: &mut Cpu) {
cpu.c = cpu.a; cpu.c = cpu.a;
} }
fn ld_d_b(cpu: &mut Cpu) {
cpu.d = cpu.b;
}
fn ld_d_c(cpu: &mut Cpu) {
cpu.d = cpu.c;
}
fn ld_d_d(cpu: &mut Cpu) {
cpu.d = cpu.d;
}
fn ld_d_e(cpu: &mut Cpu) {
cpu.d = cpu.e;
}
fn ld_d_h(cpu: &mut Cpu) {
cpu.d = cpu.h;
}
fn ld_d_l(cpu: &mut Cpu) {
cpu.d = cpu.l;
}
fn ld_d_mhl(cpu: &mut Cpu) { fn ld_d_mhl(cpu: &mut Cpu) {
let byte = cpu.mmu.read(cpu.hl()); let byte = cpu.mmu.read(cpu.hl());
cpu.d = byte; cpu.d = byte;
...@@ -1020,10 +1048,35 @@ fn ld_d_a(cpu: &mut Cpu) { ...@@ -1020,10 +1048,35 @@ fn ld_d_a(cpu: &mut Cpu) {
cpu.d = cpu.a; cpu.d = cpu.a;
} }
fn ld_e_b(cpu: &mut Cpu) {
cpu.e = cpu.b;
}
fn ld_e_c(cpu: &mut Cpu) {
cpu.e = cpu.c;
}
fn ld_e_d(cpu: &mut Cpu) {
cpu.e = cpu.d;
}
fn ld_e_e(cpu: &mut Cpu) {
cpu.e = cpu.e;
}
fn ld_e_h(cpu: &mut Cpu) {
cpu.e = cpu.h;
}
fn ld_e_l(cpu: &mut Cpu) { fn ld_e_l(cpu: &mut Cpu) {
cpu.e = cpu.l; cpu.e = cpu.l;
} }
fn ld_e_mhl(cpu: &mut Cpu) {
let byte = cpu.mmu.read(cpu.hl());
cpu.e = byte;
}
fn ld_e_a(cpu: &mut Cpu) { fn ld_e_a(cpu: &mut Cpu) {
cpu.e = cpu.a; cpu.e = cpu.a;
} }
...@@ -1053,6 +1106,10 @@ fn ld_mhl_d(cpu: &mut Cpu) { ...@@ -1053,6 +1106,10 @@ fn ld_mhl_d(cpu: &mut Cpu) {
cpu.mmu.write(cpu.hl(), cpu.d); cpu.mmu.write(cpu.hl(), cpu.d);
} }
fn ld_mhl_e(cpu: &mut Cpu) {
cpu.mmu.write(cpu.hl(), cpu.e);
}
fn halt(cpu: &mut Cpu) { fn halt(cpu: &mut Cpu) {
cpu.halt(); cpu.halt();
} }
...@@ -1133,6 +1190,15 @@ fn xor_a_c(cpu: &mut Cpu) { ...@@ -1133,6 +1190,15 @@ fn xor_a_c(cpu: &mut Cpu) {
cpu.set_carry(false); cpu.set_carry(false);
} }
fn xor_a_l(cpu: &mut Cpu) {
cpu.a ^= cpu.l;
cpu.set_sub(false);
cpu.set_zero(cpu.a == 0);
cpu.set_half_carry(false);
cpu.set_carry(false);
}
fn xor_a_mhl(cpu: &mut Cpu) { fn xor_a_mhl(cpu: &mut Cpu) {
let byte = cpu.mmu.read(cpu.hl()); let byte = cpu.mmu.read(cpu.hl());
cpu.a ^= byte; cpu.a ^= byte;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment