diff options
| author | James Barnett <noreply@jamesbarnett.xyz> | 2018-07-16 21:27:33 +0100 |
|---|---|---|
| committer | James Barnett <noreply@jamesbarnett.xyz> | 2018-07-16 21:27:33 +0100 |
| commit | ae3bb9819aad653d6a2ed972000e3c3696e39bf1 (patch) | |
| tree | 38cf07fc92c728807f03603ac0b0f7c51df77115 /src/main/kotlin/cpu/opcodes/Jumps.kt | |
| parent | 244cf2663133abb2fb861bce0474344999652f67 (diff) | |
| download | KGB-ae3bb9819aad653d6a2ed972000e3c3696e39bf1.tar.xz KGB-ae3bb9819aad653d6a2ed972000e3c3696e39bf1.zip | |
Implement JUMP ops
Diffstat (limited to 'src/main/kotlin/cpu/opcodes/Jumps.kt')
| -rw-r--r-- | src/main/kotlin/cpu/opcodes/Jumps.kt | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/main/kotlin/cpu/opcodes/Jumps.kt b/src/main/kotlin/cpu/opcodes/Jumps.kt new file mode 100644 index 0000000..6e0ea3e --- /dev/null +++ b/src/main/kotlin/cpu/opcodes/Jumps.kt @@ -0,0 +1,22 @@ +package cpu.opcodes + +import cpu.Operation +import cpu.Registers.Flag +import BitManipulation as bm + +val jumps = mapOf( + + 0xC3 to Operation("JP nn", 2, 12, {r, _, a -> r.PC = bm.argsToWord(a)}), + 0xC2 to Operation("JP NZ,nn", 2, 12, {r, _, a -> if(r.getFlag(Flag.ZERO) == 0) r.PC = bm.argsToWord(a)}), + 0xCA to Operation("JP Z,nn", 2, 12, {r, _, a -> if(r.getFlag(Flag.ZERO) == 1) r.PC = bm.argsToWord(a)}), + 0xD2 to Operation("JP NC,nn", 2, 12, {r, _, a -> if(r.getFlag(Flag.CARRY) == 0) r.PC = bm.argsToWord(a)}), + 0xDA to Operation("JP C,nn", 2, 12, {r, _, a -> if(r.getFlag(Flag.CARRY) == 1) r.PC = bm.argsToWord(a)}), + 0xE9 to Operation("JP (HL)", 0, 4, {r, m, _ -> r.PC = m.readByte(r.HL)}), + + 0x18 to Operation("JR n", 1, 8, {r, _, a -> r.addSignedByteToPC(a[0])}), + 0x20 to Operation("JR NZ,n", 1, 8, {r, _, a -> if(r.getFlag(Flag.ZERO) == 0) r.addSignedByteToPC(a[0])}), + 0x28 to Operation("JR Z,n", 1, 8, {r, _, a -> if(r.getFlag(Flag.ZERO) == 1) r.addSignedByteToPC(a[0])}), + 0x30 to Operation("JR NC,n", 1, 8, {r, _, a -> if(r.getFlag(Flag.CARRY) == 0) r.addSignedByteToPC(a[0])}), + 0x38 to Operation("JR C,n", 1, 8, {r, _, a -> if(r.getFlag(Flag.CARRY) == 1) r.addSignedByteToPC(a[0])}) + +)
\ No newline at end of file |