From f245d085cf1ce04009dcbc9f8dc04dcfabf1c745 Mon Sep 17 00:00:00 2001 From: WlodekM Date: Wed, 2 Apr 2025 17:18:05 +0300 Subject: more instructions --- 65c02.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to '65c02.ts') 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': -- cgit 1.4.1-2-gfad0