--- nono/m88xx0/m88100subr.cpp 2026/04/29 17:04:44 1.1.1.5 +++ nono/m88xx0/m88100subr.cpp 2026/04/29 17:05:07 1.1.1.10 @@ -7,12 +7,37 @@ #include "m88100.h" // コンストラクタ -m88kcpu::m88kcpu(uint32 reset_vector_) +m88kcpu::m88kcpu(MPU88xx0Device *dev_) { - reset_vector = reset_vector_; + dev = dev_; cmmu[0].Ctor(this); cmmu[1].Ctor(this); + + // レジスタのうち不定と明記されてるものは、未初期化のまま触ったことが + // 分かりやすいような適当なパターンで埋めておく。ただし最上位も c に + // すると BT454 のレジスタ付近を指してしまうので、それは避けておく。 + // XXX Super Reset が出来たらそっちに移動? + const uint32 Undefined = 0x0ccccccc; + for (int i = 1; i < 32; i++) { + r[i] = Undefined; + } + for (int i = 0; i < countof(fcr); i++) { + fcr[i] = Undefined & fcr_mask[i]; + } + + epsr = Undefined; + ssbr = Undefined; + sfip = Undefined; + snip = Undefined; + sxip = Undefined; + // DMTx は bit0(Valid) をクリア。DMAx/DMDx は不定。 + dma0 = Undefined; + dma1 = Undefined; + dma2 = Undefined; + dmd0 = Undefined; + dmd1 = Undefined; + dmd2 = Undefined; } // デストラクタ @@ -20,6 +45,14 @@ m88kcpu::~m88kcpu() { } +// DOS call エミュレーションのコールバックを設定 +void +m88kcpu::SetFLineCallback(bool (*callback)(m88kcpu *, void *), void *arg) +{ + fline_callback = callback; + fline_arg = arg; +} + // PID の VERSION フィールドをセットする。初期化時に呼ぶ。 void m88kcpu::SetVersion(uint32 version) @@ -28,6 +61,21 @@ m88kcpu::SetVersion(uint32 version) pid |= version << 1; } +// fcr のマスク +/*static*/ const uint32 m88100reg::fcr_mask[11] = { + FPECR_MASK, + 0xffffffff, // fphs1 + 0xffffffff, // fpls1 + 0xffffffff, // fphs2 + 0xffffffff, // fpls2 + FPPT_MASK, + FPRH_MASK, + 0xffffffff, // fprl + FPIT_MASK, + FPSR_MASK, + FPCR_MASK, +}; + /*static*/ const char * const m88100reg::sipname[3] = { "sxip", "snip", "sfip", }; @@ -50,50 +98,3 @@ 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; -}