--- nono/m88xx0/m88100subr.cpp 2026/04/29 17:04:34 1.1.1.2 +++ nono/m88xx0/m88100subr.cpp 2026/04/29 17:04:41 1.1.1.4 @@ -48,3 +48,50 @@ m88kcpu::SetVersion(uint32 version) "111-", // not used normally "LLLL", }; + +// 例外 +/*static*/ const char * const m88kcpu::exception_names[] = { + // 01234567890123456789012 <- 例外履歴欄の横幅 + /* 0 */ "Reset Exception", + /* 1 */ "Interrupt Exception", + /* 2 */ "Inst Access Exception", + /* 3 */ "Data Access Exception", + /* 4 */ "Misaligned Access Excep", + /* 5 */ "Unimplemented Opcode", + /* 6 */ "Priv. Violation Excep.", + /* 7 */ "Bounds Check Violation", + /* 8 */ "Illegal Integer Divide", + /* 9 */ "Int Overflow Exception", + /* 10 */ "Error Exception", + // 01234567890123456789012 +}; + +// 例外名を返す。 +// Reserved なところは NULL を返す。 +// XXX TODO 114 以降未実装 +/*static*/ const char * +m88kcpu::GetExceptionName(int vector) +{ + if (0 <= vector && vector < countof(exception_names)) { + return exception_names[vector]; + } + + // OpenBSD + // XXX 本来は OpenBSD 稼働時に限定すべきだろうけど、そうする意味もない + switch (vector) { + case 450: + return "OpenBSD system call"; + case 451: + return "OpenBSD cache flush"; + case 503: + return "Division by zero in GCC"; + case 504: + return "OpenBSD stepbpt"; + case 511: + return "OpenBSD userbpt"; + default: + break; + } + + return NULL; +}