summary refs log tree commit diff
path: root/65c02.ts
diff options
context:
space:
mode:
authorWlodekM <[email protected]>2025-04-02 17:18:05 +0300
committerWlodekM <[email protected]>2025-04-02 17:18:05 +0300
commitf245d085cf1ce04009dcbc9f8dc04dcfabf1c745 (patch)
tree90d5716c6a6b2bb7517b3e274e09cf35f10470f4 /65c02.ts
parent4f17a118a553ad67797745579ec6ab78842ef6f9 (diff)
more instructions
Diffstat (limited to '65c02.ts')
-rw-r--r--65c02.ts10
1 files changed, 9 insertions, 1 deletions
diff --git a/65c02.ts b/65c02.ts
index 96207a3..f3b0bd1 100644
--- a/65c02.ts
+++ b/65c02.ts
@@ -207,12 +207,20 @@ export default class The65c02 {
         const hi_abit = this.readPC().num()
         return ((hi_abit << 8) | lo_abit) + this.regY.num();
     }
-    getAddr(mode: string): number {
+    getAddr(mode: string, allow?: string[]): number {
+        if (allow && !allow.includes(mode))
+            throw 'disallowed mode'
         switch (mode) {
             case 'immediate':
                 this.programCounter.increment()
                 this.programCounter.increment()
                 return this.programCounter.num() - 1
+            // deno-lint-ignore no-case-declarations
+            case 'relative':
+                this.programCounter.increment()
+                const offset = this.readPC()
+                this.programCounter.increment()
+                return this.programCounter.num() + offset.num()
             case 'zero-page':
                 return this.getZPAddr()
             case 'zero-page, X-indexed':