diff --git a/bin/emu b/bin/emu index c5cee12..0157dea 100755 Binary files a/bin/emu and b/bin/emu differ diff --git a/obj/cpu.o b/obj/cpu.o index 0aad6a6..5804503 100644 Binary files a/obj/cpu.o and b/obj/cpu.o differ diff --git a/src/cpu.c b/src/cpu/cpu.c similarity index 89% rename from src/cpu.c rename to src/cpu/cpu.c index e2b8aef..52e8135 100644 --- a/src/cpu.c +++ b/src/cpu/cpu.c @@ -18,10 +18,16 @@ #include #include +#define test(x) \ + print_##x(x) + long cpu_clock = 0; void cpu_step_to(long cycle) { cpu_clock = cycle; printf("Clock: %ld", cpu_clock); + + test(f); + // test("b"); } diff --git a/src/cpu.h b/src/cpu/cpu.h similarity index 100% rename from src/cpu.h rename to src/cpu/cpu.h diff --git a/src/cpu/op.c b/src/cpu/op.c new file mode 100644 index 0000000..b10ebc6 --- /dev/null +++ b/src/cpu/op.c @@ -0,0 +1,26 @@ +#include "op.h" + +#define IS_ALU_OP_CODE_(op, offset) \ + case op + offset: \ + op_##op(); \ + break; + +#define IS_ALU_OP_CODE(op) \ + IS_ALU_OP_CODE_(op, 0x01) \ + IS_ALU_OP_CODE_(op, 0x05) \ + IS_ALU_OP_CODE_(op, 0x09) \ + IS_ALU_OP_CODE_(op, 0x0d) \ + IS_ALU_OP_CODE_(op, 0x11) \ + IS_ALU_OP_CODE_(op, 0x15) \ + IS_ALU_OP_CODE_(op, 0x19) \ + IS_ALU_OP_CODE_(op, 0x1d) + +void process_op_code(int op) { + switch (op) { + IS_ALU_OP_CODE(AND) + } +} + +void op_AND() { + +} diff --git a/src/cpu/op.h b/src/cpu/op.h new file mode 100644 index 0000000..c8f08a4 --- /dev/null +++ b/src/cpu/op.h @@ -0,0 +1,10 @@ +enum op_code { + ORA = 0x00, + AND = 0x20, + EOR = 0x40, + ADC = 0x60, + STA = 0x80, + LDA = 0xa0, + CMP = 0xc0, + SBC = 0xe0 +}; diff --git a/src/main.c b/src/main.c index 8ff18da..212163f 100644 --- a/src/main.c +++ b/src/main.c @@ -17,7 +17,7 @@ */ #include -#include "cpu.h" +#include "cpu/cpu.h" long master_clock = 0;