implement sta, stx, sty

This commit is contained in:
Vineet K 2024-06-10 12:54:05 +05:30
parent e07d5917a1
commit 454276a50c

40
cpu.c
View File

@ -559,21 +559,21 @@ sei(uint8_t arg)
} }
static void static void
sta(uint8_t arg) sta(uint16_t mem)
{ {
/* TODO: complete this */ memwrite(mem, regs.a);
} }
static void static void
stx(uint8_t arg) stx(uint16_t mem)
{ {
/* TODO: complete this */ memwrite(mem, regs.x);
} }
static void static void
sty(uint8_t arg) sty(uint16_t mem)
{ {
/* TODO: complete this */ memwrite(mem, regs.y);
} }
static void static void
@ -1219,59 +1219,59 @@ interpret(void)
cycles += 2; cycles += 2;
break; break;
case 0x85: case 0x85:
sta(opcode_arg(AM_ZP)); sta(opcode_mem(AM_ZP));
cycles += 4; cycles += 4;
break; break;
case 0x95: case 0x95:
sta(opcode_arg(AM_ZP_X)); sta(opcode_mem(AM_ZP_X));
cycles += 5; cycles += 5;
break; break;
case 0x8d: case 0x8d:
sta(opcode_arg(AM_ABS)); sta(opcode_mem(AM_ABS));
cycles += 5; cycles += 5;
break; break;
case 0x9d: case 0x9d:
sta(opcode_arg(AM_ABS_X)); sta(opcode_mem(AM_ABS_X));
cycles += 6; cycles += 6;
break; break;
case 0x99: case 0x99:
sta(opcode_arg(AM_ABS_Y)); sta(opcode_mem(AM_ABS_Y));
cycles += 6; cycles += 6;
break; break;
case 0x92: case 0x92:
sta(opcode_arg(AM_IND)); sta(opcode_mem(AM_IND));
cycles += 6; cycles += 6;
break; break;
case 0x81: case 0x81:
sta(opcode_arg(AM_IND_X)); sta(opcode_mem(AM_IND_X));
cycles += 7; cycles += 7;
break; break;
case 0x91: case 0x91:
sta(opcode_arg(AM_IND_Y)); sta(opcode_mem(AM_IND_Y));
cycles += 7; cycles += 7;
break; break;
case 0x86: case 0x86:
stx(opcode_arg(AM_ZP)); stx(opcode_mem(AM_ZP));
cycles += 4; cycles += 4;
break; break;
case 0x96: case 0x96:
stx(opcode_arg(AM_ZP_Y)); stx(opcode_mem(AM_ZP_Y));
cycles += 5; cycles += 5;
break; break;
case 0x8e: case 0x8e:
stx(opcode_arg(AM_ABS)); stx(opcode_mem(AM_ABS));
cycles += 5; cycles += 5;
break; break;
case 0x84: case 0x84:
sty(opcode_arg(AM_ZP)); sty(opcode_mem(AM_ZP));
cycles += 4; cycles += 4;
break; break;
case 0x94: case 0x94:
sty(opcode_arg(AM_ZP_X)); sty(opcode_mem(AM_ZP_X));
cycles += 5; cycles += 5;
break; break;
case 0x8c: case 0x8c:
sty(opcode_arg(AM_ABS)); sty(opcode_mem(AM_ABS));
cycles += 5; cycles += 5;
break; break;
case 0xaa: case 0xaa: