From 454276a50c5843e3401f9bc54d80cb7dda40b782 Mon Sep 17 00:00:00 2001 From: vin Date: Mon, 10 Jun 2024 12:54:05 +0530 Subject: [PATCH] implement sta, stx, sty --- cpu.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/cpu.c b/cpu.c index c0e3877..acb4efb 100644 --- a/cpu.c +++ b/cpu.c @@ -559,21 +559,21 @@ sei(uint8_t arg) } static void -sta(uint8_t arg) +sta(uint16_t mem) { -/* TODO: complete this */ + memwrite(mem, regs.a); } static void -stx(uint8_t arg) +stx(uint16_t mem) { -/* TODO: complete this */ + memwrite(mem, regs.x); } static void -sty(uint8_t arg) +sty(uint16_t mem) { -/* TODO: complete this */ + memwrite(mem, regs.y); } static void @@ -1219,59 +1219,59 @@ interpret(void) cycles += 2; break; case 0x85: - sta(opcode_arg(AM_ZP)); + sta(opcode_mem(AM_ZP)); cycles += 4; break; case 0x95: - sta(opcode_arg(AM_ZP_X)); + sta(opcode_mem(AM_ZP_X)); cycles += 5; break; case 0x8d: - sta(opcode_arg(AM_ABS)); + sta(opcode_mem(AM_ABS)); cycles += 5; break; case 0x9d: - sta(opcode_arg(AM_ABS_X)); + sta(opcode_mem(AM_ABS_X)); cycles += 6; break; case 0x99: - sta(opcode_arg(AM_ABS_Y)); + sta(opcode_mem(AM_ABS_Y)); cycles += 6; break; case 0x92: - sta(opcode_arg(AM_IND)); + sta(opcode_mem(AM_IND)); cycles += 6; break; case 0x81: - sta(opcode_arg(AM_IND_X)); + sta(opcode_mem(AM_IND_X)); cycles += 7; break; case 0x91: - sta(opcode_arg(AM_IND_Y)); + sta(opcode_mem(AM_IND_Y)); cycles += 7; break; case 0x86: - stx(opcode_arg(AM_ZP)); + stx(opcode_mem(AM_ZP)); cycles += 4; break; case 0x96: - stx(opcode_arg(AM_ZP_Y)); + stx(opcode_mem(AM_ZP_Y)); cycles += 5; break; case 0x8e: - stx(opcode_arg(AM_ABS)); + stx(opcode_mem(AM_ABS)); cycles += 5; break; case 0x84: - sty(opcode_arg(AM_ZP)); + sty(opcode_mem(AM_ZP)); cycles += 4; break; case 0x94: - sty(opcode_arg(AM_ZP_X)); + sty(opcode_mem(AM_ZP_X)); cycles += 5; break; case 0x8c: - sty(opcode_arg(AM_ABS)); + sty(opcode_mem(AM_ABS)); cycles += 5; break; case 0xaa: