--- nono/debugger/debugger_m88xx0.cpp 2026/04/29 17:05:24 1.1.1.11 +++ nono/debugger/debugger_m88xx0.cpp 2026/04/29 17:05:49 1.1.1.15 @@ -192,7 +192,7 @@ DebuggerMD_m88xx0::GetRegAddr(const char if (strcmp(name, "sr3") == 0) return cpu->reg.sr[3]; for (int i = 0; i < countof(cpu->reg.cr); i++) { - snprintf(buf, sizeof(buf), "cr%d", i); + snprintf(buf, sizeof(buf), "cr%u", i); if (strcmp(name, buf) == 0) { return cpu->reg.cr[i]; } @@ -203,7 +203,7 @@ DebuggerMD_m88xx0::GetRegAddr(const char // 通常レジスタ for (int i = 0; i < countof(cpu->reg.r); i++) { - snprintf(buf, sizeof(buf), "r%d", i); + snprintf(buf, sizeof(buf), "r%u", i); if (strcmp(name, buf) == 0) { return cpu->reg.r[i]; } @@ -329,7 +329,7 @@ DebuggerMD_m88xx0::ShowRegister(FILE *co if (MatchCMMUCmd(args[0], "ra", &cmmu_id)) { Monitor *mon = gMonitorManager->Find(ID_MONITOR_ATC(cmmu_id)); if (mon) { - parent->ShowMonitor(*mon); + parent->ShowMonitor(mon); return true; } goto notfound; @@ -340,7 +340,7 @@ DebuggerMD_m88xx0::ShowRegister(FILE *co if (MatchCMMUCmd(args[0], "rm", &cmmu_id)) { Monitor *mon = gMonitorManager->Find(ID_MONITOR_CMMU(cmmu_id)); if (mon) { - parent->ShowMonitor(*mon); + parent->ShowMonitor(mon); return true; } goto notfound; @@ -408,8 +408,8 @@ r2 :0070e1a0 r10:00000000 r18:00000000 int y = 0; uint32 res = cpu->reg.r[cmp_rd]; for (int b = 11; b >= 2; b--) { - s.Print(57 + x * 7, y, "%x:%s=%d", b, cmpstr[b], - (res & (1 << b)) ? 1 : 0); + s.Print(57 + x * 7, y, "%x:%s=%u", b, cmpstr[b], + (res & (1U << b)) ? 1 : 0); x++; if (x > 2) { x = 0; @@ -496,7 +496,7 @@ fip:00000000 sfip(cr6 // S*IP x = 32; for (int i = 0; i < 3; i++) { - s.Print(x, y + i, TSBOLDC(cr[4 + i]), "%s(cr%d):%08x:%c%c", + s.Print(x, y + i, TSBOLDC(cr[4 + i]), "%s(cr%u):%08x:%c%c", m88100reg::sipname[i], 4 + i, (cpu->reg.cr[4 + i] & M88100::SIP_MASK), (cpu->reg.cr[4 + i] & M88100::SIP_V) ? 'V' : '-', @@ -508,7 +508,7 @@ fip:00000000 sfip(cr6 // SR* for (int i = 0; i < 4; i++) { int rn = 17 + i; - s.Print(x, y++, TSBOLDC(cr[rn]), "sr%d(cr%d):%08x", + s.Print(x, y++, TSBOLDC(cr[rn]), "sr%u(cr%u):%08x", i, rn, cpu->reg.cr[rn]); } // ssbr(cr3) @@ -542,11 +542,11 @@ DebuggerMD_m88xx0::ShowRegCache(FILE *co errno = 0; set = strtol(args[1].c_str(), &end, 16); if (end == &args[1][0] || *end != '\0' || errno == ERANGE) { - fprintf(cons, " must be a number\n"); + fprintf(cons, " must be a number.\n"); goto done; } if (set < 0 || set > 256) { - fprintf(cons, " must be in 00..ff\n"); + fprintf(cons, " must be in 00..ff.\n"); goto done; } ShowRegCacheSet(cmmu, set); @@ -593,9 +593,9 @@ DebuggerMD_m88xx0::ShowRegFPU() }; TextScreen s(80, 4); - for (int i = 0; i < 9; i++) { + for (uint i = 0; i < 9; i++) { s.Print((i / 4) * 22, i % 4, TSBOLDC(fcr[i]), - "%-5s(fcr%d):%08x", fcrname[i], i, cpu->reg.fcr[i]); + "%-5s(fcr%u):%08x", fcrname[i], i, cpu->reg.fcr[i]); } s.Print(44, 2, TSBOLDC(fpsr), "fpsr(fcr62):%08x", cpu->reg.fpsr); @@ -615,12 +615,12 @@ dmt0(cr8) :0000(B,S,D,L,Rxx,S,---B,W,V) dmt0(cr11):0000(B,U,D,L,Rxx,S,HH--,W,V) dmd0(cr9) :00000000 dma0(cr10):00000000 dmt0(cr14):0000(B, ,D,L,Rxx,S,LLLL,W,V) dmd0(cr9) :00000000 dma0(cr10):00000000 */ - for (int i = 0; i <= 2; i++) { - int dt = 8 + i * 3; - int dd = 9 + i * 3; - int da = 10 + i * 3; + for (uint i = 0; i <= 2; i++) { + uint dt = 8 + i * 3; + uint dd = 9 + i * 3; + uint da = 10 + i * 3; - s.Print(0, i, TSBOLDC(cr[dt]), "dmt%d(cr%-2d):%04x", + s.Print(0, i, TSBOLDC(cr[dt]), "dmt%u(cr%-2u):%04x", i, dt, (cpu->reg.cr[dt] & 0xffff)); s.Print(15, i, "(b,s,d,l,rx, s,en ,w,v)"); PRINT_B(16, i, cr[dt], M88100::DM_BO, "%c", _new ? 'B' : '-'); @@ -628,7 +628,7 @@ dmt0(cr14):0000(B, ,D,L,Rxx,S,LLLL,W,V) PRINT_B(20, i, cr[dt], M88100::DM_DOUB1, "%c", _new ? 'D' : '-'); PRINT_B(22, i, cr[dt], M88100::DM_LOCK, "%c", _new ? 'L' : '-'); // カンマを前詰め。かつ DREG がボールドでもカンマはボールドにしない - PRINT_B(24, i, cr[dt], M88100::DM_DREG_MASK, "r%d", _new >> 7); + PRINT_B(24, i, cr[dt], M88100::DM_DREG_MASK, "r%u", _new >> 7); s.Puts(","); PRINT_B(28, i, cr[dt], M88100::DM_SIGNED, "%c", _new ? 'S' : '-'); PRINT_B(30, i, cr[dt], M88100::DM_EN_MASK,"%s", @@ -636,9 +636,9 @@ dmt0(cr14):0000(B, ,D,L,Rxx,S,LLLL,W,V) PRINT_B(35, i, cr[dt], M88100::DM_WRITE, "%c", _new ? 'W' : '-'); PRINT_B(37, i, cr[dt], M88100::DM_VALID, "%c", _new ? 'V' : '-'); - s.Print(40, i, TSBOLDC(cr[dd]), "dmd%d(cr%-2d):%08x", + s.Print(40, i, TSBOLDC(cr[dd]), "dmd%u(cr%-2u):%08x", i, dd, cpu->reg.cr[dd]); - s.Print(60, i, TSBOLDC(cr[dd]), "dma%d(cr%2d):%08x", + s.Print(60, i, TSBOLDC(cr[dd]), "dma%u(cr%2u):%08x", i, da, cpu->reg.cr[da]); } @@ -651,7 +651,7 @@ DebuggerMD_m88xx0::Disassemble(DebuggerM { m88100disasm dis; if (dis.Exec(&mem) == false) { - return "dis.Exec() failed"; + return "dis.Exec() failed."; } // ニーモニック @@ -659,11 +659,7 @@ DebuggerMD_m88xx0::Disassemble(DebuggerM // 別名追加 if (!dis.alttext.empty()) { int len = mnemonic.length() % 8; - if (len < 8) { - mnemonic += std::string(8 - len, ' '); - } else { - mnemonic += ' '; - } + mnemonic += std::string(8 - len, ' '); mnemonic += dis.alttext; } @@ -675,12 +671,12 @@ DebuggerMD_m88xx0::Disassemble(DebuggerM const auto& e = brhist->entry[brhist->top]; if (e.from + 4 == cpu->reg.xip) { // 直前の位置にあるブランチが遅延ブランチかどうか調べる - if ((e.inst & 0xfc000000) == 0xf4000000) { + if ((e.info & 0xfc000000) == 0xf4000000) { // jmp, jsr - delay = (e.inst >> 10) & 1; - } else if (0xc0000000 <= e.inst && e.inst < 0xfc000000) { + delay = (e.info >> 10) & 1; + } else if (0xc0000000 <= e.info && e.info < 0xfc000000) { // br, bsr, bcnd - delay = (e.inst >> 26) & 1; + delay = (e.info >> 26) & 1; } } } @@ -720,7 +716,7 @@ DebuggerMD_m88xx0::CondStr(uint32 op) // rS の bit B が %0 ならブランチ/トラップ cmp_rd = -1; uint32 b = m88100opf_B5(op); - TAKE_IF((cpu->reg.r[s] & (1 << b)) == 0); + TAKE_IF((cpu->reg.r[s] & (1U << b)) == 0); } if (IsBB1(op)) { // 11011N BBBBB SSSSS dddddd dd dddddddd bb1 @@ -731,7 +727,7 @@ DebuggerMD_m88xx0::CondStr(uint32 op) return " (nop)"; } uint32 b = m88100opf_B5(op); - TAKE_IF((cpu->reg.r[s] & (1 << b)) != 0); + TAKE_IF((cpu->reg.r[s] & (1U << b)) != 0); } if (IsTB1(op)) { // 111100 BBBBB SSSSS 110110 0V VVVVVVVV tb1 @@ -743,7 +739,7 @@ DebuggerMD_m88xx0::CondStr(uint32 op) return ""; } uint32 b = m88100opf_B5(op); - TAKE_IF((cpu->reg.r[s] & (1 << b)) != 0); + TAKE_IF((cpu->reg.r[s] & (1U << b)) != 0); } if ((op & 0xf8000000) == 0xe8000000 || // bcnd (op & 0xfc00fe00) == 0xf000e800) // tcnd @@ -771,3 +767,13 @@ DebuggerMD_m88xx0::CondStr(uint32 op) return ""; } + +// 命令ニーモニックに対するバイナリを文字列形式で返す。 +// 対応しない場合は "" を返す。cmd_bi 用。 +std::string +DebuggerMD_m88xx0::ParseInst(const std::string& inst) const +{ + if (inst == "rte") return "f400fc00"; + + return ""; +}