diff options
-rw-r--r-- | instructions/ADC.ts | 2 | ||||
-rw-r--r-- | instructions/CMP.ts | 9 | ||||
-rw-r--r-- | instructions/CPX.ts | 9 | ||||
-rw-r--r-- | instructions/CPY.ts | 9 | ||||
-rw-r--r-- | instructions/DEC.ts | 10 | ||||
-rw-r--r-- | instructions/DEX.ts | 8 | ||||
-rw-r--r-- | instructions/DEY.ts | 8 | ||||
-rw-r--r-- | instructions/EOR.ts | 11 | ||||
-rw-r--r-- | instructions/JMP.ts | 6 |
9 files changed, 71 insertions, 1 deletions
diff --git a/instructions/ADC.ts b/instructions/ADC.ts index 5e00f15..cfb9f73 100644 --- a/instructions/ADC.ts +++ b/instructions/ADC.ts @@ -5,7 +5,7 @@ export default function (this: The65c02, mode: string) { this.io.address.set(addr); this.read() const mem = this.io.data.num(); - const result = this.regA.num() + mem + const result = this.regA.num() + mem + +this.carry this.flagZCN(result); this.regA.set(result & 0xFF); } \ No newline at end of file diff --git a/instructions/CMP.ts b/instructions/CMP.ts new file mode 100644 index 0000000..456cf1a --- /dev/null +++ b/instructions/CMP.ts @@ -0,0 +1,9 @@ +import type The65c02 from "../65c02.ts"; + +export default function (this: The65c02, mode: string) { + const location = this.getAddr(mode); + this.io.address.set(location); + this.read(); + const thing = this.regA.num() - this.io.data.num(); + this.flagZCN(thing); +} \ No newline at end of file diff --git a/instructions/CPX.ts b/instructions/CPX.ts new file mode 100644 index 0000000..15ab9b7 --- /dev/null +++ b/instructions/CPX.ts @@ -0,0 +1,9 @@ +import type The65c02 from "../65c02.ts"; + +export default function (this: The65c02, mode: string) { + const location = this.getAddr(mode); + this.io.address.set(location); + this.read(); + const thing = this.regX.num() - this.io.data.num(); + this.flagZCN(thing); +} \ No newline at end of file diff --git a/instructions/CPY.ts b/instructions/CPY.ts new file mode 100644 index 0000000..70cb166 --- /dev/null +++ b/instructions/CPY.ts @@ -0,0 +1,9 @@ +import type The65c02 from "../65c02.ts"; + +export default function (this: The65c02, mode: string) { + const location = this.getAddr(mode); + this.io.address.set(location); + this.read(); + const thing = this.regY.num() - this.io.data.num(); + this.flagZCN(thing); +} \ No newline at end of file diff --git a/instructions/DEC.ts b/instructions/DEC.ts new file mode 100644 index 0000000..9f14487 --- /dev/null +++ b/instructions/DEC.ts @@ -0,0 +1,10 @@ +import type The65c02 from "../65c02.ts"; + +export default function (this: The65c02, mode: string) { + const addr = this.getAddr(mode); + this.io.address.set(addr); + this.read(); + const res = this.io.data.num() - 1; + this.io.data.set(res & 0xFF); + this.flagZN(res & 0xFF) +} \ No newline at end of file diff --git a/instructions/DEX.ts b/instructions/DEX.ts new file mode 100644 index 0000000..f5452e8 --- /dev/null +++ b/instructions/DEX.ts @@ -0,0 +1,8 @@ +import type The65c02 from "../65c02.ts"; + +export default function (this: The65c02) { + const res = this.regX.num() - 1; + this.regX.set(res & 0xFF); + this.flagZN(res & 0xFF); + this.programCounter.increment(); +} \ No newline at end of file diff --git a/instructions/DEY.ts b/instructions/DEY.ts new file mode 100644 index 0000000..4410abc --- /dev/null +++ b/instructions/DEY.ts @@ -0,0 +1,8 @@ +import type The65c02 from "../65c02.ts"; + +export default function (this: The65c02) { + const res = this.regY.num() - 1; + this.regY.set(res & 0xFF); + this.flagZN(res & 0xFF); + this.programCounter.increment(); +} \ No newline at end of file diff --git a/instructions/EOR.ts b/instructions/EOR.ts new file mode 100644 index 0000000..462cc16 --- /dev/null +++ b/instructions/EOR.ts @@ -0,0 +1,11 @@ +import type The65c02 from "../65c02.ts"; + +export default function (this: The65c02, mode: string) { + const addr = this.getAddr(mode) + this.io.address.set(addr); + this.read() + const mem = this.io.data.num(); + const result = this.regA.num() ^ mem + this.flagZN(result); + this.regA.set(result & 0xFF); +} \ No newline at end of file diff --git a/instructions/JMP.ts b/instructions/JMP.ts new file mode 100644 index 0000000..c675c90 --- /dev/null +++ b/instructions/JMP.ts @@ -0,0 +1,6 @@ +import type The65c02 from "../65c02.ts"; + +export default function (this: The65c02, mode: string) { + const location = this.getAddr(mode, ['relative', 'absolute', 'indirect']); + this.programCounter.set(location) +} \ No newline at end of file |