diff options
author | alekseiplusplus <alekseijeaves@protonmail.com> | 2023-03-27 20:25:33 +1100 |
---|---|---|
committer | alekseiplusplus <alekseijeaves@protonmail.com> | 2023-03-27 20:25:33 +1100 |
commit | 9e2ce013ebcf17846f84549357b5715a48df659b (patch) | |
tree | 596fdbe78a8201151bf06ff895a0c09af707f683 /debug.c | |
parent | cd50e11648971a3fbdc3936839f4a5401e3a9d29 (diff) |
+special debug commands, +instruction data
Diffstat (limited to 'debug.c')
-rw-r--r-- | debug.c | 22 |
1 files changed, 20 insertions, 2 deletions
@@ -4,7 +4,7 @@ * Note that zero-page addressing is not fully emulated yet; it will still address the zero-page section of memory but the instructions still take an address of length 4. This will be fixed later when the whole system is functional. - * + * There are a few special keywords which have particular debugging meaning */ #include"include.h" @@ -17,12 +17,30 @@ int charToNum (char c, int mul) { } } +void debug_print(){ + printf("\nacc:\t%x\nX:\t%x\nY:\t%x\nstack:\t%x\nflags:\t%x", acc, X, Y, S, P); +} + int main(){ char c; unsigned char a, b; while(true){ // Pass 1 - c = getchar(); if (c == EOF) break; + c = getchar(); + if (c == EOF) break; + switch(c){ + case D: case d: + debug_print(); + break; + case M: case m: + int m = 0; + for(int i = 1; i <= 1000; i *= 10){ + m += charToNum(getchar(), 1000/i); + } + printf("Address %d has %x", m, Memory[m]); + break; + + } a += charToNum(c, 0x10); // Pass 2 c = getchar(); if (c == EOF) break; |