summaryrefslogtreecommitdiff
path: root/cpu.c
diff options
context:
space:
mode:
authorvin <git@vineetk.net>2024-06-09 13:11:05 +0530
committervin <git@vineetk.net>2024-06-09 13:11:05 +0530
commit76b9059b2e299dca5a96cf94f21038002f4dad3a (patch)
tree13057c696da6140f2bf8569578a9ef4e2494a2b6 /cpu.c
parent207c6903f57f2364770c466dbe9807581ef96dc5 (diff)
add blank todo opcode functions based on opcode json
Diffstat (limited to 'cpu.c')
-rw-r--r--cpu.c425
1 files changed, 406 insertions, 19 deletions
diff --git a/cpu.c b/cpu.c
index bb6370b..4aeaaf6 100644
--- a/cpu.c
+++ b/cpu.c
@@ -110,7 +110,7 @@ opcode_arg(enum addressing_mode mode)
return val;
}
-void
+static void
adc(uint8_t arg)
{
uint16_t sum; // 16-bit sum makes it easier to determine carry flag
@@ -125,43 +125,198 @@ adc(uint8_t arg)
STATUS_UPDATE_NEGATIVE(regs.a);
}
-void
-sbc(uint8_t arg)
+static void
+and(uint8_t arg)
{
- /* SBC is described online as ADC with argument as two's complement */
- adc(~arg + 1);
+/* TODO: complete this */
}
-void
-brk(void)
+static void
+asl(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+bbr(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+bbs(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+bcc(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+bcs(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+beq(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+bit(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+bmi(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+bne(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+bpl(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+bra(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+brk()
{
- /* $00 */
/* TODO: push regs.pc and regs.status to stack and load IRQ vector */
regs.status.brk = 1;
- return;
+ exit(0);
}
-void
-tax(void)
+static void
+bvc(uint8_t arg)
{
- /* $AA */
- regs.x = regs.a;
+/* TODO: complete this */
+}
- STATUS_UPDATE_ZERO(regs.x);
- STATUS_UPDATE_NEGATIVE(regs.x);
+static void
+bvs(uint8_t arg)
+{
+/* TODO: complete this */
}
-void
-inx(void)
+static void
+clc(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+cld(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+cli(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+clv(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+cmp(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+cpx(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+cpy(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+dec(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+dex(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+dey(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+eor(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+inc(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+inx()
{
- /* $E8 */
regs.x++;
STATUS_UPDATE_ZERO(regs.x);
STATUS_UPDATE_NEGATIVE(regs.x);
}
-void
+static void
+iny(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+jmp(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+jsr(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
lda(uint8_t arg)
{
printf("arg1 $%02X\n", arg);
@@ -171,6 +326,238 @@ lda(uint8_t arg)
STATUS_UPDATE_NEGATIVE(regs.a);
}
+static void
+ldx(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+ldy(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+lsr(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+nop(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+ora(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+pha(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+php(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+phx(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+phy(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+pla(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+plp(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+plx(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+ply(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+rmb(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+rol(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+ror(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+rti(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+rts(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+sbc(uint8_t arg)
+{
+ /* SBC is described online as ADC with argument as two's complement */
+ adc(~arg + 1);
+}
+
+static void
+sec(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+sed(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+sei(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+smb(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+sta(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+stp(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+stx(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+sty(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+stz(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+tax()
+{
+ regs.x = regs.a;
+
+ STATUS_UPDATE_ZERO(regs.x);
+ STATUS_UPDATE_NEGATIVE(regs.x);
+}
+
+static void
+tay(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+trb(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+tsb(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+tsx(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+txa(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+txs(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+tya(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+wai(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
+static void
+unp(uint8_t arg)
+{
+/* TODO: complete this */
+}
+
void
interpret(void)
{