diff --git a/cpu.c b/cpu.c index 770206d..a8c6ceb 100644 --- a/cpu.c +++ b/cpu.c @@ -26,20 +26,18 @@ struct registers { struct registers regs; enum addressing_mode { - AM_ACCUMULATOR, - AM_IMMEDIATE, - AM_ZERO_PAGE, - AM_ZERO_PAGE_X, - AM_ZERO_PAGE_Y, - AM_RELATIVE, - AM_ABSOLUTE, - AM_ABSOLUTE_X, - AM_ABSOLUTE_Y, - AM_INDIRECT, - AM_INDIRECT_X, - AM_INDIRECT_Y, - AM_INDEXED_INDIRECT, - AM_INDIRECT_INDEXED, + AM_ACC, + AM_IMM, + AM_ZP, + AM_ZP_X, + AM_ZP_Y, + AM_REL, + AM_ABS, + AM_ABS_X, + AM_ABS_Y, + AM_IND, + AM_IND_X, + AM_IND_Y, }; /* 64K address space, 16bit words */ @@ -98,28 +96,28 @@ lda(enum addressing_mode mode) arg = peek(regs.pc++); switch (mode) { - case AM_IMMEDIATE: /* $A9 */ + case AM_IMM: /* $A9 */ val = arg; break; - case AM_ZERO_PAGE: /* $A5 */ + case AM_ZP: /* $A5 */ val = peek(arg % 256); break; - case AM_ABSOLUTE: /* $AD */ + case AM_ABS: /* $AD */ val = peek(arg); break; - case AM_ZERO_PAGE_X: /* $B5 */ + case AM_ZP_X: /* $B5 */ val = peek((arg + regs.x) % 256); break; - case AM_ABSOLUTE_X: /* $BD */ + case AM_ABS_X: /* $BD */ val = peek(arg + regs.x); break; - case AM_ABSOLUTE_Y: /* $B9 */ + case AM_ABS_Y: /* $B9 */ val = peek(arg + regs.y); break; - case AM_INDIRECT_X: /* $A1 */ + case AM_IND_X: /* $A1 */ val = peek(peek((arg + regs.x) % 256) + peek((arg + regs.x + 1) % 256) * 256); break; - case AM_INDIRECT_Y: /* $B1 */ + case AM_IND_Y: /* $B1 */ val = peek(peek(arg) + peek((arg + 1) % 256) * 256 + regs.y); break; default: @@ -149,31 +147,31 @@ interpret(void) brk(); return; case 0xa1: - lda(AM_INDIRECT_X); + lda(AM_IND_X); break; case 0xa5: - lda(AM_ZERO_PAGE); + lda(AM_ZP); break; case 0xa9: - lda(AM_IMMEDIATE); + lda(AM_IMM); break; case 0xaa: tax(); break; case 0xad: - lda(AM_ABSOLUTE); + lda(AM_ABS); break; case 0xb1: - lda(AM_INDIRECT_Y); + lda(AM_IND_Y); break; case 0xb5: - lda(AM_ZERO_PAGE_X); + lda(AM_ZP_X); break; case 0xb9: - lda(AM_ABSOLUTE_Y); + lda(AM_ABS_Y); break; case 0xbd: - lda(AM_ABSOLUTE_X); + lda(AM_ABS_X); break; case 0xe8: inx();