Hi all.
Just getting started on my emulator, so I'm working on the CPU at the minute. I'm not sure if I'm understanding the addressing modes right though...
Would the following be right to calculate operand addresses?
I'm accessing RAM directly for zero page accesses, and cpu_read is my standard IO function.
Thanks for any help/suggestions you can give
Just getting started on my emulator, so I'm working on the CPU at the minute. I'm not sure if I'm understanding the addressing modes right though...
Would the following be right to calculate operand addresses?
Code:
#define ADDR_ZP (ram[g_cpu.pc++])
#define ADDR_ZPX (ram[g_cpu.pc++] + g_cpu.x)
#define ADDR_ZPY (ram[g_cpu.pc++] + g_cpu.y)
#define ADDR_ABS (cpu_read(g_cpu.pc++) | (cpu_read(g_cpu.pc++) << 8))
#define ADDR_ABSX ((cpu_read(g_cpu.pc++) | ((cpu_read(g_cpu.pc++) << 8))) + g_cpu.x)
#define ADDR_ABSY ((cpu_read(g_cpu.pc++) | ((cpu_read(g_cpu.pc++) << 8))) + g_cpu.y)
#define ADDR_INDX ((cpu_read(g_cpu.pc++ + g_cpu.x)) | (cpu_read(g_cpu.pc++) << 8))
#define ADDR_INDY ((cpu_read(g_cpu.pc++)) | ((cpu_read(g_cpu.pc++) << 8) + g_cpu.y)))
#define ADDR_ZPX (ram[g_cpu.pc++] + g_cpu.x)
#define ADDR_ZPY (ram[g_cpu.pc++] + g_cpu.y)
#define ADDR_ABS (cpu_read(g_cpu.pc++) | (cpu_read(g_cpu.pc++) << 8))
#define ADDR_ABSX ((cpu_read(g_cpu.pc++) | ((cpu_read(g_cpu.pc++) << 8))) + g_cpu.x)
#define ADDR_ABSY ((cpu_read(g_cpu.pc++) | ((cpu_read(g_cpu.pc++) << 8))) + g_cpu.y)
#define ADDR_INDX ((cpu_read(g_cpu.pc++ + g_cpu.x)) | (cpu_read(g_cpu.pc++) << 8))
#define ADDR_INDY ((cpu_read(g_cpu.pc++)) | ((cpu_read(g_cpu.pc++) << 8) + g_cpu.y)))
I'm accessing RAM directly for zero page accesses, and cpu_read is my standard IO function.
Thanks for any help/suggestions you can give