X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fdebug.c;h=46161777fc5b6ff3c1a60bfc26012f40c0c9a4f6;hb=HEAD;hp=d6220c016fcfd4c4407c7d5f437af915cfcb5a1a;hpb=c01146f8ecd395bfcdeb8af3b50f8a9ab2b87488;p=mdlife diff --git a/src/debug.c b/src/debug.c index d6220c0..4616177 100644 --- a/src/debug.c +++ b/src/debug.c @@ -73,3 +73,45 @@ void dbg_putchar(int c) dbg_printchar(cur_x++, cur_y, c); } } + +static const char *exc_str[] = { + "unknown", "", + "bus error", + "address error", + "illegal instruction", + "divide by zero", + "chk", + "trap", + "priviledge violation", + "trace", + "op 1010", + "op 1111", + "", "", + "format error", + "uninitialized vector", + "", "", "", "", "", "", "", "", + "spurious interrupt" +}; + +struct frame { + uint16_t padding; + uint16_t status; + uint32_t pc; + /* group 2 */ + uint16_t fmtoffs; + uint16_t other[1]; +} __attribute__((packed)); + +void exc_dump(unsigned int num, struct frame *frm) +{ + dbg_setcursor(1, 1); + + if(num < sizeof exc_str / sizeof *exc_str) { + printf("Exception %xh: %s\n", num, exc_str[num]); + } else { + printf("Exception %xh\n", num); + } + + printf("status: %x\n", frm->status); + printf("pc: %x\n", frm->pc); +}