diff options
Diffstat (limited to '')
-rw-r--r-- | sources/main.c (renamed from main.c) | 23 |
1 files changed, 15 insertions, 8 deletions
@@ -281,13 +281,11 @@ void _c8_loop(chip8* c8, bool disasm, u16 from, u16 len) if(disasm) c8->pc = pc; } -void c8_disam(chip8* c8, u16 from, u16 len) { _c8_loop(c8, true, from, len); } -void c8_loop(chip8* c8) { _c8_loop(c8, false, 0, 0); } - int main(int argc, char** argv) { - FILE* f = NULL; + u64 sz = 0; + FILE* f = NULL; chip8 c8 = {0}; srand(time(NULL)); @@ -296,7 +294,7 @@ int main(int argc, char** argv) if(argc > 1) { - u64 sz, got = 0; + u64 got = 0; f = fopen(argv[1], "r"); if(!f) return 1; @@ -331,13 +329,22 @@ int main(int argc, char** argv) c8.RAM[C8_RESET_VECTOR + iota] = 0x12; c8.RAM[C8_RESET_VECTOR + iota] = 0x04; + + sz = iota; } printf("Disasm:\n"); - c8_disam(&c8, C8_RESET_VECTOR, 32); + { + u64 i; + char buf[512] = {0}; - printf("\nExec:\n"); - c8_loop(&c8); + for(i = 0; i < sz; i += 2) + { + u16 pc = C8_RESET_VECTOR + i; + c8_disasm(c8.RAM, pc, buf); + printf("%04X: %s\n", pc, buf); + } + } return 0; } |