From 9e2ce013ebcf17846f84549357b5715a48df659b Mon Sep 17 00:00:00 2001 From: alekseiplusplus Date: Mon, 27 Mar 2023 20:25:33 +1100 Subject: +special debug commands, +instruction data --- debug.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'debug.c') diff --git a/debug.c b/debug.c index ec6a75a..4e0b270 100644 --- a/debug.c +++ b/debug.c @@ -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; -- cgit v1.2.3