aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/cpu/opcodes
diff options
context:
space:
mode:
authorJames Barnett <noreply@jamesbarnett.xyz>2018-06-15 22:10:47 +0100
committerJames Barnett <noreply@jamesbarnett.xyz>2018-06-15 22:10:47 +0100
commitd8dbfe55f4741a9cf70c1b95762461e08eb08f22 (patch)
tree779df3fc4192b251da8f9f1e9e712376d9f096c9 /src/main/kotlin/cpu/opcodes
parent22f3463e3128947df69cb6444c82bd73350d5cc5 (diff)
downloadKGB-d8dbfe55f4741a9cf70c1b95762461e08eb08f22.tar.xz
KGB-d8dbfe55f4741a9cf70c1b95762461e08eb08f22.zip
Add all 8-Bit Load opcodes
Diffstat (limited to 'src/main/kotlin/cpu/opcodes')
-rw-r--r--src/main/kotlin/cpu/opcodes/Loads8Bit.kt24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/main/kotlin/cpu/opcodes/Loads8Bit.kt b/src/main/kotlin/cpu/opcodes/Loads8Bit.kt
index 091db7f..99eb933 100644
--- a/src/main/kotlin/cpu/opcodes/Loads8Bit.kt
+++ b/src/main/kotlin/cpu/opcodes/Loads8Bit.kt
@@ -1,6 +1,7 @@
package cpu.opcodes
import cpu.Operation
+import BitManipulation as bm
// 8-Bit Loads
var loads8Bit = mapOf(
@@ -21,7 +22,8 @@ var loads8Bit = mapOf(
0x0A to Operation("LD A,(BC)", 0, 8, {r, m, _ -> r.A = m.readByte(r.BC)}),
0x1A to Operation("LD A,(DE)", 0, 8, {r, m, _ -> r.A = m.readByte(r.DE)}),
0x7E to Operation("LD A,(HL)", 0, 8, {r, m, _ -> r.A = m.readByte(r.HL)}),
- 0x3E to Operation("LD A, n", 0, 8, {r, _, a -> r.A = a[0]}),
+ 0x3E to Operation("LD A, n", 1, 8, {r, _, a -> r.A = a[0]}),
+ 0xFA to Operation("LD A,(nn)", 2, 16, {r, m, a -> r.A = m.readByte(bm.argsToWord(a))}),
0x40 to Operation("LD B,B", 0, 4, {r, _, _ -> r.B = r.B}),
0x41 to Operation("LD B,C", 0, 4, {r, _, _ -> r.B = r.C}),
@@ -86,6 +88,24 @@ var loads8Bit = mapOf(
0x57 to Operation("LD D,A", 0, 4, {r, _, _ -> r.D = r.A}),
0x5F to Operation("LD E,A", 0, 4, {r, _, _ -> r.E = r.A}),
0x67 to Operation("LD H,A", 0, 4, {r, _, _ -> r.H = r.A}),
- 0x6F to Operation("LD L,A", 0, 4, {r, _, _ -> r.L = r.A})
+ 0x6F to Operation("LD L,A", 0, 4, {r, _, _ -> r.L = r.A}),
+ 0x02 to Operation("LD (BC),A", 0, 8, {r, m, _ -> m.writeByte(r.BC, r.A)}),
+ 0x12 to Operation("LD (DE),A", 0, 8, {r, m, _ -> m.writeByte(r.DE, r.A)}),
+ 0x77 to Operation("LD (HL),A", 0, 8, {r, m, _ -> m.writeByte(r.HL, r.A)}),
+ 0xEA to Operation("LD (nn),A", 2, 16, {r, m, a -> m.writeByte(bm.argsToWord(a), r.A)}),
+
+ 0xF2 to Operation("LD A,(C)", 0, 8, {r, m, _ -> r.A = m.readByte(0xFF00 + r.C)}),
+ 0xE2 to Operation("LD (C),A", 0, 8, {r, m, _ -> m.writeByte(0xFF00 + r.C, r.A)}),
+
+ 0x3A to Operation("LDD A,(HL)", 0, 8, {r, m, _ -> r.A = m.readByte(r.getAndDecrementHL())}),
+ 0x32 to Operation("LDD (HL),A", 0, 8, {r, m, _ -> m.writeByte(r.getAndDecrementHL(), r.A)}),
+
+ 0x2A to Operation("LDI A,(HL)", 0, 8, {r, m, _ -> r.A = m.readByte(r.getAndIncrementHL())}),
+ 0x22 to Operation("LDI (HL),A", 0, 8, {r, m, _ -> m.writeByte(r.getAndIncrementHL(), r.A)}),
+
+ 0xE0 to Operation("LD (n),A", 1, 8, {r, m, a -> m.writeByte(0xFF00 + a[0], r.A)}),
+ 0xF0 to Operation("LD A,(n)", 1, 8, {r, m, a -> r.A = m.readByte(0xFF00 + a[0])})
+
+
) \ No newline at end of file