From 48d137954cea666083277d1b667a3ceb52a1c93a Mon Sep 17 00:00:00 2001 From: Dirk Hoffmann Date: Fri, 6 Jan 2023 11:49:07 +0100 Subject: [PATCH] Disassembler cleanup --- Emulator/CPU/CPU.cpp | 14 +- Emulator/CPU/Moira/Moira.h | 26 ++-- Emulator/CPU/Moira/MoiraDasm.h | 7 +- Emulator/CPU/Moira/MoiraDasmFPU_cpp.h | 90 ++++++------ Emulator/CPU/Moira/MoiraDasmMMU_cpp.h | 12 +- Emulator/CPU/Moira/MoiraDasm_cpp.h | 189 +++++++++++++++----------- Emulator/CPU/Moira/MoiraDebugger.cpp | 2 +- 7 files changed, 188 insertions(+), 152 deletions(-) diff --git a/Emulator/CPU/CPU.cpp b/Emulator/CPU/CPU.cpp index 07c860a70..574bc1361 100644 --- a/Emulator/CPU/CPU.cpp +++ b/Emulator/CPU/CPU.cpp @@ -694,7 +694,7 @@ CPU::disassembleRecordedFlags(isize i) { static char result[18]; - disassembleSR(debugger.logEntryAbs((int)i).sr, result); + disassembleSR(result, debugger.logEntryAbs((int)i).sr); return result; } @@ -702,8 +702,8 @@ const char * CPU::disassembleRecordedPC(isize i) { static char result[16]; - - Moira::disassemblePC(debugger.logEntryAbs((int)i).pc0, result); + + Moira::dump24(result, debugger.logEntryAbs((int)i).pc0); return result; } @@ -712,7 +712,7 @@ CPU::disassembleAddr(u32 addr) { static char result[16]; - Moira::disassemblePC(addr, result); + Moira::dump24(result, addr); return result; } @@ -721,7 +721,7 @@ CPU::disassembleWord(u16 value) { static char result[16]; - Moira::disassembleWord(value, result); + Moira::dump16(result, value); return result; } @@ -730,7 +730,7 @@ CPU::disassembleInstr(u32 addr, isize *len) { static char result[128]; - int l = disassemble(addr, result); + int l = disassemble(result, addr); if (len) *len = (isize)l; return result; @@ -741,7 +741,7 @@ CPU::disassembleWords(u32 addr, isize len) { static char result[64]; - disassembleMemory(addr, (int)len, result); + dump16(result, addr, len); return result; } diff --git a/Emulator/CPU/Moira/Moira.h b/Emulator/CPU/Moira/Moira.h index 67397cb67..f38ff594d 100644 --- a/Emulator/CPU/Moira/Moira.h +++ b/Emulator/CPU/Moira/Moira.h @@ -230,21 +230,21 @@ class Moira : public SubComponent { public: // Disassembles a single instruction and returns the instruction size - int disassemble(u32 addr, char *str) const; + int disassemble(char *str, u32 addr) const; // Creates a textual representation for the status register - void disassembleSR(char *str) const { disassembleSR(reg.sr, str); } - void disassembleSR(const StatusRegister &sr, char *str) const; - - // Returns a textual representation for a single word - void disassembleWord(u32 value, char *str) const; - - // Returns a textual representation for one or more words from memory - void disassembleMemory(u32 addr, int cnt, char *str) const; - - // Returns a textual representation for the program counter - void disassemblePC(char *str) const { disassemblePC(reg.pc, str); } - void disassemblePC(u32 pc, char *str) const; + void disassembleSR(char *str) const { disassembleSR(str, reg.sr); } + void disassembleSR(char *str, const StatusRegister &sr) const; + + // Creates a textual representation for a single data value + void dump8(char *str, u8 value) const; + void dump16(char *str, u16 value) const; + void dump24(char *str, u32 value) const; + void dump32(char *str, u32 value) const; + + // Creates a textual representation for multiple data values + void dump16(char *str, u16 values[], isize cnt) const; + void dump16(char *str, u32 addr, isize cnt) const; // Return an info struct for a certain opcode InstrInfo getInfo(u16 op) const; diff --git a/Emulator/CPU/Moira/MoiraDasm.h b/Emulator/CPU/Moira/MoiraDasm.h index 8e274e646..9fb79412f 100644 --- a/Emulator/CPU/Moira/MoiraDasm.h +++ b/Emulator/CPU/Moira/MoiraDasm.h @@ -9,8 +9,11 @@ // Auxiliary functions // -// Reads a word from memory and increments addr -template u32 dasmRead(u32 &addr) const; +// Reads a data value from memory without side-effects +template u32 dasmRead(u32 addr) const; + +// Increments addr and reads a data value from memory without side-effects +template u32 dasmIncRead(u32 &addr) const; // Assembles an operand template EaOp(u16 reg, u32 &pc) const; diff --git a/Emulator/CPU/Moira/MoiraDasmFPU_cpp.h b/Emulator/CPU/Moira/MoiraDasmFPU_cpp.h index aa4aeff78..1b262000b 100644 --- a/Emulator/CPU/Moira/MoiraDasmFPU_cpp.h +++ b/Emulator/CPU/Moira/MoiraDasmFPU_cpp.h @@ -12,7 +12,7 @@ template void Moira::dasmFGen(StrWriter &str, u32 &addr, u16 op) const { - auto ext = dasmRead(addr); + auto ext = dasmIncRead(addr); auto cod = xxx_____________(ext); auto cmd = _________xxxxxxx(ext); addr -= 2; @@ -128,7 +128,7 @@ template void Moira::dasmFBcc(StrWriter &str, u32 &addr, u16 op) const { auto old = addr; - auto ext = dasmRead(addr); + auto ext = dasmIncRead(addr); auto cnd = ___________xxxxx (op); // Check for special FNOP opcode @@ -152,7 +152,7 @@ template void Moira::dasmFDbcc(StrWriter &str, u32 &addr, u16 op) const { auto old = addr; - auto ext = dasmRead(addr); + auto ext = dasmIncRead(addr); auto src = _____________xxx (op); auto cnd = ___________xxxxx (ext); @@ -165,7 +165,7 @@ Moira::dasmFDbcc(StrWriter &str, u32 &addr, u16 op) const } auto dst = addr + 2; - U32_INC(dst, SEXT(dasmRead(addr))); + U32_INC(dst, SEXT(dasmIncRead(addr))); str << Ins{} << Fcc{cnd} << str.tab << Dn{src} << Sep{} << UInt(dst); } @@ -197,7 +197,7 @@ template void Moira::dasmFScc(StrWriter &str, u32 &addr, u16 op) const { auto old = addr; - auto ext = dasmRead(addr); + auto ext = dasmIncRead(addr); auto reg = _____________xxx (op); auto cnd = __________xxxxxx (ext); @@ -216,7 +216,7 @@ template void Moira::dasmFTrapcc(StrWriter &str, u32 &addr, u16 op) const { auto old = addr; - auto ext = dasmRead(addr); + auto ext = dasmIncRead(addr); auto cnd = __________xxxxxx (ext); // Catch illegal extension words @@ -237,7 +237,7 @@ Moira::dasmFTrapcc(StrWriter &str, u32 &addr, u16 op) const case Word: case Long: - str << Ins{} << Fcc{cnd} << Sz{} << str.tab << Ims(dasmRead(addr)); + str << Ins{} << Fcc{cnd} << Sz{} << str.tab << Ims(dasmIncRead(addr)); break; } } @@ -245,7 +245,7 @@ Moira::dasmFTrapcc(StrWriter &str, u32 &addr, u16 op) const template void Moira::dasmFGeneric(StrWriter &str, u32 &addr, u16 op) const { - auto ext = dasmRead(addr); + auto ext = dasmIncRead(addr); auto reg = _____________xxx (op); auto src = ___xxx__________ (ext); auto dst = ______xxx_______ (ext); @@ -260,34 +260,34 @@ Moira::dasmFGeneric(StrWriter &str, u32 &addr, u16 op) const case 0: // Long-Word Integer - val = dasmRead(addr); + val = dasmIncRead(addr); str << Ins{} << Ffmt{src} << str.tab << Ims(u32(val)); break; case 1: // Single precision - val = dasmRead(addr); + val = dasmIncRead(addr); str << Ins{} << Ffmt{src} << str.tab << "#"; break; case 2: // Double precision case 3: // Packed-Decimal Real - val = dasmRead(addr); - dasmRead(addr); - dasmRead(addr); // Why??? + val = dasmIncRead(addr); + dasmIncRead(addr); + dasmIncRead(addr); // Why??? str << Ins{} << Ffmt{src} << str.tab << "#"; break; case 5: // Double-precision real - val = dasmRead(addr); - dasmRead(addr); + val = dasmIncRead(addr); + dasmIncRead(addr); str << Ins{} << Ffmt{src} << str.tab << "#"; break; case 6: // Byte Integer - val = dasmRead(addr); + val = dasmIncRead(addr); str << Ins{} << Ffmt{src} << str.tab << Ims(u32(val)); break; @@ -308,7 +308,7 @@ Moira::dasmFGeneric(StrWriter &str, u32 &addr, u16 op) const template void Moira::dasmFGeneric2(StrWriter &str, u32 &addr, u16 op) const { - auto ext = dasmRead(addr); + auto ext = dasmIncRead(addr); auto reg = _____________xxx (op); auto src = ___xxx__________ (ext); auto dst = ______xxx_______ (ext); @@ -326,35 +326,35 @@ Moira::dasmFGeneric2(StrWriter &str, u32 &addr, u16 op) const case 0: // Long-Word Integer - val = dasmRead(addr); + val = dasmIncRead(addr); str << Ims(u32(val)); break; case 1: // Single precision - val = dasmRead(addr); + val = dasmIncRead(addr); str << "#"; break; case 2: // Double precision case 3: // Packed-Decimal Real - val = dasmRead(addr); - dasmRead(addr); - dasmRead(addr); // Why??? + val = dasmIncRead(addr); + dasmIncRead(addr); + dasmIncRead(addr); // Why??? str << "#"; break; case 5: // Double-precision real - val = dasmRead(addr); - dasmRead(addr); + val = dasmIncRead(addr); + dasmIncRead(addr); str << "#"; break; case 6: // Byte Integer - val = dasmRead(addr); + val = dasmIncRead(addr); str << Ims(u32(val)); break; @@ -375,7 +375,7 @@ Moira::dasmFGeneric2(StrWriter &str, u32 &addr, u16 op) const template void Moira::dasmFGeneric3(StrWriter &str, u32 &addr, u16 op) const { - auto ext = dasmRead(addr); + auto ext = dasmIncRead(addr); auto reg = _____________xxx (op); auto src = ___xxx__________ (ext); @@ -389,35 +389,35 @@ Moira::dasmFGeneric3(StrWriter &str, u32 &addr, u16 op) const case 0: // Long-Word Integer - val = dasmRead(addr); + val = dasmIncRead(addr); str << Ins{} << Ffmt{src} << str.tab << Ims(u32(val)); break; case 1: // Single precision - val = dasmRead(addr); + val = dasmIncRead(addr); str << Ins{} << Ffmt{src} << str.tab << "#"; break; case 2: // Double precision case 3: // Packed-Decimal Real - val = dasmRead(addr); - dasmRead(addr); - dasmRead(addr); // Why??? + val = dasmIncRead(addr); + dasmIncRead(addr); + dasmIncRead(addr); // Why??? str << Ins{} << Ffmt{src} << str.tab << "#"; break; case 5: // Double-precision real - val = dasmRead(addr); - dasmRead(addr); + val = dasmIncRead(addr); + dasmIncRead(addr); str << Ins{} << Ffmt{src} << str.tab << "#"; break; case 6: // Byte Integer - val = dasmRead(addr); + val = dasmIncRead(addr); str << Ins{} << Ffmt{src} << str.tab << Ims(u32(val)); break; @@ -437,7 +437,7 @@ template void Moira::dasmFMove(StrWriter &str, u32 &addr, u16 op) const { auto old = addr; - auto ext = dasmRead(addr); + auto ext = dasmIncRead(addr); auto reg = _____________xxx (op); auto cod = xxx_____________ (ext); auto src = ___xxx__________ (ext); @@ -479,34 +479,34 @@ Moira::dasmFMove(StrWriter &str, u32 &addr, u16 op) const switch (src) { case 0: // Long-Word Integer - val = dasmRead(addr); + val = dasmIncRead(addr); str << str.tab << Ims(u32(val)) << Sep{} << Fp(dst); break; case 1: // Single precision - val = dasmRead(addr); + val = dasmIncRead(addr); str << str.tab << "#" << Sep{} << Fp(dst); break; case 2: // Double precision case 3: // Packed-Decimal Real - val = dasmRead(addr); - dasmRead(addr); - dasmRead(addr); // Why??? + val = dasmIncRead(addr); + dasmIncRead(addr); + dasmIncRead(addr); // Why??? str << str.tab << "#" << Sep{} << Fp(dst); break; case 5: // Double-precision real - val = dasmRead(addr); - dasmRead(addr); + val = dasmIncRead(addr); + dasmIncRead(addr); str << str.tab << "#" << Sep{} << Fp(dst); break; case 6: // Byte Integer - val = dasmRead(addr); + val = dasmIncRead(addr); str << str.tab << Ims(u32(val)) << Sep{} << Fp(dst); break; @@ -547,7 +547,7 @@ template void Moira::dasmFMovecr(StrWriter &str, u32 &addr, u16 op) const { auto old = addr; - auto ext = dasmRead(addr); + auto ext = dasmIncRead(addr); auto dst = ______xxx_______ (ext); auto ofs = _________xxxxxxx (ext); @@ -569,7 +569,7 @@ template void Moira::dasmFMovem(StrWriter &str, u32 &addr, u16 op) const { auto old = addr; - auto ext = dasmRead(addr); + auto ext = dasmIncRead(addr); auto reg = _____________xxx (op); auto cod = xxx_____________ (ext); auto mod = ___xx___________ (ext); diff --git a/Emulator/CPU/Moira/MoiraDasmMMU_cpp.h b/Emulator/CPU/Moira/MoiraDasmMMU_cpp.h index a26533b6f..c1e2f31d7 100644 --- a/Emulator/CPU/Moira/MoiraDasmMMU_cpp.h +++ b/Emulator/CPU/Moira/MoiraDasmMMU_cpp.h @@ -10,7 +10,7 @@ template void Moira::dasmPGen(StrWriter &str, u32 &addr, u16 op) const { - auto ext = dasmRead(addr); + auto ext = dasmIncRead(addr); addr -= 2; // PLOAD: 0010 00x0 000x xxxx @@ -55,7 +55,7 @@ template void Moira::dasmPFlush(StrWriter &str, u32 &addr, u16 op) const { auto old = addr; - auto ext = dasmRead(addr); + auto ext = dasmIncRead(addr); auto reg = _____________xxx (op); auto mode = ___xxx__________ (ext); auto mask = _______xxxx_____ (ext); @@ -84,7 +84,7 @@ template void Moira::dasmPFlusha(StrWriter &str, u32 &addr, u16 op) const { auto old = addr; - auto ext = dasmRead(addr); + auto ext = dasmIncRead(addr); // Catch illegal extension words if (str.style.syntax == DASM_GNU || str.style.syntax == DASM_GNU_MIT) { @@ -119,7 +119,7 @@ template void Moira::dasmPLoad(StrWriter &str, u32 &addr, u16 op) const { auto old = addr; - auto ext = dasmRead(addr); + auto ext = dasmIncRead(addr); auto ea = Op ( _____________xxx(op), addr ); // Catch illegal extension words @@ -141,7 +141,7 @@ template void Moira::dasmPMove(StrWriter &str, u32 &addr, u16 op) const { auto old = addr; - auto ext = dasmRead(addr); + auto ext = dasmIncRead(addr); auto reg = _____________xxx (op); auto fmt = xxx_____________ (ext); auto preg = ___xxx__________ (ext); @@ -223,7 +223,7 @@ template void Moira::dasmPTest(StrWriter &str, u32 &addr, u16 op) const { auto old = addr; - auto ext = dasmRead(addr); + auto ext = dasmIncRead(addr); auto reg = _____________xxx (op); auto lev = ___xxx__________ (ext); auto rw = ______x_________ (ext); diff --git a/Emulator/CPU/Moira/MoiraDasm_cpp.h b/Emulator/CPU/Moira/MoiraDasm_cpp.h index 4fb0b90ae..5a68b41a1 100644 --- a/Emulator/CPU/Moira/MoiraDasm_cpp.h +++ b/Emulator/CPU/Moira/MoiraDasm_cpp.h @@ -6,7 +6,7 @@ // ----------------------------------------------------------------------------- int -Moira::disassemble(u32 addr, char *str) const +Moira::disassemble(char *str, u32 addr) const { if constexpr (ENABLE_DASM == false) { throw std::runtime_error("This feature requires ENABLE_DASM = true\n"); @@ -46,7 +46,7 @@ Moira::disassemble(u32 addr, char *str) const } void -Moira::disassembleSR(const StatusRegister &sr, char *str) const +Moira::disassembleSR(char *str, const StatusRegister &sr) const { str[0] = sr.t1 ? 'T' : 't'; str[1] = sr.t0 ? 'T' : 't'; @@ -68,44 +68,77 @@ Moira::disassembleSR(const StatusRegister &sr, char *str) const } void -Moira::disassembleWord(u32 value, char *str) const +Moira::dump8(char *str, u8 value) const { - StrWriter(str, dataStyle) << UInt32{u32(value)} << Finish{}; + StrWriter(str, dataStyle) << UInt8{value} << Finish{}; } void -Moira::disassembleMemory(u32 addr, int cnt, char *str) const +Moira::dump16(char *str, u16 value) const { - U32_DEC(addr, 2); // Because dasmRead increases addr first + StrWriter(str, dataStyle) << UInt16{value} << Finish{}; +} + +void +Moira::dump24(char *str, u32 value) const +{ + StrWriter(str, dataStyle) << UInt24{value} << Finish{}; +} + +void +Moira::dump32(char *str, u32 value) const +{ + StrWriter(str, dataStyle) << UInt32{value} << Finish{}; +} +void +Moira::dump16(char *str, u16 values[], isize cnt) const +{ StrWriter writer(str, dataStyle); for (int i = 0; i < cnt; i++) { for (isize j = 0; i && j < dataStyle.tab; j++) writer << ' '; - writer << UInt16{u16(dasmRead(addr))} << Finish{}; + writer << UInt16{values[i]} << Finish{}; } } void -Moira::disassemblePC(u32 pc, char *str) const +Moira::dump16(char *str, u32 addr, isize cnt) const { - StrWriter(str, dataStyle) << UInt24{pc} << Finish{}; + StrWriter writer(str, dataStyle); + + for (int i = 0; i < cnt; i++) { + + for (isize j = 0; i && j < dataStyle.tab; j++) writer << ' '; + writer << UInt16{u16(dasmRead(addr))} << Finish{}; + U32_INC(addr, 2); + } } template u32 -Moira::dasmRead(u32 &addr) const +Moira::dasmRead(u32 addr) const { switch (S) { - case Byte: + case Long: + + return dasmRead(addr) << 16 | dasmRead(U32_ADD(addr, 2)); - U32_INC(addr, 2); - return read16Dasm(addr) & 0xFF; + default: + + return read16Dasm(addr); + } +} + +template u32 +Moira::dasmIncRead(u32 &addr) const +{ + switch (S) { case Long: - return dasmRead(addr) << 16 | dasmRead(addr); + return dasmIncRead(addr) << 16 | dasmIncRead(addr); default: @@ -128,19 +161,19 @@ Moira::Op(u16 reg, u32 &pc) const case 7: // ABS.W case 9: // (d,PC) { - result.ext1 = dasmRead(pc); + result.ext1 = dasmIncRead(pc); break; } case 8: // ABS.L { - result.ext1 = dasmRead(pc); - result.ext1 = result.ext1 << 16 | dasmRead(pc); + result.ext1 = dasmIncRead(pc); + result.ext1 = result.ext1 << 16 | dasmIncRead(pc); break; } case 6: // (d,An,Xi) case 10: // (d,PC,Xi) { - result.ext1 = dasmRead(pc); + result.ext1 = dasmIncRead(pc); result.ext2 = 0; result.ext3 = 0; @@ -155,16 +188,16 @@ Moira::Op(u16 reg, u32 &pc) const result.ow = 0; } - if (result.dw == 1) result.ext2 = (i16)dasmRead(pc); - if (result.dw == 2) result.ext2 = (i32)dasmRead(pc); - if (result.ow == 1) result.ext3 = (i16)dasmRead(pc); - if (result.ow == 2) result.ext3 = (i32)dasmRead(pc); + if (result.dw == 1) result.ext2 = (i16)dasmIncRead(pc); + if (result.dw == 2) result.ext2 = (i32)dasmIncRead(pc); + if (result.ow == 1) result.ext3 = (i16)dasmIncRead(pc); + if (result.ow == 2) result.ext3 = (i32)dasmIncRead(pc); } break; } case 11: // Imm { - result.ext1 = dasmRead(pc); + result.ext1 = dasmIncRead(pc); break; } default: @@ -308,7 +341,7 @@ Moira::dasmAdda(StrWriter &str, u32 &addr, u16 op) const template void Moira::dasmAddiRg(StrWriter &str, u32 &addr, u16 op) const { - auto src = dasmRead(addr); + auto src = dasmIncRead(addr); auto dst = Dn ( _____________xxx(op) ); str << Ins{} << Sz{} << str.tab << Ims(src) << Sep{} << dst; @@ -317,7 +350,7 @@ Moira::dasmAddiRg(StrWriter &str, u32 &addr, u16 op) const template void Moira::dasmAddiEa(StrWriter &str, u32 &addr, u16 op) const { - auto src = dasmRead(addr); + auto src = dasmIncRead(addr); auto dst = Op ( _____________xxx(op), addr ); str << Ins{} << Sz{} << str.tab << Ims(src) << Sep{} << dst; @@ -425,7 +458,7 @@ Moira::dasmAndRgEa(StrWriter &str, u32 &addr, u16 op) const template void Moira::dasmAndiRg(StrWriter &str, u32 &addr, u16 op) const { - auto src = dasmRead(addr); + auto src = dasmIncRead(addr); auto dst = _____________xxx(op); if (str.style.syntax == DASM_MUSASHI) { @@ -438,7 +471,7 @@ Moira::dasmAndiRg(StrWriter &str, u32 &addr, u16 op) const template void Moira::dasmAndiEa(StrWriter &str, u32 &addr, u16 op) const { - auto src = dasmRead(addr); + auto src = dasmIncRead(addr); auto dst = Op ( _____________xxx(op), addr ); if (str.style.syntax == DASM_MUSASHI) { @@ -451,7 +484,7 @@ Moira::dasmAndiEa(StrWriter &str, u32 &addr, u16 op) const template void Moira::dasmAndiccr(StrWriter &str, u32 &addr, u16 op) const { - auto src = dasmRead(addr); + auto src = dasmIncRead(addr); if (str.style.syntax == DASM_MUSASHI) { str << Ins{} << str.tab << Imu{src} << Sep{} << Ccr{}; @@ -463,7 +496,7 @@ Moira::dasmAndiccr(StrWriter &str, u32 &addr, u16 op) const template void Moira::dasmAndisr(StrWriter &str, u32 &addr, u16 op) const { - auto src = dasmRead(addr); + auto src = dasmIncRead(addr); if (str.style.syntax == DASM_MUSASHI) { str << Ins{} << str.tab << Imu{src} << Sep{} << Sr{}; @@ -476,7 +509,7 @@ template void Moira::dasmBitFieldDn(StrWriter &str, u32 &addr, u16 op) const { auto old = addr; - auto ext = dasmRead (addr); + auto ext = dasmIncRead (addr); auto dst = _____________xxx(op); auto o = _____xxxxx______(ext); auto w = ___________xxxxx(ext); @@ -569,7 +602,7 @@ Moira::dasmBsr(StrWriter &str, u32 &addr, u16 op) const template void Moira::dasmCallm(StrWriter &str, u32 &addr, u16 op) const { - auto src = dasmRead(addr); + auto src = dasmIncRead(addr) & 0xFF; auto dst = Op( _____________xxx(op), addr ); switch (str.style.syntax) { @@ -590,7 +623,7 @@ template void Moira::dasmCas(StrWriter &str, u32 &addr, u16 op) const { auto old = addr; - auto ext = dasmRead (addr); + auto ext = dasmIncRead (addr); auto dc = Dn ( _____________xxx(ext) ); auto du = Dn ( _______xxx______(ext) ); auto dst = Op ( _____________xxx(op), addr ); @@ -611,7 +644,7 @@ template void Moira::dasmCas2(StrWriter &str, u32 &addr, u16 op) const { auto old = addr; - auto ext = dasmRead (addr); + auto ext = dasmIncRead (addr); auto dc1 = Dn ( (ext >> 16) & 0b111 ); auto dc2 = Dn ( (ext >> 0) & 0b111 ); auto du1 = Dn ( (ext >> 22) & 0b111 ); @@ -673,7 +706,7 @@ template void Moira::dasmChkCmp2(StrWriter &str, u32 &addr, u16 op) const { auto old = addr; - auto ext = dasmRead (addr); + auto ext = dasmIncRead (addr); auto src = Op ( _____________xxx(op), addr ); auto dst = Rn ( xxxx____________(ext) ); @@ -722,7 +755,7 @@ Moira::dasmCmpa(StrWriter &str, u32 &addr, u16 op) const template void Moira::dasmCmpiRg(StrWriter &str, u32 &addr, u16 op) const { - auto src = dasmRead(addr); + auto src = dasmIncRead(addr); auto dst = Dn ( _____________xxx(op) ); str << Ins{} << Sz{} << str.tab << Ims(src) << Sep{} << dst; @@ -732,7 +765,7 @@ Moira::dasmCmpiRg(StrWriter &str, u32 &addr, u16 op) const template void Moira::dasmCmpiEa(StrWriter &str, u32 &addr, u16 op) const { - auto src = dasmRead(addr); + auto src = dasmIncRead(addr); auto dst = Op ( _____________xxx(op), addr ); str << Ins{} << Sz{} << str.tab << Ims(src) << Sep{} << dst; @@ -760,9 +793,9 @@ Moira::dasmCpBcc(StrWriter &str, u32 &addr, u16 op) const auto id = ( ____xxx_________(op) ); auto cnd = ( __________xxxxxx(op) ); auto pc = addr + 2; - auto ext1 = dasmRead(addr); - auto disp = dasmRead(addr); - auto ext2 = dasmRead(addr); + auto ext1 = dasmIncRead(addr); + auto disp = dasmIncRead(addr); + auto ext2 = dasmIncRead(addr); pc += SEXT(disp); @@ -780,15 +813,15 @@ Moira::dasmCpDbcc(StrWriter &str, u32 &addr, u16 op) const } auto pc = addr + 2; - auto ext1 = dasmRead(addr); - auto ext2 = dasmRead(addr); + auto ext1 = dasmIncRead(addr); + auto ext2 = dasmIncRead(addr); auto dn = ( _____________xxx(op) ); auto id = ( ____xxx_________(op) ); auto cnd = ( __________xxxxxx(ext1) ); - auto ext3 = dasmRead(addr); - auto ext4 = dasmRead(addr); + auto ext3 = dasmIncRead(addr); + auto ext4 = dasmIncRead(addr); pc += i16(ext3); @@ -806,7 +839,7 @@ Moira::dasmCpGen(StrWriter &str, u32 &addr, u16 op) const } auto id = ( ____xxx_________(op) ); - auto ext = Imu ( dasmRead(addr) ); + auto ext = Imu ( dasmIncRead(addr) ); str << id << Ins{} << str.tab << ext; str << Av{}; @@ -857,9 +890,9 @@ Moira::dasmCpScc(StrWriter &str, u32 &addr, u16 op) const auto dn = ( _____________xxx(op) ); auto id = ( ____xxx_________(op) ); - auto ext1 = dasmRead(addr); + auto ext1 = dasmIncRead(addr); auto cnd = ( __________xxxxxx(ext1) ); - auto ext2 = dasmRead(addr); + auto ext2 = dasmIncRead(addr); auto ea = Op(dn, addr); str << id << Ins{} << Cpcc{cnd} << str.tab << ea; @@ -875,19 +908,19 @@ Moira::dasmCpTrapcc(StrWriter &str, u32 &addr, u16 op) const return; } - auto ext1 = dasmRead(addr); + auto ext1 = dasmIncRead(addr); auto id = ( ____xxx_________(op) ); auto cnd = ( __________xxxxxx(ext1) ); if (id == 0) { - auto ext2 = dasmRead(addr); + auto ext2 = dasmIncRead(addr); switch (op & 0b111) { case 0b010: { - auto ext = dasmRead(addr); + auto ext = dasmIncRead(addr); str << id << Ins{} << Cpcc{cnd} << Tab{9}; str << Tab{10} << Imu(ext); str << "; (extension = " << Int(ext2) << ") (2-3)"; @@ -895,7 +928,7 @@ Moira::dasmCpTrapcc(StrWriter &str, u32 &addr, u16 op) const } case 0b011: { - auto ext = dasmRead(addr); + auto ext = dasmIncRead(addr); str << id << Ins{} << Cpcc{cnd} << Tab{9}; str << Tab{10} << Imu(ext); str << "; (extension = " << Int(ext2) << ") (2-3)"; @@ -903,7 +936,7 @@ Moira::dasmCpTrapcc(StrWriter &str, u32 &addr, u16 op) const } case 0b100: { - // (void)dasmRead(addr); + // (void)dasmIncRead(addr); str << id << Ins{} << Cpcc{cnd} << Tab{9}; str << "; (extension = " << Int(ext2) << ") (2-3)"; break; @@ -917,13 +950,13 @@ Moira::dasmCpTrapcc(StrWriter &str, u32 &addr, u16 op) const } else { - auto ext2 = dasmRead(addr); + auto ext2 = dasmIncRead(addr); switch (op & 0b111) { case 0b010: { - auto ext = dasmRead(addr); + auto ext = dasmIncRead(addr); str << id << Ins{} << Cpcc{cnd} << Tab{9}; str << Tab{10} << Imu(ext); str << "; (extension = " << Int(ext2) << ") (2-3)"; @@ -931,7 +964,7 @@ Moira::dasmCpTrapcc(StrWriter &str, u32 &addr, u16 op) const } case 0b011: { - auto ext = dasmRead(addr); + auto ext = dasmIncRead(addr); str << id << Ins{} << Cpcc{cnd} << Tab{9}; str << Tab{10} << Imu(ext); str << "; (extension = " << Int(ext2) << ") (2-3)"; @@ -939,7 +972,7 @@ Moira::dasmCpTrapcc(StrWriter &str, u32 &addr, u16 op) const } case 0b100: { - // (void)dasmRead(addr); + // (void)dasmIncRead(addr); str << id << Ins{} << Cpcc{cnd} << Tab{9}; str << "; (extension = " << Int(ext2) << ") (2-3)"; break; @@ -958,7 +991,7 @@ Moira::dasmBcc(StrWriter &str, u32 &addr, u16 op) const { u32 dst = addr; U32_INC(dst, 2); - U32_INC(dst, S == Byte ? (i8)op : SEXT(dasmRead(addr))); + U32_INC(dst, S == Byte ? (i8)op : SEXT(dasmIncRead(addr))); switch (str.style.syntax) { @@ -1013,7 +1046,7 @@ Moira::dasmBitDxEa(StrWriter &str, u32 &addr, u16 op) const template void Moira::dasmBitImDy(StrWriter &str, u32 &addr, u16 op) const { - auto src = dasmRead(addr); + auto src = dasmIncRead(addr); auto dst = Op ( _____________xxx(op), addr ); switch (str.style.syntax) { @@ -1033,7 +1066,7 @@ Moira::dasmBitImDy(StrWriter &str, u32 &addr, u16 op) const template void Moira::dasmBitImEa(StrWriter &str, u32 &addr, u16 op) const { - auto src = dasmRead(addr); + auto src = dasmIncRead(addr); auto dst = Op ( _____________xxx(op), addr ); switch (str.style.syntax) { @@ -1056,7 +1089,7 @@ Moira::dasmDbcc(StrWriter &str, u32 &addr, u16 op) const auto src = Dn ( _____________xxx(op) ); auto dst = addr + 2; - U32_INC(dst, (i16)dasmRead(addr)); + U32_INC(dst, (i16)dasmIncRead(addr)); str << Ins{} << str.tab << src << Sep{} << UInt(dst); } @@ -1133,7 +1166,7 @@ Moira::dasmLea(StrWriter &str, u32 &addr, u16 op) const template void Moira::dasmLink(StrWriter &str, u32 &addr, u16 op) const { - auto dsp = dasmRead(addr); + auto dsp = dasmIncRead(addr); auto src = An ( _____________xxx(op) ); switch (str.style.syntax) { @@ -1234,7 +1267,7 @@ Moira::dasmMovea(StrWriter &str, u32 &addr, u16 op) const template void Moira::dasmMovecRcRx(StrWriter &str, u32 &addr, u16 op) const { - auto ext = u16(dasmRead(addr)); + auto ext = u16(dasmIncRead(addr)); auto src = Cn(____xxxxxxxxxxxx(ext)); auto dst = Rn(xxxx____________(ext)); @@ -1245,7 +1278,7 @@ Moira::dasmMovecRcRx(StrWriter &str, u32 &addr, u16 op) const template void Moira::dasmMovecRxRc(StrWriter &str, u32 &addr, u16 op) const { - auto ext = u16(dasmRead(addr)); + auto ext = u16(dasmIncRead(addr)); auto dst = Cn(____xxxxxxxxxxxx(ext)); auto src = Rn(xxxx____________(ext)); @@ -1256,7 +1289,7 @@ Moira::dasmMovecRxRc(StrWriter &str, u32 &addr, u16 op) const template void Moira::dasmMovemEaRg(StrWriter &str, u32 &addr, u16 op) const { - auto dst = RegRegList ( (u16)dasmRead(addr) ); + auto dst = RegRegList ( (u16)dasmIncRead(addr) ); auto src = Op ( _____________xxx(op), addr ); str << Ins{} << Sz{} << str.tab << src << Sep{} << dst; @@ -1265,7 +1298,7 @@ Moira::dasmMovemEaRg(StrWriter &str, u32 &addr, u16 op) const template void Moira::dasmMovemRgEa(StrWriter &str, u32 &addr, u16 op) const { - auto src = RegRegList ( (u16)dasmRead(addr) ); + auto src = RegRegList ( (u16)dasmIncRead(addr) ); auto dst = Op ( _____________xxx(op), addr ); if constexpr (M == 4) { src.raw = REVERSE_16(src.raw); } @@ -1303,7 +1336,7 @@ template void Moira::dasmMoves(StrWriter &str, u32 &addr, u16 op) const { auto old = addr; - auto ext = (u16)dasmRead(addr); + auto ext = (u16)dasmIncRead(addr); auto ea = Op ( _____________xxx(op), addr ); auto rg = Rn ( xxxx____________(ext) ); @@ -1493,7 +1526,7 @@ template void Moira::dasmMull(StrWriter &str, u32 &addr, u16 op) const { auto old = addr; - auto ext = dasmRead (addr); + auto ext = dasmIncRead (addr); auto src = Op ( _____________xxx(op), addr ); auto dl = Dn ( _xxx____________(ext) ); auto dh = Dn ( _____________xxx(ext) ); @@ -1545,7 +1578,7 @@ template void Moira::dasmDivl(StrWriter &str, u32 &addr, u16 op) const { auto old = addr; - auto ext = dasmRead (addr); + auto ext = dasmIncRead (addr); auto src = Op ( _____________xxx(op), addr ); auto dl = Dn ( _xxx____________(ext) ); auto dh = Dn ( _____________xxx(ext) ); @@ -1614,7 +1647,7 @@ Moira::dasmNop(StrWriter &str, u32 &addr, u16 op) const template void Moira::dasmPackDn(StrWriter &str, u32 &addr, u16 op) const { - auto ext = dasmRead (addr); + auto ext = dasmIncRead (addr); auto rx = Op ( _____________xxx(op), addr ); auto ry = Op ( ____xxx_________(op), addr ); @@ -1656,7 +1689,7 @@ Moira::dasmReset(StrWriter &str, u32 &addr, u16 op) const template void Moira::dasmRtd(StrWriter &str, u32 &addr, u16 op) const { - auto disp = dasmRead(addr); + auto disp = dasmIncRead(addr); str << Ins{} << str.tab << Ims(disp); str << Av{}; @@ -1708,7 +1741,7 @@ Moira::dasmSccEa(StrWriter &str, u32 &addr, u16 op) const template void Moira::dasmStop(StrWriter &str, u32 &addr, u16 op) const { - auto src = dasmRead(addr); + auto src = dasmIncRead(addr); str << Ins{} << str.tab << Ims(src); } @@ -1785,7 +1818,7 @@ Moira::dasmTrapcc(StrWriter &str, u32 &addr, u16 op) const case Word: case Long: - auto ext = dasmRead(addr); + auto ext = dasmIncRead(addr); str << Ins{} << Sz{} << str.tab << Ims(ext); break; } @@ -1803,7 +1836,7 @@ Moira::dasmTrapcc(StrWriter &str, u32 &addr, u16 op) const case Word: case Long: - auto ext = dasmRead(addr); + auto ext = dasmIncRead(addr); str << Ins{} << str.tab << Imu(ext); break; } @@ -1832,7 +1865,7 @@ Moira::dasmUnlk(StrWriter &str, u32 &addr, u16 op) const template void Moira::dasmUnpkDn(StrWriter &str, u32 &addr, u16 op) const { - auto ext = dasmRead (addr); + auto ext = dasmIncRead (addr); auto rx = Op ( _____________xxx(op), addr ); auto ry = Op ( ____xxx_________(op), addr ); @@ -1908,7 +1941,7 @@ template void Moira::dasmMove16PiPi(StrWriter &str, u32 &addr, u16 op) const { auto old = addr; - auto ext = dasmRead(addr); + auto ext = dasmIncRead(addr); auto ax = _____________xxx(op); auto ay = _xxx____________(ext); @@ -1926,7 +1959,7 @@ Moira::dasmMove16PiPi(StrWriter &str, u32 &addr, u16 op) const template void Moira::dasmMove16PiAl(StrWriter &str, u32 &addr, u16 op) const { - auto ext = dasmRead(addr); + auto ext = dasmIncRead(addr); auto ay = _____________xxx(op); str << Ins{} << str.tab << Op(ay, addr) << Sep{} << UInt(ext); @@ -1936,7 +1969,7 @@ Moira::dasmMove16PiAl(StrWriter &str, u32 &addr, u16 op) const template void Moira::dasmMove16AlPi(StrWriter &str, u32 &addr, u16 op) const { - auto ext = dasmRead(addr); + auto ext = dasmIncRead(addr); auto ay = _____________xxx(op); str << Ins{} << str.tab << UInt(ext) << Sep{} << Op(ay, addr); @@ -1946,7 +1979,7 @@ Moira::dasmMove16AlPi(StrWriter &str, u32 &addr, u16 op) const template void Moira::dasmMove16AiAl(StrWriter &str, u32 &addr, u16 op) const { - auto ext = dasmRead(addr); + auto ext = dasmIncRead(addr); auto ay = _____________xxx(op); str << Ins{} << str.tab << Op(ay, addr) << Sep{} << UInt(ext); @@ -1956,7 +1989,7 @@ Moira::dasmMove16AiAl(StrWriter &str, u32 &addr, u16 op) const template void Moira::dasmMove16AlAi(StrWriter &str, u32 &addr, u16 op) const { - auto ext = dasmRead(addr); + auto ext = dasmIncRead(addr); auto ay = _____________xxx(op); str << Ins{} << str.tab << UInt(ext) << Sep{} << Op(ay, addr); diff --git a/Emulator/CPU/Moira/MoiraDebugger.cpp b/Emulator/CPU/Moira/MoiraDebugger.cpp index 62d6bc04f..6fc478408 100644 --- a/Emulator/CPU/Moira/MoiraDebugger.cpp +++ b/Emulator/CPU/Moira/MoiraDebugger.cpp @@ -252,7 +252,7 @@ void Debugger::stepOver() { char tmp[64]; - softStop = moira.getPC() + moira.disassemble(moira.getPC(), tmp); + softStop = moira.getPC() + moira.disassemble(tmp, moira.getPC()); breakpoints.setNeedsCheck(true); }