summaryrefslogtreecommitdiff
path: root/debug.c
diff options
context:
space:
mode:
authoralekseiplusplus <alekseijeaves@protonmail.com>2023-03-27 20:25:33 +1100
committeralekseiplusplus <alekseijeaves@protonmail.com>2023-03-27 20:25:33 +1100
commit9e2ce013ebcf17846f84549357b5715a48df659b (patch)
tree596fdbe78a8201151bf06ff895a0c09af707f683 /debug.c
parentcd50e11648971a3fbdc3936839f4a5401e3a9d29 (diff)
+special debug commands, +instruction data
Diffstat (limited to 'debug.c')
-rw-r--r--debug.c22
1 files changed, 20 insertions, 2 deletions
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;