diff --git a/src/debugger/CartDebug.cxx b/src/debugger/CartDebug.cxx index a80217303..d22fe3426 100644 --- a/src/debugger/CartDebug.cxx +++ b/src/debugger/CartDebug.cxx @@ -82,8 +82,9 @@ CartDebug::CartDebug(Debugger& dbg, Console& console, const OSystem& osystem) myBankInfo.push_back(info); // We know the address for the startup bank right now - myBankInfo[myConsole.cartridge().startBank()].addressList.push_back(myDebugger.dpeek(0xfffc)); - addLabel("START", myDebugger.dpeek(0xfffc)); + myBankInfo[myConsole.cartridge().startBank()].addressList.push_front(myDebugger.dpeek(0xfffc)); + addLabel("Start", myDebugger.dpeek(0xfffc, DATA)); + addLabel("Break", myDebugger.dpeek(0xfffe)); // Add system equates for(uInt16 addr = 0x00; addr <= 0x0F; ++addr) @@ -114,16 +115,17 @@ CartDebug::CartDebug(Debugger& dbg, Console& console, const OSystem& osystem) myDisassembly.list.reserve(2048); // Add settings for Distella - DiStella::settings.gfx_format = + DiStella::settings.gfxFormat = myOSystem.settings().getInt("dis.gfxformat") == 16 ? Base::F_16 : Base::F_2; - DiStella::settings.resolve_code = + DiStella::settings.resolveCode = myOSystem.settings().getBool("dis.resolve"); - DiStella::settings.show_addresses = + DiStella::settings.showAddresses = myOSystem.settings().getBool("dis.showaddr"); - DiStella::settings.aflag = false; // Not currently configurable - DiStella::settings.fflag = true; // Not currently configurable - DiStella::settings.rflag = myOSystem.settings().getBool("dis.relocate"); - DiStella::settings.bwidth = 9; // TODO - configure based on window size + DiStella::settings.aFlag = false; // Not currently configurable + DiStella::settings.fFlag = true; // Not currently configurable + DiStella::settings.rFlag = myOSystem.settings().getBool("dis.relocate"); + DiStella::settings.bFlag = true; // Not currently configurable + DiStella::settings.bytesWidth = 8+1; // TODO - configure based on window size } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -263,34 +265,28 @@ bool CartDebug::disassemble(bool force) // Only add addresses when absolutely necessary, to cut down on the // work that Distella has to do - // Distella expects the addresses to be unique and in sorted order if(bankChanged || !pcfound) { AddressList::const_iterator i; for(i = addresses.cbegin(); i != addresses.cend(); ++i) { - if(PC < *i) - { - addresses.insert(i, PC); - break; - } - else if(PC == *i) // already present + if (PC == *i) // already present break; } // Otherwise, add the item at the end - if(i == addresses.end()) - addresses.push_back(PC); + if (i == addresses.end()) + addresses.push_back(PC); } // Always attempt to resolve code sections unless it's been // specifically disabled bool found = fillDisassemblyList(info, PC); - if(!found && DiStella::settings.resolve_code) + if(!found && DiStella::settings.resolveCode) { // Temporarily turn off code resolution - DiStella::settings.resolve_code = false; + DiStella::settings.resolveCode = false; fillDisassemblyList(info, PC); - DiStella::settings.resolve_code = true; + DiStella::settings.resolveCode = true; } } @@ -973,20 +969,21 @@ string CartDebug::saveDisassembly() // We can't print the header to the disassembly until it's actually // been processed; therefore buffer output to a string first ostringstream buf; - buf << "\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;\n" - << "; MAIN PROGRAM\n" - << ";\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n"; + buf << "\n\n;***********************************************************\n" + << "; Program Code + Data\n" + << ";***********************************************************\n\n"; // Use specific settings for disassembly output // This will most likely differ from what you see in the debugger DiStella::Settings settings; - settings.gfx_format = DiStella::settings.gfx_format; - settings.resolve_code = true; - settings.show_addresses = false; - settings.aflag = false; // Otherwise DASM gets confused - settings.fflag = DiStella::settings.fflag; - settings.rflag = DiStella::settings.rflag; - settings.bwidth = 8+1; // same as Stella debugger + settings.gfxFormat = DiStella::settings.gfxFormat; + settings.resolveCode = true; + settings.showAddresses = false; + settings.aFlag = false; // Otherwise DASM gets confused + settings.fFlag = DiStella::settings.fFlag; + settings.rFlag = DiStella::settings.rFlag; + settings.bytesWidth = 8+1; // same as Stella debugger + settings.bFlag = DiStella::settings.bFlag;; // process break routine (TODO) Disassembly disasm; disasm.list.reserve(2048); @@ -1001,6 +998,9 @@ string CartDebug::saveDisassembly() disasm.list.clear(); DiStella distella(*this, disasm.list, info, settings, myDisLabels, myDisDirectives, myReserved); + + //if (myReserved.breakFound) + // addLabel("BREAK", myDebugger.dpeek(0xfffe)); buf << " SEG CODE\n" << " ORG $" << Base::HEX4 << info.offset << "\n\n"; @@ -1031,7 +1031,7 @@ string CartDebug::saveDisassembly() } case CartDebug::GFX: { - buf << ".byte " << (settings.gfx_format == Base::F_2 ? "%" : "$") + buf << ".byte " << (settings.gfxFormat == Base::F_2 ? "%" : "$") << tag.bytes << " ; |"; for(int c = 12; c < 20; ++c) buf << ((tag.disasm[c] == '\x1e') ? "#" : " "); @@ -1040,7 +1040,7 @@ string CartDebug::saveDisassembly() } case CartDebug::PGFX: { - buf << ".byte " << (settings.gfx_format == Base::F_2 ? "%" : "$") + buf << ".byte " << (settings.gfxFormat == Base::F_2 ? "%" : "$") << tag.bytes << " ; |"; for(int c = 12; c < 20; ++c) buf << ((tag.disasm[c] == '\x1f') ? "*" : " "); @@ -1087,9 +1087,9 @@ string CartDebug::saveDisassembly() addrUsed = addrUsed || myReserved.IOReadWrite[addr]; if(addrUsed) { - out << ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n" - << "; TIA AND IO CONSTANTS\n" - << ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n"; + out << "\n;-----------------------------------------------------------\n" + << "; TIA and IO constants accessed\n" + << ";-----------------------------------------------------------\n\n"; for(uInt16 addr = 0x00; addr <= 0x0F; ++addr) if(myReserved.TIARead[addr] && ourTIAMnemonicR[addr]) out << ALIGN(16) << ourTIAMnemonicR[addr] << "= $" @@ -1109,9 +1109,9 @@ string CartDebug::saveDisassembly() addrUsed = addrUsed || myReserved.ZPRAM[addr-0x80]; if(addrUsed) { - out << "\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n" - << "; RIOT RAM (zero-page)\n" - << ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n"; + out << "\n\n;-----------------------------------------------------------\n" + << "; RIOT RAM (zero-page) labels\n" + << ";-----------------------------------------------------------\n\n"; for(uInt16 addr = 0x80; addr <= 0xFF; ++addr) { if(myReserved.ZPRAM[addr-0x80] && @@ -1125,18 +1125,18 @@ string CartDebug::saveDisassembly() if(myReserved.Label.size() > 0) { - out << "\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n" - << "; NON LOCATABLE\n" - << ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n"; + out << "\n\n;-----------------------------------------------------------\n" + << "; Non Locatable Labels\n" + << ";-----------------------------------------------------------\n\n"; for(const auto& iter: myReserved.Label) out << ALIGN(16) << iter.second << "= $" << iter.first << "\n"; } if(myUserLabels.size() > 0) { - out << "\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n" - << "; USER DEFINED\n" - << ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n"; + out << "\n\n;-----------------------------------------------------------\n" + << "; User Defined Labels\n" + << ";-----------------------------------------------------------\n\n"; int max_len = 16; for(const auto& iter: myUserLabels) max_len = std::max(max_len, int(iter.second.size())); diff --git a/src/debugger/CartDebug.hxx b/src/debugger/CartDebug.hxx index eb628b644..804b27a05 100644 --- a/src/debugger/CartDebug.hxx +++ b/src/debugger/CartDebug.hxx @@ -52,9 +52,9 @@ class CartDebug : public DebuggerSystem public: enum DisasmType { NONE = 0, - REFERENCED = 1 << 0, /* code somewhere in the program references it, + REFERENCED = 1 << 0, /* 0x01, code somewhere in the program references it, i.e. LDA $F372 referenced $F372 */ - VALID_ENTRY = 1 << 1, /* addresses that can have a label placed in front of it. + VALID_ENTRY = 1 << 1, /* 0x02, addresses that can have a label placed in front of it. A good counterexample would be "FF00: LDA $FE00"; $FF01 would be in the middle of a multi-byte instruction, and therefore cannot be labelled. */ @@ -63,12 +63,12 @@ class CartDebug : public DebuggerSystem // debugger, or specified in a Distella cfg file, and are listed in order // of decreasing hierarchy // - CODE = 1 << 7, // disassemble-able code segments - TCODE = 1 << 6, // (tentative) disassemble-able code segments - GFX = 1 << 5, // addresses loaded into GRPx registers - PGFX = 1 << 4, // addresses loaded into PFx registers - DATA = 1 << 3, // addresses loaded into registers other than GRPx / PFx - ROW = 1 << 2 // all other addresses + CODE = 1 << 7, // 0x80, disassemble-able code segments + TCODE = 1 << 6, // 0x40, (tentative) disassemble-able code segments + GFX = 1 << 5, // 0x20, addresses loaded into GRPx registers + PGFX = 1 << 4, // 0x10, addresses loaded into PFx registers + DATA = 1 << 3, // 0x08, addresses loaded into registers other than GRPx / PFx + ROW = 1 << 2 // 0x04, all other addresses }; struct DisassemblyTag { DisasmType type; @@ -317,6 +317,7 @@ class CartDebug : public DebuggerSystem bool IOReadWrite[24]; bool ZPRAM[128]; AddrToLabel Label; + bool breakFound; }; ReservedEquates myReserved; diff --git a/src/debugger/Debugger.hxx b/src/debugger/Debugger.hxx index 945a56e9f..bdefeb719 100644 --- a/src/debugger/Debugger.hxx +++ b/src/debugger/Debugger.hxx @@ -206,8 +206,8 @@ class Debugger : public DialogContainer static Debugger& debugger() { return *myStaticDebugger; } /* These are now exposed so Expressions can use them. */ - int peek(int addr) { return mySystem.peek(addr); } - int dpeek(int addr) { return mySystem.peek(addr) | (mySystem.peek(addr+1) << 8); } + int peek(int addr, uInt8 flags = 0) { return mySystem.peek(addr, flags); } + int dpeek(int addr, uInt8 flags = 0) { return mySystem.peek(addr, flags) | (mySystem.peek(addr+1, flags) << 8); } int getAccessFlags(uInt16 addr) const { return mySystem.getAccessFlags(addr); } void setAccessFlags(uInt16 addr, uInt8 flags) diff --git a/src/debugger/DiStella.cxx b/src/debugger/DiStella.cxx index 3e6ca9926..128000bef 100644 --- a/src/debugger/DiStella.cxx +++ b/src/debugger/DiStella.cxx @@ -35,15 +35,10 @@ DiStella::DiStella(const CartDebug& dbg, CartDebug::DisassemblyList& list, myLabels(labels), myDirectives(directives) { - CartDebug::AddressList& addresses = info.addressList; - - while (!myAddressQueue.empty()) - myAddressQueue.pop(); - - bool resolve_code = mySettings.resolve_code; - - auto it = addresses.cbegin(); - uInt16 start = *it++; + bool resolve_code = mySettings.resolveCode; + CartDebug::AddressList& debuggerAddresses = info.addressList; + auto it = debuggerAddresses.cbegin(); + uInt16 start = *it++; myOffset = info.offset; if (start & 0x1000) { @@ -89,6 +84,10 @@ DiStella::DiStella(const CartDebug& dbg, CartDebug::DisassemblyList& list, memset(myLabels, 0, 0x1000); memset(myDirectives, 0, 0x1000); + myReserved.breakFound = false; + + while (!myAddressQueue.empty()) + myAddressQueue.pop(); myAddressQueue.push(start); // Process any directives first, as they override automatic code determination @@ -105,12 +104,23 @@ DiStella::DiStella(const CartDebug& dbg, CartDebug::DisassemblyList& list, // addresses and only process the first one uInt16 lastPC = 0; bool duplicateFound = false; - while (!(myAddressQueue.empty() || duplicateFound)) { - myPC = lastPC = myAddressQueue.front(); + int count = 0; - uInt16 pcBeg = myPC; + + uInt8 flags = Debugger::debugger().getAccessFlags(0xf52c); + //checkBit(0xf52c, CartDebug::DATA); + + while (!(myAddressQueue.empty() || duplicateFound)) { + + /*if (++count == 2) + break;*/ + + uInt16 pcBeg = myPC = lastPC = myAddressQueue.front(); + myAddressQueue.pop(); - disasm(myPC, 1); + //disasm(myPC, 1); + disasmPass1(myPC); + if (pcBeg <= myPCEnd) { // Tentatively mark all addresses in the range as CODE // Note that this is a 'best-effort' approach, since @@ -120,11 +130,13 @@ DiStella::DiStella(const CartDebug& dbg, CartDebug::DisassemblyList& list, // in the emulation core indicate that the CODE range has finished // Therefore, we stop at the first such address encountered for (uInt32 k = pcBeg; k <= myPCEnd; k++) { - if (Debugger::debugger().getAccessFlags(k) & - (CartDebug::DATA | CartDebug::GFX | CartDebug::PGFX)) { + /*if (Debugger::debugger().getAccessFlags(k) & + (CartDebug::DATA | CartDebug::GFX | CartDebug::PGFX)) { myPCEnd = k - 1; + if (k == 0xf5c6) + k = k; break; - } + }*/ mark(k, CartDebug::CODE); } } @@ -144,30 +156,28 @@ DiStella::DiStella(const CartDebug& dbg, CartDebug::DisassemblyList& list, // the processing of a single address can cause others to be added in // the ::disasm method // All of these have to be exhausted before considering a new address - if (myAddressQueue.empty()) { - while (it != addresses.end()) { - uInt16 addr = *it; - if (!checkBit(addr - myOffset, CartDebug::CODE)) { - myAddressQueue.push(addr); - ++it; - break; - } else // remove this address, it is redundant - it = addresses.erase(it); - } + while (myAddressQueue.empty() && it != debuggerAddresses.end()) { + uInt16 addr = *it; - // Stella itself can provide hints on whether an address has ever - // been referenced as CODE - while (it == addresses.end() && codeAccessPoint <= myAppData.end) { - if ((Debugger::debugger().getAccessFlags(codeAccessPoint + myOffset) & CartDebug::CODE) - && !(myLabels[codeAccessPoint & myAppData.end] & CartDebug::CODE)) { - myAddressQueue.push(codeAccessPoint + myOffset); - ++codeAccessPoint; - break; - } - ++codeAccessPoint; - } + if (!checkBit(addr - myOffset, CartDebug::CODE)) { + myAddressQueue.push(addr); + ++it; + } else // remove this address, it is redundant + it = debuggerAddresses.erase(it); } - duplicateFound = (myAddressQueue.front() == lastPC); + + // Stella itself can provide hints on whether an address has ever + // been referenced as CODE + while (myAddressQueue.empty() && codeAccessPoint <= myAppData.end) { + if ((Debugger::debugger().getAccessFlags(codeAccessPoint + myOffset) & CartDebug::CODE) + && !(myLabels[codeAccessPoint & myAppData.end] & CartDebug::CODE)) { + myAddressQueue.push(codeAccessPoint + myOffset); + ++codeAccessPoint; + break; + } + ++codeAccessPoint; + } + duplicateFound = !myAddressQueue.empty() && (myAddressQueue.front() == lastPC); // TODO: check! } // while for (int k = 0; k <= myAppData.end; k++) { @@ -180,10 +190,10 @@ DiStella::DiStella(const CartDebug& dbg, CartDebug::DisassemblyList& list, // Must be ROW / unused bytes if (!checkBit(k, CartDebug::CODE | CartDebug::GFX | - CartDebug::PGFX | CartDebug::DATA)) + CartDebug::PGFX | CartDebug::DATA)) mark(k + myOffset, CartDebug::ROW); } - } + } // resolve code // Second pass disasm(myOffset, 2); @@ -207,6 +217,10 @@ DiStella::DiStella(const CartDebug& dbg, CartDebug::DisassemblyList& list, // Third pass disasm(myOffset, 3); + + for (uInt16 addr = 0x80; addr <= 0xFF; ++addr) { + //myReserved.ZPRAM[addr - 0x80] + } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -218,10 +232,10 @@ void DiStella::disasm(uInt32 distart, int pass) - pass 3 generates output */ { -#define LABEL_A12_HIGH(address) labelA12High(nextLine, op, address, labelFound) -#define LABEL_A12_LOW(address) labelA12Low(nextLine, op, address, labelFound) +#define LABEL_A12_HIGH(address) labelA12High(nextLine, opcode, address, labelFound) +#define LABEL_A12_LOW(address) labelA12Low(nextLine, opcode, address, labelFound) - uInt8 op, d1; + uInt8 opcode, d1; uInt16 ad; uInt32 cycles = 0; AddressingMode addrMode; @@ -231,11 +245,11 @@ void DiStella::disasm(uInt32 distart, int pass) mySegType = CartDebug::NONE; // create extra lines between code and data myDisasmBuf.str(""); - myPass = pass; /* pc=myAppData.start; */ myPC = distart - myOffset; while (myPC <= myAppData.end) { + if (checkBits(myPC, CartDebug::GFX | CartDebug::PGFX, CartDebug::CODE)) { if (pass == 2) @@ -261,6 +275,8 @@ void DiStella::disasm(uInt32 distart, int pass) else myPC++; } else { + // The following sections must be CODE + // add extra spacing line when switching from non-code to code if (pass == 3 && mySegType != CartDebug::CODE && mySegType != CartDebug::NONE) { myDisasmBuf << " ' ' "; @@ -269,37 +285,65 @@ void DiStella::disasm(uInt32 distart, int pass) } mySegType = CartDebug::CODE; - // The following sections must be CODE - // Add label (if any) - op = Debugger::debugger().peek(myPC + myOffset); /* version 2.1 bug fix */ if (pass == 2) mark(myPC + myOffset, CartDebug::VALID_ENTRY); - + + // get opcode + opcode = Debugger::debugger().peek(myPC + myOffset); + // get address mode for opcode + addrMode = ourLookup[opcode].addr_mode; + if (pass == 3) { if (checkBit(myPC, CartDebug::REFERENCED)) myDisasmBuf << Base::HEX4 << myPC + myOffset << "'L" << Base::HEX4 << myPC + myOffset << "'"; else myDisasmBuf << Base::HEX4 << myPC + myOffset << "' '"; } - - // Add opcode mnemonic - addrMode = ourLookup[op].addr_mode; myPC++; + // detect labels inside instructions (e.g. BIT masks) + labelFound = false; + for (Uint8 i = 0; i < ourLookup[opcode].bytes - 1; i++) { + if (checkBit(myPC + i, CartDebug::REFERENCED)) { + labelFound = true; + break; + } + } + if (labelFound) { + // the opcode's operand address matches a label address + if (pass == 3) { + // output the byte of the opcode incl. cycles + Uint8 nextOpcode = Debugger::debugger().peek(myPC + myOffset); + + cycles += int(ourLookup[opcode].cycles) - int(ourLookup[nextOpcode].cycles); + nextLine << ".byte $" << Base::HEX2 << int(opcode) << " ;"; + nextLine << ourLookup[opcode].mnemonic; + + myDisasmBuf << nextLine.str() << "'" << ";" + << std::dec << int(ourLookup[opcode].cycles) << "-" + << std::dec << int(ourLookup[nextOpcode].cycles) << " " + << "'= " << std::setw(3) << std::setfill(' ') << std::dec << cycles; + + nextLine.str(""); + cycles = 0; + addEntry(CartDebug::CODE); // add the new found CODE entry + } + // continue with the label's opcode + continue; + } + // Undefined opcodes start with a '.' // These are undefined wrt DASM - if (ourLookup[op].mnemonic[0] == '.') { - addrMode = IMPLIED; - if (pass == 3) - nextLine << ".byte $" << Base::HEX2 << int(op) << " ;"; + if (ourLookup[opcode].mnemonic[0] == '.' && pass == 3) { + nextLine << ".byte $" << Base::HEX2 << int(opcode) << " ;"; } if (pass == 3) { - nextLine << ourLookup[op].mnemonic; - nextLineBytes << Base::HEX2 << int(op) << " "; + nextLine << ourLookup[opcode].mnemonic; + nextLineBytes << Base::HEX2 << int(opcode) << " "; } - + // Add operand(s) for PC values outside the app data range if (myPC >= myAppData.end) { switch (addrMode) { @@ -314,9 +358,9 @@ void DiStella::disasm(uInt32 distart, int pass) /* Line information is already printed; append .byte since last instruction will put recompilable object larger that original binary file */ - myDisasmBuf << ".byte $" << Base::HEX2 << int(op) << " $" + myDisasmBuf << ".byte $" << Base::HEX2 << int(opcode) << " $" << Base::HEX4 << myPC + myOffset << "'" - << Base::HEX2 << int(op); + << Base::HEX2 << int(opcode); addEntry(CartDebug::DATA); if (myPC == myAppData.end) { @@ -325,10 +369,10 @@ void DiStella::disasm(uInt32 distart, int pass) else myDisasmBuf << Base::HEX4 << myPC + myOffset << "' '"; - op = Debugger::debugger().peek(myPC + myOffset); myPC++; - myDisasmBuf << ".byte $" << Base::HEX2 << int(op) << " $" + opcode = Debugger::debugger().peek(myPC + myOffset); myPC++; + myDisasmBuf << ".byte $" << Base::HEX2 << int(opcode) << " $" << Base::HEX4 << myPC + myOffset << "'" - << Base::HEX2 << int(op); + << Base::HEX2 << int(opcode); addEntry(CartDebug::DATA); } } @@ -345,7 +389,7 @@ void DiStella::disasm(uInt32 distart, int pass) if (pass == 3) { /* Line information is already printed, but we can remove the Instruction (i.e. BMI) by simply clearing the buffer to print */ - myDisasmBuf << ".byte $" << Base::HEX2 << int(op); + myDisasmBuf << ".byte $" << Base::HEX2 << int(opcode); addEntry(CartDebug::ROW); nextLine.str(""); nextLineBytes.str(""); @@ -366,7 +410,7 @@ void DiStella::disasm(uInt32 distart, int pass) switch (addrMode) { case ACCUMULATOR: { - if (pass == 3 && mySettings.aflag) + if (pass == 3 && mySettings.aFlag) nextLine << " A"; break; } @@ -375,18 +419,8 @@ void DiStella::disasm(uInt32 distart, int pass) { ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2; labelFound = mark(ad, CartDebug::REFERENCED); - if (pass == 1) { - if (!checkBit(ad & myAppData.end, CartDebug::CODE)) { - if (ad > 0xfff) - myAddressQueue.push((ad & myAppData.end) + myOffset); - - mark(ad, CartDebug::CODE); - } else if (ad > 0xfff) { - mark(ad, CartDebug::DATA); - } - } if (pass == 3) { - if (ad < 0x100 && mySettings.fflag) + if (ad < 0x100 && mySettings.fFlag) nextLine << ".w "; else nextLine << " "; @@ -395,7 +429,7 @@ void DiStella::disasm(uInt32 distart, int pass) LABEL_A12_HIGH(ad); nextLineBytes << Base::HEX2 << int(ad & 0xff) << " " << Base::HEX2 << int(ad >> 8); } else if (labelFound == 4) { - if (mySettings.rflag) { + if (mySettings.rFlag) { int tmp = (ad & myAppData.end) + myOffset; LABEL_A12_HIGH(tmp); nextLineBytes << Base::HEX2 << int(tmp & 0xff) << " " << Base::HEX2 << int(tmp >> 8); @@ -444,7 +478,7 @@ void DiStella::disasm(uInt32 distart, int pass) // the code can somehow track access to CPU registers mark(ad, CartDebug::ROW); } else if (pass == 3) { - if (ad < 0x100 && mySettings.fflag) + if (ad < 0x100 && mySettings.fFlag) nextLine << ".wx "; else nextLine << " "; @@ -454,7 +488,7 @@ void DiStella::disasm(uInt32 distart, int pass) nextLine << ",x"; nextLineBytes << Base::HEX2 << int(ad & 0xff) << " " << Base::HEX2 << int(ad >> 8); } else if (labelFound == 4) { - if (mySettings.rflag) { + if (mySettings.rFlag) { int tmp = (ad & myAppData.end) + myOffset; LABEL_A12_HIGH(tmp); nextLine << ",x"; @@ -483,7 +517,7 @@ void DiStella::disasm(uInt32 distart, int pass) // the code can somehow track access to CPU registers mark(ad, CartDebug::ROW); } else if (pass == 3) { - if (ad < 0x100 && mySettings.fflag) + if (ad < 0x100 && mySettings.fFlag) nextLine << ".wy "; else nextLine << " "; @@ -493,7 +527,7 @@ void DiStella::disasm(uInt32 distart, int pass) nextLine << ",y"; nextLineBytes << Base::HEX2 << int(ad & 0xff) << " " << Base::HEX2 << int(ad >> 8); } else if (labelFound == 4) { - if (mySettings.rflag) { + if (mySettings.rFlag) { int tmp = (ad & myAppData.end) + myOffset; LABEL_A12_HIGH(tmp); nextLine << ",y"; @@ -572,12 +606,7 @@ void DiStella::disasm(uInt32 distart, int pass) ad = ((myPC + Int8(d1)) & 0xfff) + myOffset; labelFound = mark(ad, CartDebug::REFERENCED); - if (pass == 1) { - if (!checkBit(ad - myOffset, CartDebug::CODE)) { - myAddressQueue.push(ad); - mark(ad, CartDebug::CODE); - } - } else if (pass == 3) { + if (pass == 3) { if (labelFound == 1) { nextLine << " "; LABEL_A12_HIGH(ad); @@ -600,7 +629,7 @@ void DiStella::disasm(uInt32 distart, int pass) // the code can somehow track access to CPU registers mark(ad, CartDebug::ROW); } else if (pass == 3) { - if (ad < 0x100 && mySettings.fflag) + if (ad < 0x100 && mySettings.fFlag) nextLine << ".ind "; else nextLine << " "; @@ -625,24 +654,15 @@ void DiStella::disasm(uInt32 distart, int pass) break; } // end switch - if (pass == 1) { - // RTS/JMP/RTI always indicate the end of a block of CODE - if (!strcmp(ourLookup[op].mnemonic, "RTS") || - !strcmp(ourLookup[op].mnemonic, "JMP") || - /*!strcmp(ourLookup[op].mnemonic,"BRK") || */ // BRK may return here - !strcmp(ourLookup[op].mnemonic, "RTI")) { - myPCEnd = (myPC - 1) + myOffset; - return; - } - } else if (pass == 3) { - cycles += int(ourLookup[op].cycles); + if (pass == 3) { + cycles += int(ourLookup[opcode].cycles); // A complete line of disassembly (text, cycle count, and bytes) myDisasmBuf << nextLine.str() << "'" - << ";" << std::dec << int(ourLookup[op].cycles) + << ";" << std::dec << int(ourLookup[opcode].cycles) << (addrMode == RELATIVE ? (ad & 0xf00) != ((myPC + myOffset) & 0xf00) ? "/4!" : "/3 " : " "); - if ((op == 0x40 || op == 0x60 || op == 0x4c || op == 0x00 // code block end - || checkBit(myPC, CartDebug::REFERENCED) // referenced address - || /*addr_mode == ZERO_PAGE &&*/ ourLookup[op].rw_mode == WRITE && d1 == WSYNC) // strobe WSYNC + if ((opcode == 0x40 || opcode == 0x60 || opcode == 0x4c || opcode == 0x00 // code block end + || checkBit(myPC, CartDebug::REFERENCED) // referenced address + || ourLookup[opcode].rw_mode == WRITE && d1 == WSYNC) // strobe WSYNC && cycles > 0) { // output cycles for previous code block myDisasmBuf << "'= " << std::setw(3) << std::setfill(' ') << std::dec << cycles; @@ -653,7 +673,7 @@ void DiStella::disasm(uInt32 distart, int pass) myDisasmBuf << "'" << nextLineBytes.str(); addEntry(CartDebug::CODE); - if (op == 0x40 || op == 0x60 || op == 0x4c || op == 0x00) { + if (opcode == 0x40 || opcode == 0x60 || opcode == 0x4c || opcode == 0x00) { myDisasmBuf << " ' ' "; addEntry(CartDebug::NONE); mySegType = CartDebug::NONE; // prevent extra lines if data follows @@ -669,6 +689,154 @@ void DiStella::disasm(uInt32 distart, int pass) myPCEnd = myAppData.end + myOffset; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DiStella::disasmPass1(uInt32 distart) +{ + uInt8 opcode, d1; + uInt16 ad; + AddressingMode addrMode; + + myPC = distart - myOffset; + + while (myPC <= myAppData.end) { + + // abort when we reach non-code areas + if (checkBits(myPC, CartDebug::CartDebug::DATA | CartDebug::GFX | CartDebug::PGFX, CartDebug::CODE)) { + myPCEnd = (myPC - 1) + myOffset; + return; + } + + // so this should be code now... + // get opcode + opcode = Debugger::debugger().peek(myPC + myOffset); myPC++; + // get address mode for opcode + addrMode = ourLookup[opcode].addr_mode; + + // Add operand(s) for PC values outside the app data range + if (myPC >= myAppData.end) { + switch (addrMode) { + case ABSOLUTE: + case ABSOLUTE_X: + case ABSOLUTE_Y: + case INDIRECT_X: + case INDIRECT_Y: + case ABS_INDIRECT: + myPCEnd = myAppData.end + myOffset; + return; + + case ZERO_PAGE: + case IMMEDIATE: + case ZERO_PAGE_X: + case ZERO_PAGE_Y: + case RELATIVE: + if (myPC > myAppData.end) { + myPC++; + myPCEnd = myAppData.end + myOffset; + return; + } + + default: + break; + } // end switch(addr_mode) + } // end if (myPC >= myAppData.end) + + // Add operand(s) + switch (addrMode) { + case ABSOLUTE: + ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2; + mark(ad, CartDebug::REFERENCED); + // handle JMP/JSR + if (ourLookup[opcode].source == M_ADDR) { + // do NOT use flags set by debugger, else known CODE will not analyzed statically. + if (!checkBit(ad & myAppData.end, CartDebug::CODE, false)) { + if (ad > 0xfff) + myAddressQueue.push((ad & myAppData.end) + myOffset); + mark(ad, CartDebug::CODE); + } + } else + mark(ad, CartDebug::DATA); + break; + + case ZERO_PAGE: + d1 = Debugger::debugger().peek(myPC + myOffset); myPC++; + mark(d1, CartDebug::REFERENCED); + break; + + case IMMEDIATE: + myPC++; + break; + + case ABSOLUTE_X: + ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2; + mark(ad, CartDebug::REFERENCED); + break; + + case ABSOLUTE_Y: + ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2; + mark(ad, CartDebug::REFERENCED); + break; + + case INDIRECT_X: + myPC++; + break; + + case INDIRECT_Y: + myPC++; + break; + + case ZERO_PAGE_X: + d1 = Debugger::debugger().peek(myPC + myOffset); myPC++; + mark(d1, CartDebug::REFERENCED); + break; + + case ZERO_PAGE_Y: + d1 = Debugger::debugger().peek(myPC + myOffset); myPC++; + mark(d1, CartDebug::REFERENCED); + break; + + case RELATIVE: + // SA - 04-06-2010: there seemed to be a bug in distella, + // where wraparound occurred on a 32-bit int, and subsequent + // indexing into the labels array caused a crash + d1 = Debugger::debugger().peek(myPC + myOffset); myPC++; + ad = ((myPC + Int8(d1)) & 0xfff) + myOffset; + mark(ad, CartDebug::REFERENCED); + // do NOT use flags set by debugger, else known CODE will not analyzed statically. + if (!checkBit(ad - myOffset, CartDebug::CODE, false)) { + myAddressQueue.push(ad); + mark(ad, CartDebug::CODE); + } + break; + + case ABS_INDIRECT: + ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2; + mark(ad, CartDebug::REFERENCED); + break; + + default: + break; + } // end switch + + // mark BRK vector + if (opcode == 0x00) { + if (!myReserved.breakFound) { + ad = Debugger::debugger().dpeek(0xfffe, CartDebug::DATA); + myAddressQueue.push(ad); + mark(ad, CartDebug::CODE); + myReserved.breakFound = true; + } + } + + // JMP/RTS/RTI always indicate the end of a block of CODE + if (opcode == 0x4c || opcode == 0x60 || opcode == 0x40) { + // code block end + myPCEnd = (myPC - 1) + myOffset; + return; + } + } // while +} + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - int DiStella::mark(uInt32 address, uInt8 mask, bool directive) { @@ -719,6 +887,11 @@ int DiStella::mark(uInt32 address, uInt8 mask, bool directive) =========================================================== -----------------------------------------------------------------------*/ + /*if (address == 0xf5c2) { + address++; + address--; + }*/ + // Check for equates before ROM/ZP-RAM accesses, because the original logic // of Distella assumed either equates or ROM; it didn't take ZP-RAM into account CartDebug::AddrType type = myDbg.addressType(address); @@ -743,13 +916,12 @@ int DiStella::mark(uInt32 address, uInt8 mask, bool directive) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool DiStella::checkBit(uInt16 address, uInt8 mask) const +bool DiStella::checkBit(uInt16 address, uInt8 mask, bool useDebugger) const { // The REFERENCED and VALID_ENTRY flags are needed for any inspection of // an address // Since they're set only in the labels array (as the lower two bits), // they must be included in the other bitfields - // thrust26: ignoreStella is currently only used with addbranch uInt8 label = myLabels[address & myAppData.end], lastbits = label & 0x03, directive = myDirectives[address & myAppData.end] & 0xFC, @@ -759,16 +931,16 @@ bool DiStella::checkBit(uInt16 address, uInt8 mask) const if (directive) return (directive | lastbits) & mask; // Next, the results from a dynamic/runtime analysis are used (except for pass 1) - else if (myPass != 1 && ((debugger | lastbits) & mask)) + else if (useDebugger && ((debugger | lastbits) & mask)) return true; // Otherwise, default to static analysis from Distella else return label & mask; } -bool DiStella::checkBits(uInt16 address, uInt8 mask, uInt8 notMask) const +bool DiStella::checkBits(uInt16 address, uInt8 mask, uInt8 notMask, bool useDebugger) const { - return checkBit(address, mask) && !checkBit(address, notMask); + return checkBit(address, mask, useDebugger) && !checkBit(address, notMask, useDebugger); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -817,7 +989,7 @@ void DiStella::addEntry(CartDebug::DisasmType type) if (tag.label == EmptyString) { if (myDisasmBuf.peek() != ' ') getline(myDisasmBuf, tag.label, '\''); - else if (mySettings.show_addresses && tag.type == CartDebug::CODE) { + else if (mySettings.showAddresses && tag.type == CartDebug::CODE) { // Have addresses indented, to differentiate from actual labels tag.label = " " + Base::toString(tag.address, Base::F_16_4); tag.hllabel = false; @@ -893,7 +1065,7 @@ void DiStella::outputGraphics() for (uInt8 i = 0, c = byte; i < 8; ++i, c <<= 1) myDisasmBuf << ((c > 127) ? bitString : " "); myDisasmBuf << "| $" << Base::HEX4 << myPC + myOffset << "'"; - if (mySettings.gfx_format == Base::F_2) + if (mySettings.gfxFormat == Base::F_2) myDisasmBuf << Base::toString(byte, Base::F_2_8); else myDisasmBuf << Base::HEX2 << int(byte); @@ -937,7 +1109,7 @@ void DiStella::outputBytes(CartDebug::DisasmType type) lineEmpty = false; } // Otherwise, append bytes to the current line, up until the maximum - else if (++numBytes == mySettings.bwidth) { + else if (++numBytes == mySettings.bytesWidth) { addEntry(type); lineEmpty = true; } else { @@ -966,340 +1138,341 @@ void DiStella::processDirectives(const CartDebug::DirectiveList& directives) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DiStella::Settings DiStella::settings = { - Base::F_2, // gfx_format - true, // resolve_code (opposite of -d in Distella) - true, // show_addresses (not used externally; always off) - false, // aflag (-a in Distella) - true, // fflag (-f in Distella) - false, // rflag (-r in Distella) - 9 // number of bytes to use with .byte directive + Base::F_2, // gfxFormat + true, // resolveCode (opposite of -d in Distella) + true, // showAddresses (not used externally; always off) + false, // aFlag (-a in Distella) + true, // fFlag (-f in Distella) + false, // rFlag (-r in Distella) + false, // bFlag (-b in Distella) + 8+1 // number of bytes to use with .byte directive }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - const DiStella::Instruction_tag DiStella::ourLookup[256] = { /**** Positive ****/ - /* 00 */ { "BRK", IMPLIED, M_NONE, NONE, 7 }, /* Pseudo Absolute */ - /* 01 */ { "ORA", INDIRECT_X, M_INDX, READ, 6 }, /* (Indirect,X) */ - /* 02 */ { ".jam",IMPLIED, M_NONE, NONE, 0 }, /* TILT */ - /* 03 */ { "slo", INDIRECT_X, M_INDX, WRITE, 8 }, + /* 00 */{"brk", IMPLIED, M_NONE, NONE, 7, 1}, /* Pseudo Absolute */ + /* 01 */{"ora", INDIRECT_X, M_INDX, READ, 6, 2}, /* (Indirect,X) */ + /* 02 */{".JAM",IMPLIED, M_NONE, NONE, 0, 1}, /* TILT */ + /* 03 */{"SLO", INDIRECT_X, M_INDX, WRITE, 8, 2}, - /* 04 */ { "nop", ZERO_PAGE, M_NONE, NONE, 3 }, - /* 05 */ { "ORA", ZERO_PAGE, M_ZERO, READ, 3 }, /* Zeropage */ - /* 06 */ { "ASL", ZERO_PAGE, M_ZERO, WRITE, 5 }, /* Zeropage */ - /* 07 */ { "slo", ZERO_PAGE, M_ZERO, WRITE, 5 }, + /* 04 */{"NOP", ZERO_PAGE, M_NONE, NONE, 3, 2}, + /* 05 */{"ora", ZERO_PAGE, M_ZERO, READ, 3, 2}, /* Zeropage */ + /* 06 */{"asl", ZERO_PAGE, M_ZERO, WRITE, 5, 2}, /* Zeropage */ + /* 07 */{"SLO", ZERO_PAGE, M_ZERO, WRITE, 5, 2}, - /* 08 */ { "PHP", IMPLIED, M_SR, NONE, 3 }, - /* 09 */ { "ORA", IMMEDIATE, M_IMM, READ, 2 }, /* Immediate */ - /* 0a */ { "ASL", ACCUMULATOR, M_AC, WRITE, 2 }, /* Accumulator */ - /* 0b */ { "anc", IMMEDIATE, M_ACIM, READ, 2 }, + /* 08 */{"php", IMPLIED, M_SR, NONE, 3, 1}, + /* 09 */{"ora", IMMEDIATE, M_IMM, READ, 2, 2}, /* Immediate */ + /* 0a */{"asl", ACCUMULATOR, M_AC, WRITE, 2, 1}, /* Accumulator */ + /* 0b */{"ANC", IMMEDIATE, M_ACIM, READ, 2, 2}, - /* 0c */ { "nop", ABSOLUTE, M_NONE, NONE, 4 }, - /* 0d */ { "ORA", ABSOLUTE, M_ABS, READ, 4 }, /* Absolute */ - /* 0e */ { "ASL", ABSOLUTE, M_ABS, WRITE, 6 }, /* Absolute */ - /* 0f */ { "slo", ABSOLUTE, M_ABS, WRITE, 6 }, + /* 0c */{"NOP", ABSOLUTE, M_NONE, NONE, 4, 3}, + /* 0d */{"ora", ABSOLUTE, M_ABS, READ, 4, 3}, /* Absolute */ + /* 0e */{"asl", ABSOLUTE, M_ABS, WRITE, 6, 3}, /* Absolute */ + /* 0f */{"SLO", ABSOLUTE, M_ABS, WRITE, 6, 3}, - /* 10 */ { "BPL", RELATIVE, M_REL, READ, 2 }, - /* 11 */ { "ORA", INDIRECT_Y, M_INDY, READ, 5 }, /* (Indirect),Y */ - /* 12 */ { ".jam",IMPLIED, M_NONE, NONE, 0 }, /* TILT */ - /* 13 */ { "slo", INDIRECT_Y, M_INDY, WRITE, 8 }, + /* 10 */{"bpl", RELATIVE, M_REL, READ, 2, 2}, + /* 11 */{"ora", INDIRECT_Y, M_INDY, READ, 5, 2}, /* (Indirect),Y */ + /* 12 */{".JAM",IMPLIED, M_NONE, NONE, 0, 1}, /* TILT */ + /* 13 */{"SLO", INDIRECT_Y, M_INDY, WRITE, 8, 2}, - /* 14 */ { "nop", ZERO_PAGE_X, M_NONE, NONE, 4 }, - /* 15 */ { "ORA", ZERO_PAGE_X, M_ZERX, READ, 4 }, /* Zeropage,X */ - /* 16 */ { "ASL", ZERO_PAGE_X, M_ZERX, WRITE, 6 }, /* Zeropage,X */ - /* 17 */ { "slo", ZERO_PAGE_X, M_ZERX, WRITE, 6 }, + /* 14 */{"NOP", ZERO_PAGE_X, M_NONE, NONE, 4, 2}, + /* 15 */{"ora", ZERO_PAGE_X, M_ZERX, READ, 4, 2}, /* Zeropage,X */ + /* 16 */{"asl", ZERO_PAGE_X, M_ZERX, WRITE, 6, 2}, /* Zeropage,X */ + /* 17 */{"SLO", ZERO_PAGE_X, M_ZERX, WRITE, 6, 2}, - /* 18 */ { "CLC", IMPLIED, M_NONE, NONE, 2 }, - /* 19 */ { "ORA", ABSOLUTE_Y, M_ABSY, READ, 4 }, /* Absolute,Y */ - /* 1a */ { ".nop",IMPLIED, M_NONE, NONE, 2 }, - /* 1b */ { "slo", ABSOLUTE_Y, M_ABSY, WRITE, 7 }, + /* 18 */{"clc", IMPLIED, M_NONE, NONE, 2, 1}, + /* 19 */{"ora", ABSOLUTE_Y, M_ABSY, READ, 4, 3}, /* Absolute,Y */ + /* 1a */{"NOP", IMPLIED, M_NONE, NONE, 2, 1}, + /* 1b */{"SLO", ABSOLUTE_Y, M_ABSY, WRITE, 7, 3}, - /* 1c */ { "nop", ABSOLUTE_X, M_NONE, NONE, 4 }, - /* 1d */ { "ORA", ABSOLUTE_X, M_ABSX, READ, 4 }, /* Absolute,X */ - /* 1e */ { "ASL", ABSOLUTE_X, M_ABSX, WRITE, 7 }, /* Absolute,X */ - /* 1f */ { "slo", ABSOLUTE_X, M_ABSX, WRITE, 7 }, + /* 1c */{"NOP", ABSOLUTE_X, M_NONE, NONE, 4, 3}, + /* 1d */{"ora", ABSOLUTE_X, M_ABSX, READ, 4, 3}, /* Absolute,X */ + /* 1e */{"asl", ABSOLUTE_X, M_ABSX, WRITE, 7, 3}, /* Absolute,X */ + /* 1f */{"SLO", ABSOLUTE_X, M_ABSX, WRITE, 7, 3}, - /* 20 */ { "JSR", ABSOLUTE, M_ADDR, READ, 6 }, - /* 21 */ { "AND", INDIRECT_X, M_INDX, READ, 6 }, /* (Indirect ,X) */ - /* 22 */ { ".jam",IMPLIED, M_NONE, NONE, 0 }, /* TILT */ - /* 23 */ { "rla", INDIRECT_X, M_INDX, WRITE, 8 }, + /* 20 */{"jsr", ABSOLUTE, M_ADDR, READ, 6, 3}, + /* 21 */{"and", INDIRECT_X, M_INDX, READ, 6, 2}, /* (Indirect ,X) */ + /* 22 */{".JAM",IMPLIED, M_NONE, NONE, 0, 1}, /* TILT */ + /* 23 */{"RLA", INDIRECT_X, M_INDX, WRITE, 8, 2}, - /* 24 */ { "BIT", ZERO_PAGE, M_ZERO, READ, 3 }, /* Zeropage */ - /* 25 */ { "AND", ZERO_PAGE, M_ZERO, READ, 3 }, /* Zeropage */ - /* 26 */ { "ROL", ZERO_PAGE, M_ZERO, WRITE, 5 }, /* Zeropage */ - /* 27 */ { "rla", ZERO_PAGE, M_ZERO, WRITE, 5 }, + /* 24 */{"bit", ZERO_PAGE, M_ZERO, READ, 3, 2}, /* Zeropage */ + /* 25 */{"and", ZERO_PAGE, M_ZERO, READ, 3, 2}, /* Zeropage */ + /* 26 */{"rol", ZERO_PAGE, M_ZERO, WRITE, 5, 2}, /* Zeropage */ + /* 27 */{"RLA", ZERO_PAGE, M_ZERO, WRITE, 5, 2}, - /* 28 */ { "PLP", IMPLIED, M_NONE, NONE, 4 }, - /* 29 */ { "AND", IMMEDIATE, M_IMM, READ, 2 }, /* Immediate */ - /* 2a */ { "ROL", ACCUMULATOR, M_AC, WRITE, 2 }, /* Accumulator */ - /* 2b */ { ".anc",IMMEDIATE, M_ACIM, READ, 2 }, + /* 28 */{"plp", IMPLIED, M_NONE, NONE, 4, 1}, + /* 29 */{"and", IMMEDIATE, M_IMM, READ, 2, 2}, /* Immediate */ + /* 2a */{"rol", ACCUMULATOR, M_AC, WRITE, 2, 1}, /* Accumulator */ + /* 2b */{"ANC", IMMEDIATE, M_ACIM, READ, 2, 2}, - /* 2c */ { "BIT", ABSOLUTE, M_ABS, READ, 4 }, /* Absolute */ - /* 2d */ { "AND", ABSOLUTE, M_ABS, READ, 4 }, /* Absolute */ - /* 2e */ { "ROL", ABSOLUTE, M_ABS, WRITE, 6 }, /* Absolute */ - /* 2f */ { "rla", ABSOLUTE, M_ABS, WRITE, 6 }, + /* 2c */{"bit", ABSOLUTE, M_ABS, READ, 4, 3}, /* Absolute */ + /* 2d */{"and", ABSOLUTE, M_ABS, READ, 4, 3}, /* Absolute */ + /* 2e */{"rol", ABSOLUTE, M_ABS, WRITE, 6, 3}, /* Absolute */ + /* 2f */{"RLA", ABSOLUTE, M_ABS, WRITE, 6, 3}, - /* 30 */ { "BMI", RELATIVE, M_REL, READ, 2 }, - /* 31 */ { "AND", INDIRECT_Y, M_INDY, READ, 5 }, /* (Indirect),Y */ - /* 32 */ { ".jam",IMPLIED, M_NONE, NONE, 0 }, /* TILT */ - /* 33 */ { "rla", INDIRECT_Y, M_INDY, WRITE, 8 }, + /* 30 */{"bmi", RELATIVE, M_REL, READ, 2, 2}, + /* 31 */{"and", INDIRECT_Y, M_INDY, READ, 5, 2}, /* (Indirect),Y */ + /* 32 */{".JAM",IMPLIED, M_NONE, NONE, 0, 1}, /* TILT */ + /* 33 */{"RLA", INDIRECT_Y, M_INDY, WRITE, 8, 2}, - /* 34 */ { ".nop",ZERO_PAGE_X, M_NONE, NONE, 4 }, - /* 35 */ { "AND", ZERO_PAGE_X, M_ZERX, READ, 4 }, /* Zeropage,X */ - /* 36 */ { "ROL", ZERO_PAGE_X, M_ZERX, WRITE, 6 }, /* Zeropage,X */ - /* 37 */ { "rla", ZERO_PAGE_X, M_ZERX, WRITE, 6 }, + /* 34 */{"NOP", ZERO_PAGE_X, M_NONE, NONE, 4, 2}, + /* 35 */{"and", ZERO_PAGE_X, M_ZERX, READ, 4, 2}, /* Zeropage,X */ + /* 36 */{"rol", ZERO_PAGE_X, M_ZERX, WRITE, 6, 2}, /* Zeropage,X */ + /* 37 */{"RLA", ZERO_PAGE_X, M_ZERX, WRITE, 6, 2}, - /* 38 */ { "SEC", IMPLIED, M_NONE, NONE, 2 }, - /* 39 */ { "AND", ABSOLUTE_Y, M_ABSY, READ, 4 }, /* Absolute,Y */ - /* 3a */ { ".nop",IMPLIED, M_NONE, NONE, 2 }, - /* 3b */ { "rla", ABSOLUTE_Y, M_ABSY, WRITE, 7 }, + /* 38 */{"sec", IMPLIED, M_NONE, NONE, 2, 1}, + /* 39 */{"and", ABSOLUTE_Y, M_ABSY, READ, 4, 3}, /* Absolute,Y */ + /* 3a */{"NOP", IMPLIED, M_NONE, NONE, 2, 1}, + /* 3b */{"RLA", ABSOLUTE_Y, M_ABSY, WRITE, 7, 3}, - /* 3c */ { ".nop",ABSOLUTE_X, M_NONE, NONE, 4 }, - /* 3d */ { "AND", ABSOLUTE_X, M_ABSX, READ, 4 }, /* Absolute,X */ - /* 3e */ { "ROL", ABSOLUTE_X, M_ABSX, WRITE, 7 }, /* Absolute,X */ - /* 3f */ { "rla", ABSOLUTE_X, M_ABSX, WRITE, 7 }, + /* 3c */{"NOP", ABSOLUTE_X, M_NONE, NONE, 4, 3}, + /* 3d */{"and", ABSOLUTE_X, M_ABSX, READ, 4, 3}, /* Absolute,X */ + /* 3e */{"rol", ABSOLUTE_X, M_ABSX, WRITE, 7, 3}, /* Absolute,X */ + /* 3f */{"RLA", ABSOLUTE_X, M_ABSX, WRITE, 7, 3}, - /* 40 */ { "RTI", IMPLIED, M_NONE, NONE, 6 }, - /* 41 */ { "EOR", INDIRECT_X, M_INDX, READ, 6 }, /* (Indirect,X) */ - /* 42 */ { ".jam",IMPLIED, M_NONE, NONE, 0 }, /* TILT */ - /* 43 */ { "sre", INDIRECT_X, M_INDX, WRITE, 8 }, + /* 40 */{"rti", IMPLIED, M_NONE, NONE, 6, 1}, + /* 41 */{"eor", INDIRECT_X, M_INDX, READ, 6, 2}, /* (Indirect,X) */ + /* 42 */{".JAM",IMPLIED, M_NONE, NONE, 0, 1}, /* TILT */ + /* 43 */{"SRE", INDIRECT_X, M_INDX, WRITE, 8, 2}, - /* 44 */ { ".nop",ZERO_PAGE, M_NONE, NONE, 3 }, - /* 45 */ { "EOR", ZERO_PAGE, M_ZERO, READ, 3 }, /* Zeropage */ - /* 46 */ { "LSR", ZERO_PAGE, M_ZERO, WRITE, 5 }, /* Zeropage */ - /* 47 */ { "sre", ZERO_PAGE, M_ZERO, WRITE, 5 }, + /* 44 */{"NOP", ZERO_PAGE, M_NONE, NONE, 3, 2}, + /* 45 */{"eor", ZERO_PAGE, M_ZERO, READ, 3, 2}, /* Zeropage */ + /* 46 */{"lsr", ZERO_PAGE, M_ZERO, WRITE, 5, 2}, /* Zeropage */ + /* 47 */{"SRE", ZERO_PAGE, M_ZERO, WRITE, 5, 2}, - /* 48 */ { "PHA", IMPLIED, M_AC, NONE, 3 }, - /* 49 */ { "EOR", IMMEDIATE, M_IMM, READ, 2 }, /* Immediate */ - /* 4a */ { "LSR", ACCUMULATOR, M_AC, WRITE, 2 }, /* Accumulator */ - /* 4b */ { "asr", IMMEDIATE, M_ACIM, READ, 2 }, /* (AC & IMM) >>1 */ + /* 48 */{"pha", IMPLIED, M_AC, NONE, 3, 1}, + /* 49 */{"eor", IMMEDIATE, M_IMM, READ, 2, 2}, /* Immediate */ + /* 4a */{"lsr", ACCUMULATOR, M_AC, WRITE, 2, 1}, /* Accumulator */ + /* 4b */{"ASR", IMMEDIATE, M_ACIM, READ, 2, 2}, /* (AC & IMM) >>1 */ - /* 4c */ { "JMP", ABSOLUTE, M_ADDR, READ, 3 }, /* Absolute */ - /* 4d */ { "EOR", ABSOLUTE, M_ABS, READ, 4 }, /* Absolute */ - /* 4e */ { "LSR", ABSOLUTE, M_ABS, WRITE, 6 }, /* Absolute */ - /* 4f */ { "sre", ABSOLUTE, M_ABS, WRITE, 6 }, + /* 4c */{"jmp", ABSOLUTE, M_ADDR, READ, 3, 3}, /* Absolute */ + /* 4d */{"eor", ABSOLUTE, M_ABS, READ, 4, 3}, /* Absolute */ + /* 4e */{"lsr", ABSOLUTE, M_ABS, WRITE, 6, 3}, /* Absolute */ + /* 4f */{"SRE", ABSOLUTE, M_ABS, WRITE, 6, 3}, - /* 50 */ { "BVC", RELATIVE, M_REL, READ, 2 }, - /* 51 */ { "EOR", INDIRECT_Y, M_INDY, READ, 5 }, /* (Indirect),Y */ - /* 52 */ { ".jam",IMPLIED, M_NONE, NONE, 0 }, /* TILT */ - /* 53 */ { "sre", INDIRECT_Y, M_INDY, WRITE, 8 }, + /* 50 */{"bvc", RELATIVE, M_REL, READ, 2, 2}, + /* 51 */{"eor", INDIRECT_Y, M_INDY, READ, 5, 2}, /* (Indirect),Y */ + /* 52 */{".JAM",IMPLIED, M_NONE, NONE, 0, 1}, /* TILT */ + /* 53 */{"SRE", INDIRECT_Y, M_INDY, WRITE, 8, 2}, - /* 54 */ { ".nop",ZERO_PAGE_X, M_NONE, NONE, 4 }, - /* 55 */ { "EOR", ZERO_PAGE_X, M_ZERX, READ, 4 }, /* Zeropage,X */ - /* 56 */ { "LSR", ZERO_PAGE_X, M_ZERX, WRITE, 6 }, /* Zeropage,X */ - /* 57 */ { "sre", ZERO_PAGE_X, M_ZERX, WRITE, 6 }, + /* 54 */{"NOP", ZERO_PAGE_X, M_NONE, NONE, 4, 2}, + /* 55 */{"eor", ZERO_PAGE_X, M_ZERX, READ, 4, 2}, /* Zeropage,X */ + /* 56 */{"lsr", ZERO_PAGE_X, M_ZERX, WRITE, 6, 2}, /* Zeropage,X */ + /* 57 */{"SRE", ZERO_PAGE_X, M_ZERX, WRITE, 6, 2}, - /* 58 */ { "CLI", IMPLIED, M_NONE, NONE, 2 }, - /* 59 */ { "EOR", ABSOLUTE_Y, M_ABSY, READ, 4 }, /* Absolute,Y */ - /* 5a */ { ".nop",IMPLIED, M_NONE, NONE, 2 }, - /* 5b */ { "sre", ABSOLUTE_Y, M_ABSY, WRITE, 7 }, + /* 58 */{"cli", IMPLIED, M_NONE, NONE, 2, 1}, + /* 59 */{"eor", ABSOLUTE_Y, M_ABSY, READ, 4, 3}, /* Absolute,Y */ + /* 5a */{"NOP", IMPLIED, M_NONE, NONE, 2, 1}, + /* 5b */{"SRE", ABSOLUTE_Y, M_ABSY, WRITE, 7, 3}, - /* 5c */ { ".nop",ABSOLUTE_X, M_NONE, NONE, 4 }, - /* 5d */ { "EOR", ABSOLUTE_X, M_ABSX, READ, 4 }, /* Absolute,X */ - /* 5e */ { "LSR", ABSOLUTE_X, M_ABSX, WRITE, 7 }, /* Absolute,X */ - /* 5f */ { "sre", ABSOLUTE_X, M_ABSX, WRITE, 7 }, + /* 5c */{"NOP", ABSOLUTE_X, M_NONE, NONE, 4, 3}, + /* 5d */{"eor", ABSOLUTE_X, M_ABSX, READ, 4, 3}, /* Absolute,X */ + /* 5e */{"lsr", ABSOLUTE_X, M_ABSX, WRITE, 7, 3}, /* Absolute,X */ + /* 5f */{"SRE", ABSOLUTE_X, M_ABSX, WRITE, 7, 3}, - /* 60 */ { "RTS", IMPLIED, M_NONE, NONE, 6 }, - /* 61 */ { "ADC", INDIRECT_X, M_INDX, READ, 6 }, /* (Indirect,X) */ - /* 62 */ { ".jam",IMPLIED, M_NONE, NONE, 0 }, /* TILT */ - /* 63 */ { "rra", INDIRECT_X, M_INDX, WRITE, 8 }, + /* 60 */{"rts", IMPLIED, M_NONE, NONE, 6, 1}, + /* 61 */{"adc", INDIRECT_X, M_INDX, READ, 6, 2}, /* (Indirect,X) */ + /* 62 */{".JAM",IMPLIED, M_NONE, NONE, 0, 1}, /* TILT */ + /* 63 */{"RRA", INDIRECT_X, M_INDX, WRITE, 8, 2}, - /* 64 */ { ".nop",ZERO_PAGE, M_NONE, NONE, 3 }, - /* 65 */ { "ADC", ZERO_PAGE, M_ZERO, READ, 3 }, /* Zeropage */ - /* 66 */ { "ROR", ZERO_PAGE, M_ZERO, WRITE, 5 }, /* Zeropage */ - /* 67 */ { "rra", ZERO_PAGE, M_ZERO, WRITE, 5 }, + /* 64 */{"NOP", ZERO_PAGE, M_NONE, NONE, 3, 2}, + /* 65 */{"adc", ZERO_PAGE, M_ZERO, READ, 3, 2}, /* Zeropage */ + /* 66 */{"ror", ZERO_PAGE, M_ZERO, WRITE, 5, 2}, /* Zeropage */ + /* 67 */{"RRA", ZERO_PAGE, M_ZERO, WRITE, 5, 2}, - /* 68 */ { "PLA", IMPLIED, M_NONE, NONE, 4 }, - /* 69 */ { "ADC", IMMEDIATE, M_IMM, READ, 2 }, /* Immediate */ - /* 6a */ { "ROR", ACCUMULATOR, M_AC, WRITE, 2 }, /* Accumulator */ - /* 6b */ { "arr", IMMEDIATE, M_ACIM, READ, 2 }, /* ARR isn't typo */ + /* 68 */{"pla", IMPLIED, M_NONE, NONE, 4, 1}, + /* 69 */{"adc", IMMEDIATE, M_IMM, READ, 2, 2}, /* Immediate */ + /* 6a */{"ror", ACCUMULATOR, M_AC, WRITE, 2, 1}, /* Accumulator */ + /* 6b */{"ARR", IMMEDIATE, M_ACIM, READ, 2, 2}, /* ARR isn't typo */ - /* 6c */ { "JMP", ABS_INDIRECT,M_AIND, READ, 5 }, /* Indirect */ - /* 6d */ { "ADC", ABSOLUTE, M_ABS, READ, 4 }, /* Absolute */ - /* 6e */ { "ROR", ABSOLUTE, M_ABS, WRITE, 6 }, /* Absolute */ - /* 6f */ { "rra", ABSOLUTE, M_ABS, WRITE, 6 }, + /* 6c */{"jmp", ABS_INDIRECT,M_AIND, READ, 5, 3}, /* Indirect */ + /* 6d */{"adc", ABSOLUTE, M_ABS, READ, 4, 3}, /* Absolute */ + /* 6e */{"ror", ABSOLUTE, M_ABS, WRITE, 6, 3}, /* Absolute */ + /* 6f */{"RRA", ABSOLUTE, M_ABS, WRITE, 6, 3}, - /* 70 */ { "BVS", RELATIVE, M_REL, READ, 2 }, - /* 71 */ { "ADC", INDIRECT_Y, M_INDY, READ, 5 }, /* (Indirect),Y */ - /* 72 */ { ".jam",IMPLIED, M_NONE, NONE, 0 }, /* TILT relative? */ - /* 73 */ { "rra", INDIRECT_Y, M_INDY, WRITE, 8 }, + /* 70 */{"bvs", RELATIVE, M_REL, READ, 2, 2}, + /* 71 */{"adc", INDIRECT_Y, M_INDY, READ, 5, 2}, /* (Indirect),Y */ + /* 72 */{".JAM",IMPLIED, M_NONE, NONE, 0, 1}, /* TILT relative? */ + /* 73 */{"RRA", INDIRECT_Y, M_INDY, WRITE, 8, 2}, - /* 74 */ { ".nop",ZERO_PAGE_X, M_NONE, NONE, 4 }, - /* 75 */ { "ADC", ZERO_PAGE_X, M_ZERX, READ, 4 }, /* Zeropage,X */ - /* 76 */ { "ROR", ZERO_PAGE_X, M_ZERX, WRITE, 6 }, /* Zeropage,X */ - /* 77 */ { "rra", ZERO_PAGE_X, M_ZERX, WRITE, 6 }, + /* 74 */{"NOP", ZERO_PAGE_X, M_NONE, NONE, 4, 2}, + /* 75 */{"adc", ZERO_PAGE_X, M_ZERX, READ, 4, 2}, /* Zeropage,X */ + /* 76 */{"ror", ZERO_PAGE_X, M_ZERX, WRITE, 6, 2}, /* Zeropage,X */ + /* 77 */{"RRA", ZERO_PAGE_X, M_ZERX, WRITE, 6, 2}, - /* 78 */ { "SEI", IMPLIED, M_NONE, NONE, 2 }, - /* 79 */ { "ADC", ABSOLUTE_Y, M_ABSY, READ, 4 }, /* Absolute,Y */ - /* 7a */ { ".nop",IMPLIED, M_NONE, NONE, 2 }, - /* 7b */ { "rra", ABSOLUTE_Y, M_ABSY, WRITE, 7 }, + /* 78 */{"sei", IMPLIED, M_NONE, NONE, 2, 1}, + /* 79 */{"adc", ABSOLUTE_Y, M_ABSY, READ, 4, 3}, /* Absolute,Y */ + /* 7a */{"NOP", IMPLIED, M_NONE, NONE, 2, 1}, + /* 7b */{"RRA", ABSOLUTE_Y, M_ABSY, WRITE, 7, 3}, - /* 7c */ { ".nop",ABSOLUTE_X, M_NONE, NONE, 4 }, - /* 7d */ { "ADC", ABSOLUTE_X, M_ABSX, READ, 4 }, /* Absolute,X */ - /* 7e */ { "ROR", ABSOLUTE_X, M_ABSX, WRITE, 7 }, /* Absolute,X */ - /* 7f */ { "rra", ABSOLUTE_X, M_ABSX, WRITE, 7 }, + /* 7c */{"NOP", ABSOLUTE_X, M_NONE, NONE, 4, 3}, + /* 7d */{"adc", ABSOLUTE_X, M_ABSX, READ, 4, 3}, /* Absolute,X */ + /* 7e */{"ror", ABSOLUTE_X, M_ABSX, WRITE, 7, 3}, /* Absolute,X */ + /* 7f */{"RRA", ABSOLUTE_X, M_ABSX, WRITE, 7, 3}, /**** Negative ****/ - /* 80 */ { "nop", IMMEDIATE, M_NONE, NONE, 2 }, - /* 81 */ { "STA", INDIRECT_X, M_AC, WRITE, 6 }, /* (Indirect,X) */ - /* 82 */ { ".nop",IMMEDIATE, M_NONE, NONE, 2 }, - /* 83 */ { "sax", INDIRECT_X, M_ANXR, WRITE, 6 }, + /* 80 */{"NOP", IMMEDIATE, M_NONE, NONE, 2, 2}, + /* 81 */{"sta", INDIRECT_X, M_AC, WRITE, 6, 2}, /* (Indirect,X) */ + /* 82 */{"NOP", IMMEDIATE, M_NONE, NONE, 2, 2}, + /* 83 */{"SAX", INDIRECT_X, M_ANXR, WRITE, 6, 2}, - /* 84 */ { "STY", ZERO_PAGE, M_YR, WRITE, 3 }, /* Zeropage */ - /* 85 */ { "STA", ZERO_PAGE, M_AC, WRITE, 3 }, /* Zeropage */ - /* 86 */ { "STX", ZERO_PAGE, M_XR, WRITE, 3 }, /* Zeropage */ - /* 87 */ { "sax", ZERO_PAGE, M_ANXR, WRITE, 3 }, + /* 84 */{"sty", ZERO_PAGE, M_YR, WRITE, 3, 2}, /* Zeropage */ + /* 85 */{"sta", ZERO_PAGE, M_AC, WRITE, 3, 2}, /* Zeropage */ + /* 86 */{"stx", ZERO_PAGE, M_XR, WRITE, 3, 2}, /* Zeropage */ + /* 87 */{"SAX", ZERO_PAGE, M_ANXR, WRITE, 3, 2}, - /* 88 */ { "DEY", IMPLIED, M_YR, NONE, 2 }, - /* 89 */ { ".nop",IMMEDIATE, M_NONE, NONE, 2 }, - /* 8a */ { "TXA", IMPLIED, M_XR, NONE, 2 }, + /* 88 */{"dey", IMPLIED, M_YR, NONE, 2, 1}, + /* 89 */{"NOP", IMMEDIATE, M_NONE, NONE, 2, 2}, + /* 8a */{"txa", IMPLIED, M_XR, NONE, 2, 1}, /**** very abnormal: usually AC = AC | #$EE & XR & #$oper ****/ - /* 8b */ { "ane", IMMEDIATE, M_AXIM, READ, 2 }, + /* 8b */{"ANE", IMMEDIATE, M_AXIM, READ, 2, 2}, - /* 8c */ { "STY", ABSOLUTE, M_YR, WRITE, 4 }, /* Absolute */ - /* 8d */ { "STA", ABSOLUTE, M_AC, WRITE, 4 }, /* Absolute */ - /* 8e */ { "STX", ABSOLUTE, M_XR, WRITE, 4 }, /* Absolute */ - /* 8f */ { "sax", ABSOLUTE, M_ANXR, WRITE, 4 }, + /* 8c */{"sty", ABSOLUTE, M_YR, WRITE, 4, 3}, /* Absolute */ + /* 8d */{"sta", ABSOLUTE, M_AC, WRITE, 4, 3}, /* Absolute */ + /* 8e */{"stx", ABSOLUTE, M_XR, WRITE, 4, 3}, /* Absolute */ + /* 8f */{"SAX", ABSOLUTE, M_ANXR, WRITE, 4, 3}, - /* 90 */ { "BCC", RELATIVE, M_REL, READ, 2 }, - /* 91 */ { "STA", INDIRECT_Y, M_AC, WRITE, 6 }, /* (Indirect),Y */ - /* 92 */ { ".jam",IMPLIED, M_NONE, NONE, 0 }, /* TILT relative? */ - /* 93 */ { "sha", INDIRECT_Y, M_ANXR, WRITE, 6 }, + /* 90 */{"bcc", RELATIVE, M_REL, READ, 2, 2}, + /* 91 */{"sta", INDIRECT_Y, M_AC, WRITE, 6, 2}, /* (Indirect),Y */ + /* 92 */{".JAM",IMPLIED, M_NONE, NONE, 0, 1}, /* TILT relative? */ + /* 93 */{"SHA", INDIRECT_Y, M_ANXR, WRITE, 6, 2}, - /* 94 */ { "STY", ZERO_PAGE_X, M_YR, WRITE, 4 }, /* Zeropage,X */ - /* 95 */ { "STA", ZERO_PAGE_X, M_AC, WRITE, 4 }, /* Zeropage,X */ - /* 96 */ { "STX", ZERO_PAGE_Y, M_XR, WRITE, 4 }, /* Zeropage,Y */ - /* 97 */ { "sax", ZERO_PAGE_Y, M_ANXR, WRITE, 4 }, + /* 94 */{"sty", ZERO_PAGE_X, M_YR, WRITE, 4, 2}, /* Zeropage,X */ + /* 95 */{"sta", ZERO_PAGE_X, M_AC, WRITE, 4, 2}, /* Zeropage,X */ + /* 96 */{"stx", ZERO_PAGE_Y, M_XR, WRITE, 4, 2}, /* Zeropage,Y */ + /* 97 */{"SAX", ZERO_PAGE_Y, M_ANXR, WRITE, 4, 2}, - /* 98 */ { "TYA", IMPLIED, M_YR, NONE, 2 }, - /* 99 */ { "STA", ABSOLUTE_Y, M_AC, WRITE, 5 }, /* Absolute,Y */ - /* 9a */ { "TXS", IMPLIED, M_XR, NONE, 2 }, - /*** This is very mysterious comm AND ... */ - /* 9b */ { "shs", ABSOLUTE_Y, M_ANXR, WRITE, 5 }, + /* 98 */{"tya", IMPLIED, M_YR, NONE, 2, 1}, + /* 99 */{"sta", ABSOLUTE_Y, M_AC, WRITE, 5, 3}, /* Absolute,Y */ + /* 9a */{"txs", IMPLIED, M_XR, NONE, 2, 1}, + /*** This is very mysterious command ... */ + /* 9b */{"SHS", ABSOLUTE_Y, M_ANXR, WRITE, 5, 3}, - /* 9c */ { "shy", ABSOLUTE_X, M_YR, WRITE, 5 }, - /* 9d */ { "STA", ABSOLUTE_X, M_AC, WRITE, 5 }, /* Absolute,X */ - /* 9e */ { "shx", ABSOLUTE_Y, M_XR , WRITE, 5 }, - /* 9f */ { "sha", ABSOLUTE_Y, M_ANXR, WRITE, 5 }, + /* 9c */{"SHY", ABSOLUTE_X, M_YR, WRITE, 5, 3}, + /* 9d */{"sta", ABSOLUTE_X, M_AC, WRITE, 5, 3}, /* Absolute,X */ + /* 9e */{"SHX", ABSOLUTE_Y, M_XR , WRITE, 5, 3}, + /* 9f */{"SHA", ABSOLUTE_Y, M_ANXR, WRITE, 5, 3}, - /* a0 */ { "LDY", IMMEDIATE, M_IMM, READ, 2 }, /* Immediate */ - /* a1 */ { "LDA", INDIRECT_X, M_INDX, READ, 6 }, /* (indirect,X) */ - /* a2 */ { "LDX", IMMEDIATE, M_IMM, READ, 2 }, /* Immediate */ - /* a3 */ { "lax", INDIRECT_X, M_INDX, READ, 6 }, /* (indirect,X) */ + /* a0 */{"ldy", IMMEDIATE, M_IMM, READ, 2, 2}, /* Immediate */ + /* a1 */{"lda", INDIRECT_X, M_INDX, READ, 6, 2}, /* (indirect,X) */ + /* a2 */{"ldx", IMMEDIATE, M_IMM, READ, 2, 2}, /* Immediate */ + /* a3 */{"LAX", INDIRECT_X, M_INDX, READ, 6, 2}, /* (indirect,X) */ - /* a4 */ { "LDY", ZERO_PAGE, M_ZERO, READ, 3 }, /* Zeropage */ - /* a5 */ { "LDA", ZERO_PAGE, M_ZERO, READ, 3 }, /* Zeropage */ - /* a6 */ { "LDX", ZERO_PAGE, M_ZERO, READ, 3 }, /* Zeropage */ - /* a7 */ { "lax", ZERO_PAGE, M_ZERO, READ, 3 }, + /* a4 */{"ldy", ZERO_PAGE, M_ZERO, READ, 3, 2}, /* Zeropage */ + /* a5 */{"lda", ZERO_PAGE, M_ZERO, READ, 3, 2}, /* Zeropage */ + /* a6 */{"ldx", ZERO_PAGE, M_ZERO, READ, 3, 2}, /* Zeropage */ + /* a7 */{"LAX", ZERO_PAGE, M_ZERO, READ, 3, 2}, - /* a8 */ { "TAY", IMPLIED, M_AC, NONE, 2 }, - /* a9 */ { "LDA", IMMEDIATE, M_IMM, READ, 2 }, /* Immediate */ - /* aa */ { "TAX", IMPLIED, M_AC, NONE, 2 }, - /* ab */ { "lxa", IMMEDIATE, M_ACIM, READ, 2 }, /* LXA isn't a typo */ + /* a8 */{"tay", IMPLIED, M_AC, NONE, 2, 1}, + /* a9 */{"lda", IMMEDIATE, M_IMM, READ, 2, 2}, /* Immediate */ + /* aa */{"tax", IMPLIED, M_AC, NONE, 2, 1}, + /* ab */{"LXA", IMMEDIATE, M_ACIM, READ, 2, 2}, /* LXA isn't a typo */ - /* ac */ { "LDY", ABSOLUTE, M_ABS, READ, 4 }, /* Absolute */ - /* ad */ { "LDA", ABSOLUTE, M_ABS, READ, 4 }, /* Absolute */ - /* ae */ { "LDX", ABSOLUTE, M_ABS, READ, 4 }, /* Absolute */ - /* af */ { "lax", ABSOLUTE, M_ABS, READ, 4 }, + /* ac */{"ldy", ABSOLUTE, M_ABS, READ, 4, 3}, /* Absolute */ + /* ad */{"lda", ABSOLUTE, M_ABS, READ, 4, 3}, /* Absolute */ + /* ae */{"ldx", ABSOLUTE, M_ABS, READ, 4, 3}, /* Absolute */ + /* af */{"LAX", ABSOLUTE, M_ABS, READ, 4, 3}, - /* b0 */ { "BCS", RELATIVE, M_REL, READ, 2 }, - /* b1 */ { "LDA", INDIRECT_Y, M_INDY, READ, 5 }, /* (indirect),Y */ - /* b2 */ { ".jam",IMPLIED, M_NONE, NONE, 0 }, /* TILT */ - /* b3 */ { "lax", INDIRECT_Y, M_INDY, READ, 5 }, + /* b0 */{"bcs", RELATIVE, M_REL, READ, 2, 2}, + /* b1 */{"lda", INDIRECT_Y, M_INDY, READ, 5, 2}, /* (indirect),Y */ + /* b2 */{".JAM",IMPLIED, M_NONE, NONE, 0, 1}, /* TILT */ + /* b3 */{"LAX", INDIRECT_Y, M_INDY, READ, 5, 2}, - /* b4 */ { "LDY", ZERO_PAGE_X, M_ZERX, READ, 4 }, /* Zeropage,X */ - /* b5 */ { "LDA", ZERO_PAGE_X, M_ZERX, READ, 4 }, /* Zeropage,X */ - /* b6 */ { "LDX", ZERO_PAGE_Y, M_ZERY, READ, 4 }, /* Zeropage,Y */ - /* b7 */ { "lax", ZERO_PAGE_Y, M_ZERY, READ, 4 }, + /* b4 */{"ldy", ZERO_PAGE_X, M_ZERX, READ, 4, 2}, /* Zeropage,X */ + /* b5 */{"lda", ZERO_PAGE_X, M_ZERX, READ, 4, 2}, /* Zeropage,X */ + /* b6 */{"ldx", ZERO_PAGE_Y, M_ZERY, READ, 4, 2}, /* Zeropage,Y */ + /* b7 */{"LAX", ZERO_PAGE_Y, M_ZERY, READ, 4, 2}, - /* b8 */ { "CLV", IMPLIED, M_NONE, NONE, 2 }, - /* b9 */ { "LDA", ABSOLUTE_Y, M_ABSY, READ, 4 }, /* Absolute,Y */ - /* ba */ { "TSX", IMPLIED, M_SP, NONE, 2 }, - /* bb */ { "las", ABSOLUTE_Y, M_SABY, READ, 4 }, + /* b8 */{"clv", IMPLIED, M_NONE, NONE, 2, 1}, + /* b9 */{"lda", ABSOLUTE_Y, M_ABSY, READ, 4, 3}, /* Absolute,Y */ + /* ba */{"tsx", IMPLIED, M_SP, NONE, 2, 1}, + /* bb */{"LAS", ABSOLUTE_Y, M_SABY, READ, 4, 3}, - /* bc */ { "LDY", ABSOLUTE_X, M_ABSX, READ, 4 }, /* Absolute,X */ - /* bd */ { "LDA", ABSOLUTE_X, M_ABSX, READ, 4 }, /* Absolute,X */ - /* be */ { "LDX", ABSOLUTE_Y, M_ABSY, READ, 4 }, /* Absolute,Y */ - /* bf */ { "lax", ABSOLUTE_Y, M_ABSY, READ, 4 }, + /* bc */{"ldy", ABSOLUTE_X, M_ABSX, READ, 4, 3}, /* Absolute,X */ + /* bd */{"lda", ABSOLUTE_X, M_ABSX, READ, 4, 3}, /* Absolute,X */ + /* be */{"ldx", ABSOLUTE_Y, M_ABSY, READ, 4, 3}, /* Absolute,Y */ + /* bf */{"LAX", ABSOLUTE_Y, M_ABSY, READ, 4, 3}, - /* c0 */ { "CPY", IMMEDIATE, M_IMM, READ, 2 }, /* Immediate */ - /* c1 */ { "CMP", INDIRECT_X, M_INDX, READ, 6 }, /* (Indirect,X) */ - /* c2 */ { ".nop",IMMEDIATE, M_NONE, NONE, 2 }, /* occasional TILT */ - /* c3 */ { "dcp", INDIRECT_X, M_INDX, WRITE, 8 }, + /* c0 */{"cpy", IMMEDIATE, M_IMM, READ, 2, 2}, /* Immediate */ + /* c1 */{"cmp", INDIRECT_X, M_INDX, READ, 6, 2}, /* (Indirect,X) */ + /* c2 */{"NOP", IMMEDIATE, M_NONE, NONE, 2, 2}, /* occasional TILT */ + /* c3 */{"DCP", INDIRECT_X, M_INDX, WRITE, 8, 2}, - /* c4 */ { "CPY", ZERO_PAGE, M_ZERO, READ, 3 }, /* Zeropage */ - /* c5 */ { "CMP", ZERO_PAGE, M_ZERO, READ, 3 }, /* Zeropage */ - /* c6 */ { "DEC", ZERO_PAGE, M_ZERO, WRITE, 5 }, /* Zeropage */ - /* c7 */ { "dcp", ZERO_PAGE, M_ZERO, WRITE, 5 }, + /* c4 */{"cpy", ZERO_PAGE, M_ZERO, READ, 3, 2}, /* Zeropage */ + /* c5 */{"cmp", ZERO_PAGE, M_ZERO, READ, 3, 2}, /* Zeropage */ + /* c6 */{"dec", ZERO_PAGE, M_ZERO, WRITE, 5, 2}, /* Zeropage */ + /* c7 */{"DCP", ZERO_PAGE, M_ZERO, WRITE, 5, 2}, - /* c8 */ { "INY", IMPLIED, M_YR, NONE, 2 }, - /* c9 */ { "CMP", IMMEDIATE, M_IMM, READ, 2 }, /* Immediate */ - /* ca */ { "DEX", IMPLIED, M_XR, NONE, 2 }, - /* cb */ { "sbx", IMMEDIATE, M_IMM, READ, 2 }, + /* c8 */{"iny", IMPLIED, M_YR, NONE, 2, 1}, + /* c9 */{"cmp", IMMEDIATE, M_IMM, READ, 2, 2}, /* Immediate */ + /* ca */{"dex", IMPLIED, M_XR, NONE, 2, 1}, + /* cb */{"SBX", IMMEDIATE, M_IMM, READ, 2, 2}, - /* cc */ { "CPY", ABSOLUTE, M_ABS, READ, 4 }, /* Absolute */ - /* cd */ { "CMP", ABSOLUTE, M_ABS, READ, 4 }, /* Absolute */ - /* ce */ { "DEC", ABSOLUTE, M_ABS, WRITE, 6 }, /* Absolute */ - /* cf */ { "dcp", ABSOLUTE, M_ABS, WRITE, 6 }, + /* cc */{"cpy", ABSOLUTE, M_ABS, READ, 4, 3}, /* Absolute */ + /* cd */{"cmp", ABSOLUTE, M_ABS, READ, 4, 3}, /* Absolute */ + /* ce */{"dec", ABSOLUTE, M_ABS, WRITE, 6, 3}, /* Absolute */ + /* cf */{"DCP", ABSOLUTE, M_ABS, WRITE, 6, 3}, - /* d0 */ { "BNE", RELATIVE, M_REL, READ, 2 }, - /* d1 */ { "CMP", INDIRECT_Y, M_INDY, READ, 5 }, /* (Indirect),Y */ - /* d2 */ { ".jam",IMPLIED, M_NONE, NONE, 0 }, /* TILT */ - /* d3 */ { "dcp", INDIRECT_Y, M_INDY, WRITE, 8 }, + /* d0 */{"bne", RELATIVE, M_REL, READ, 2, 2}, + /* d1 */{"cmp", INDIRECT_Y, M_INDY, READ, 5, 2}, /* (Indirect),Y */ + /* d2 */{".JAM",IMPLIED, M_NONE, NONE, 0, 1}, /* TILT */ + /* d3 */{"DCP", INDIRECT_Y, M_INDY, WRITE, 8, 2}, - /* d4 */ { ".nop",ZERO_PAGE_X, M_NONE, NONE, 4 }, - /* d5 */ { "CMP", ZERO_PAGE_X, M_ZERX, READ, 4 }, /* Zeropage,X */ - /* d6 */ { "DEC", ZERO_PAGE_X, M_ZERX, WRITE, 6 }, /* Zeropage,X */ - /* d7 */ { "dcp", ZERO_PAGE_X, M_ZERX, WRITE, 6 }, + /* d4 */{"NOP", ZERO_PAGE_X, M_NONE, NONE, 4, 2}, + /* d5 */{"cmp", ZERO_PAGE_X, M_ZERX, READ, 4, 2}, /* Zeropage,X */ + /* d6 */{"dec", ZERO_PAGE_X, M_ZERX, WRITE, 6, 2}, /* Zeropage,X */ + /* d7 */{"DCP", ZERO_PAGE_X, M_ZERX, WRITE, 6, 2}, - /* d8 */ { "CLD", IMPLIED, M_NONE, NONE, 2 }, - /* d9 */ { "CMP", ABSOLUTE_Y, M_ABSY, READ, 4 }, /* Absolute,Y */ - /* da */ { ".nop",IMPLIED, M_NONE, NONE, 2 }, - /* db */ { "dcp", ABSOLUTE_Y, M_ABSY, WRITE, 7 }, + /* d8 */{"cld", IMPLIED, M_NONE, NONE, 2, 1}, + /* d9 */{"cmp", ABSOLUTE_Y, M_ABSY, READ, 4, 3}, /* Absolute,Y */ + /* da */{"NOP", IMPLIED, M_NONE, NONE, 2, 1}, + /* db */{"DCP", ABSOLUTE_Y, M_ABSY, WRITE, 7, 3}, - /* dc */ { ".nop",ABSOLUTE_X, M_NONE, NONE, 4 }, - /* dd */ { "CMP", ABSOLUTE_X, M_ABSX, READ, 4 }, /* Absolute,X */ - /* de */ { "DEC", ABSOLUTE_X, M_ABSX, WRITE, 7 }, /* Absolute,X */ - /* df */ { "dcp", ABSOLUTE_X, M_ABSX, WRITE, 7 }, + /* dc */{"NOP", ABSOLUTE_X, M_NONE, NONE, 4, 3}, + /* dd */{"cmp", ABSOLUTE_X, M_ABSX, READ, 4, 3}, /* Absolute,X */ + /* de */{"dec", ABSOLUTE_X, M_ABSX, WRITE, 7, 3}, /* Absolute,X */ + /* df */{"DCP", ABSOLUTE_X, M_ABSX, WRITE, 7, 3}, - /* e0 */ { "CPX", IMMEDIATE, M_IMM, READ, 2 }, /* Immediate */ - /* e1 */ { "SBC", INDIRECT_X, M_INDX, READ, 6 }, /* (Indirect,X) */ - /* e2 */ { ".nop",IMMEDIATE, M_NONE, NONE, 2 }, - /* e3 */ { "isb", INDIRECT_X, M_INDX, WRITE, 8 }, + /* e0 */{"cpx", IMMEDIATE, M_IMM, READ, 2, 2}, /* Immediate */ + /* e1 */{"sbc", INDIRECT_X, M_INDX, READ, 6, 2}, /* (Indirect,X) */ + /* e2 */{"NOP", IMMEDIATE, M_NONE, NONE, 2, 2}, + /* e3 */{"ISB", INDIRECT_X, M_INDX, WRITE, 8, 2}, - /* e4 */ { "CPX", ZERO_PAGE, M_ZERO, READ, 3 }, /* Zeropage */ - /* e5 */ { "SBC", ZERO_PAGE, M_ZERO, READ, 3 }, /* Zeropage */ - /* e6 */ { "INC", ZERO_PAGE, M_ZERO, WRITE, 5 }, /* Zeropage */ - /* e7 */ { "isb", ZERO_PAGE, M_ZERO, WRITE, 5 }, + /* e4 */{"cpx", ZERO_PAGE, M_ZERO, READ, 3, 2}, /* Zeropage */ + /* e5 */{"sbc", ZERO_PAGE, M_ZERO, READ, 3, 2}, /* Zeropage */ + /* e6 */{"inc", ZERO_PAGE, M_ZERO, WRITE, 5, 2}, /* Zeropage */ + /* e7 */{"ISB", ZERO_PAGE, M_ZERO, WRITE, 5, 2}, - /* e8 */ { "INX", IMPLIED, M_XR, NONE, 2 }, - /* e9 */ { "SBC", IMMEDIATE, M_IMM, READ, 2 }, /* Immediate */ - /* ea */ { "NOP", IMPLIED, M_NONE, NONE, 2 }, - /* eb */ { ".sbc",IMMEDIATE, M_IMM, READ, 2 }, /* same as e9 */ + /* e8 */{"inx", IMPLIED, M_XR, NONE, 2, 1}, + /* e9 */{"sbc", IMMEDIATE, M_IMM, READ, 2, 2}, /* Immediate */ + /* ea */{"nop", IMPLIED, M_NONE, NONE, 2, 1}, + /* eb */{"SBC", IMMEDIATE, M_IMM, READ, 2, 2}, /* same as e9 */ - /* ec */ { "CPX", ABSOLUTE, M_ABS, READ, 4 }, /* Absolute */ - /* ed */ { "SBC", ABSOLUTE, M_ABS, READ, 4 }, /* Absolute */ - /* ee */ { "INC", ABSOLUTE, M_ABS, WRITE, 6 }, /* Absolute */ - /* ef */ { "isb", ABSOLUTE, M_ABS, WRITE, 6 }, + /* ec */{"cpx", ABSOLUTE, M_ABS, READ, 4, 3}, /* Absolute */ + /* ed */{"sbc", ABSOLUTE, M_ABS, READ, 4, 3}, /* Absolute */ + /* ee */{"inc", ABSOLUTE, M_ABS, WRITE, 6, 3}, /* Absolute */ + /* ef */{"ISB", ABSOLUTE, M_ABS, WRITE, 6, 3}, - /* f0 */ { "BEQ", RELATIVE, M_REL, READ, 2 }, - /* f1 */ { "SBC", INDIRECT_Y, M_INDY, READ, 5 }, /* (Indirect),Y */ - /* f2 */ { ".jam",IMPLIED, M_NONE, NONE, 0 }, /* TILT */ - /* f3 */ { "isb", INDIRECT_Y, M_INDY, WRITE, 8 }, + /* f0 */{"beq", RELATIVE, M_REL, READ, 2, 2}, + /* f1 */{"sbc", INDIRECT_Y, M_INDY, READ, 5, 2}, /* (Indirect),Y */ + /* f2 */{".JAM",IMPLIED, M_NONE, NONE, 0, 1}, /* TILT */ + /* f3 */{"ISB", INDIRECT_Y, M_INDY, WRITE, 8, 2}, - /* f4 */ { ".nop",ZERO_PAGE_X, M_NONE, NONE, 4 }, - /* f5 */ { "SBC", ZERO_PAGE_X, M_ZERX, READ, 4 }, /* Zeropage,X */ - /* f6 */ { "INC", ZERO_PAGE_X, M_ZERX, WRITE, 6 }, /* Zeropage,X */ - /* f7 */ { "isb", ZERO_PAGE_X, M_ZERX, WRITE, 6 }, + /* f4 */{"NOP", ZERO_PAGE_X, M_NONE, NONE, 4, 2}, + /* f5 */{"sbc", ZERO_PAGE_X, M_ZERX, READ, 4, 2}, /* Zeropage,X */ + /* f6 */{"inc", ZERO_PAGE_X, M_ZERX, WRITE, 6, 2}, /* Zeropage,X */ + /* f7 */{"ISB", ZERO_PAGE_X, M_ZERX, WRITE, 6, 2}, - /* f8 */ { "SED", IMPLIED, M_NONE, NONE, 2 }, - /* f9 */ { "SBC", ABSOLUTE_Y, M_ABSY, READ, 4 }, /* Absolute,Y */ - /* fa */ { ".nop",IMPLIED, M_NONE, NONE, 2 }, - /* fb */ { "isb", ABSOLUTE_Y, M_ABSY, WRITE, 7 }, + /* f8 */{"sed", IMPLIED, M_NONE, NONE, 2, 1}, + /* f9 */{"sbc", ABSOLUTE_Y, M_ABSY, READ, 4, 3}, /* Absolute,Y */ + /* fa */{"NOP", IMPLIED, M_NONE, NONE, 2, 1}, + /* fb */{"ISB", ABSOLUTE_Y, M_ABSY, WRITE, 7, 3}, - /* fc */ { ".nop",ABSOLUTE_X, M_NONE, NONE, 4 }, - /* fd */ { "SBC", ABSOLUTE_X, M_ABSX, READ, 4 }, /* Absolute,X */ - /* fe */ { "INC", ABSOLUTE_X, M_ABSX, WRITE, 7 }, /* Absolute,X */ - /* ff */ { "isb", ABSOLUTE_X, M_ABSX, WRITE, 7 } + /* fc */{"NOP" ,ABSOLUTE_X, M_NONE, NONE, 4, 3}, + /* fd */{"sbc", ABSOLUTE_X, M_ABSX, READ, 4, 3}, /* Absolute,X */ + /* fe */{"inc", ABSOLUTE_X, M_ABSX, WRITE, 7, 3}, /* Absolute,X */ + /* ff */{"ISB", ABSOLUTE_X, M_ABSX, WRITE, 7, 3} }; diff --git a/src/debugger/DiStella.hxx b/src/debugger/DiStella.hxx index d0353d144..0ea754e5b 100644 --- a/src/debugger/DiStella.hxx +++ b/src/debugger/DiStella.hxx @@ -42,13 +42,14 @@ class DiStella // This will eventually grow to include all options supported by // standalone Distella struct Settings { - Common::Base::Format gfx_format; - bool resolve_code; // Attempt to detect code vs. data sections - bool show_addresses; // Show PC addresses (always off for external output) - bool aflag; // Turns 'A' off in accumulator instructions (-a in Distella) - bool fflag; // Forces correct address length (-f in Distella) - bool rflag; // Relocate calls out of address range (-r in Distella) - int bwidth; // Number of bytes to use per line (with .byte xxx) + Common::Base::Format gfxFormat; + bool resolveCode; // Attempt to detect code vs. data sections + bool showAddresses; // Show PC addresses (always off for external output) + bool aFlag; // Turns 'A' off in accumulator instructions (-a in Distella) + bool fFlag; // Forces correct address length (-f in Distella) + bool rFlag; // Relocate calls out of address range (-r in Distella) + bool bFlag; // Process break routine (-b in Distella) + int bytesWidth; // Number of bytes to use per line (with .byte xxx) }; static Settings settings; // Default settings @@ -81,11 +82,13 @@ class DiStella // These functions are part of the original Distella code void disasm(uInt32 distart, int pass); + void disasmPass1(uInt32 distart); + bool check_range(uInt16 start, uInt16 end) const; int mark(uInt32 address, uInt8 mask, bool directive = false); - bool checkBit(uInt16 address, uInt8 mask) const; + bool checkBit(uInt16 address, uInt8 mask, bool useDebugger = true) const; - bool DiStella::checkBits(uInt16 address, uInt8 mask, uInt8 notMask) const; + bool checkBits(uInt16 address, uInt8 mask, uInt8 notMask, bool useDebugger = true) const; void outputGraphics(); void outputBytes(CartDebug::DisasmType type); @@ -118,7 +121,7 @@ class DiStella CartDebug::ReservedEquates& myReserved; stringstream myDisasmBuf; std::queue myAddressQueue; - uInt16 myOffset, myPC, myPCEnd, myPass; + uInt16 myOffset, myPC, myPCEnd; uInt16 mySegType; struct resource { @@ -184,6 +187,7 @@ class DiStella AccessMode source; ReadWriteMode rw_mode; uInt8 cycles; + uInt8 bytes; }; static const Instruction_tag ourLookup[256]; diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index f3b1183ba..a2fe75564 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -582,7 +582,7 @@ void RomListWidget::startEditMode() { case CartDebug::GFX: case CartDebug::PGFX: - _base = DiStella::settings.gfx_format; + _base = DiStella::settings.gfxFormat; break; default: _base = Common::Base::format(); diff --git a/src/debugger/gui/RomWidget.cxx b/src/debugger/gui/RomWidget.cxx index 921c322c8..4a5a19bc1 100644 --- a/src/debugger/gui/RomWidget.cxx +++ b/src/debugger/gui/RomWidget.cxx @@ -122,18 +122,18 @@ void RomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) case RomListWidget::kTentativeCodeCmd: { // 'data' is the boolean value - DiStella::settings.resolve_code = data; + DiStella::settings.resolveCode = data; instance().settings().setValue("dis.resolve", - DiStella::settings.resolve_code); + DiStella::settings.resolveCode); invalidate(); break; } case RomListWidget::kPCAddressesCmd: // 'data' is the boolean value - DiStella::settings.show_addresses = data; + DiStella::settings.showAddresses = data; instance().settings().setValue("dis.showaddr", - DiStella::settings.show_addresses); + DiStella::settings.showAddresses); invalidate(); break; @@ -141,12 +141,12 @@ void RomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) // 'data' is the boolean value if(data) { - DiStella::settings.gfx_format = Common::Base::F_2; + DiStella::settings.gfxFormat = Common::Base::F_2; instance().settings().setValue("dis.gfxformat", "2"); } else { - DiStella::settings.gfx_format = Common::Base::F_16; + DiStella::settings.gfxFormat = Common::Base::F_16; instance().settings().setValue("dis.gfxformat", "16"); } invalidate(); @@ -154,9 +154,9 @@ void RomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) case RomListWidget::kAddrRelocationCmd: // 'data' is the boolean value - DiStella::settings.rflag = data; + DiStella::settings.rFlag = data; instance().settings().setValue("dis.relocate", - DiStella::settings.rflag); + DiStella::settings.rFlag); invalidate(); break; } diff --git a/src/emucore/M6502.ins b/src/emucore/M6502.ins index 997cfa6a9..ead0fccb6 100644 --- a/src/emucore/M6502.ins +++ b/src/emucore/M6502.ins @@ -38,7 +38,7 @@ #ifndef CLEAR_LAST_PEEK #ifdef DEBUGGER_SUPPORT - #define CLEAR_LAST_PEEK(_addr) _addr = -1; + #define CLEAR_LAST_PEEK(_addr) _addr = 0; #else #define CLEAR_LAST_PEEK(_addr) #endif @@ -266,8 +266,8 @@ - - +////////////////////////////////////////////////// +// ADC case 0x69: { operand = peek(PC++, DISASM_CODE); @@ -344,7 +344,7 @@ break; case 0x75: { intermediateAddress = peek(PC++, DISASM_CODE); - peek(intermediateAddress, DISASM_DATA); + peek(intermediateAddress, DISASM_NONE); intermediateAddress += X; operand = peek(intermediateAddress, DISASM_DATA); } @@ -423,11 +423,15 @@ case 0x7d: uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); intermediateAddress = high | uInt8(low + X); - operand = peek(intermediateAddress, DISASM_DATA); if((low + X) > 0xFF) { + operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + X; operand = peek(intermediateAddress, DISASM_DATA); + } + else + { + operand = peek(intermediateAddress, DISASM_DATA); } } { @@ -467,12 +471,16 @@ case 0x79: uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); intermediateAddress = high | uInt8(low + Y); - operand = peek(intermediateAddress, DISASM_DATA); if((low + Y) > 0xFF) { + operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + Y; operand = peek(intermediateAddress, DISASM_DATA); } + else + { + operand = peek(intermediateAddress, DISASM_DATA); + } } { if(!D) @@ -509,7 +517,7 @@ break; case 0x61: { uInt8 pointer = peek(PC++, DISASM_CODE); - peek(pointer, DISASM_DATA); + peek(pointer, DISASM_NONE); pointer += X; intermediateAddress = peek(pointer++, DISASM_DATA); intermediateAddress |= (uInt16(peek(pointer, DISASM_DATA)) << 8); @@ -553,12 +561,16 @@ case 0x71: uInt16 low = peek(pointer++, DISASM_DATA); uInt16 high = (uInt16(peek(pointer, DISASM_DATA)) << 8); intermediateAddress = high | uInt8(low + Y); - operand = peek(intermediateAddress, DISASM_DATA); if((low + Y) > 0xFF) { + operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + Y; operand = peek(intermediateAddress, DISASM_DATA); } + else + { + operand = peek(intermediateAddress, DISASM_DATA); + } } { if(!D) @@ -592,7 +604,8 @@ case 0x71: } break; - +////////////////////////////////////////////////// +// ASR case 0x4b: { operand = peek(PC++, DISASM_CODE); @@ -610,7 +623,8 @@ case 0x4b: } break; - +////////////////////////////////////////////////// +// ANC case 0x0b: case 0x2b: { @@ -624,7 +638,8 @@ case 0x2b: } break; - +////////////////////////////////////////////////// +// AND case 0x29: { operand = peek(PC++, DISASM_CODE); @@ -651,7 +666,7 @@ break; case 0x35: { intermediateAddress = peek(PC++, DISASM_CODE); - peek(intermediateAddress, DISASM_DATA); + peek(intermediateAddress, DISASM_NONE); intermediateAddress += X; operand = peek(intermediateAddress, DISASM_DATA); } @@ -680,11 +695,15 @@ case 0x3d: uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); intermediateAddress = high | uInt8(low + X); - operand = peek(intermediateAddress, DISASM_DATA); if((low + X) > 0xFF) { + operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + X; operand = peek(intermediateAddress, DISASM_DATA); + } + else + { + operand = peek(intermediateAddress, DISASM_DATA); } } { @@ -699,12 +718,16 @@ case 0x39: uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); intermediateAddress = high | uInt8(low + Y); - operand = peek(intermediateAddress, DISASM_DATA); if((low + Y) > 0xFF) { + operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + Y; operand = peek(intermediateAddress, DISASM_DATA); } + else + { + operand = peek(intermediateAddress, DISASM_DATA); + } } { A &= operand; @@ -716,7 +739,7 @@ break; case 0x21: { uInt8 pointer = peek(PC++, DISASM_CODE); - peek(pointer, DISASM_DATA); + peek(pointer, DISASM_NONE); pointer += X; intermediateAddress = peek(pointer++, DISASM_DATA); intermediateAddress |= (uInt16(peek(pointer, DISASM_DATA)) << 8); @@ -735,12 +758,16 @@ case 0x31: uInt16 low = peek(pointer++, DISASM_DATA); uInt16 high = (uInt16(peek(pointer, DISASM_DATA)) << 8); intermediateAddress = high | uInt8(low + Y); - operand = peek(intermediateAddress, DISASM_DATA); if((low + Y) > 0xFF) { + operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + Y; operand = peek(intermediateAddress, DISASM_DATA); } + else + { + operand = peek(intermediateAddress, DISASM_DATA); + } } { A &= operand; @@ -749,7 +776,8 @@ case 0x31: } break; - +////////////////////////////////////////////////// +// ANE case 0x8b: { operand = peek(PC++, DISASM_CODE); @@ -764,7 +792,8 @@ case 0x8b: } break; - +////////////////////////////////////////////////// +// ARR case 0x6b: { operand = peek(PC++, DISASM_CODE); @@ -811,7 +840,8 @@ case 0x6b: } break; - +////////////////////////////////////////////////// +// ASL case 0x0a: { peek(PC, DISASM_NONE); @@ -848,7 +878,7 @@ break; case 0x16: { operandAddress = peek(PC++, DISASM_CODE); - peek(operandAddress, DISASM_DATA); + peek(operandAddress, DISASM_NONE); operandAddress = (operandAddress + X) & 0xFF; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -888,7 +918,7 @@ case 0x1e: { uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); - peek(high | uInt8(low + X), DISASM_DATA); + peek(high | uInt8(low + X), DISASM_NONE); operandAddress = (high | low) + X; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -905,7 +935,35 @@ case 0x1e: } break; +////////////////////////////////////////////////// +// BIT +case 0x24: +{ + intermediateAddress = peek(PC++, DISASM_CODE); + operand = peek(intermediateAddress, DISASM_DATA); +} +{ + notZ = (A & operand); + N = operand & 0x80; + V = operand & 0x40; +} +break; +case 0x2C: +{ + intermediateAddress = peek(PC++, DISASM_CODE); + intermediateAddress |= (uInt16(peek(PC++, DISASM_CODE)) << 8); + operand = peek(intermediateAddress, DISASM_DATA); +} +{ + notZ = (A & operand); + N = operand & 0x80; + V = operand & 0x40; +} +break; + +////////////////////////////////////////////////// +// Branches case 0x90: { operand = peek(PC++, DISASM_CODE); @@ -957,32 +1015,6 @@ case 0xf0: break; -case 0x24: -{ - intermediateAddress = peek(PC++, DISASM_CODE); - operand = peek(intermediateAddress, DISASM_DATA); -} -{ - notZ = (A & operand); - N = operand & 0x80; - V = operand & 0x40; -} -break; - -case 0x2C: -{ - intermediateAddress = peek(PC++, DISASM_CODE); - intermediateAddress |= (uInt16(peek(PC++, DISASM_CODE)) << 8); - operand = peek(intermediateAddress, DISASM_DATA); -} -{ - notZ = (A & operand); - N = operand & 0x80; - V = operand & 0x40; -} -break; - - case 0x30: { operand = peek(PC++, DISASM_CODE); @@ -1034,24 +1066,6 @@ case 0x10: break; -case 0x00: -{ - peek(PC++, DISASM_CODE); - - B = true; - - poke(0x0100 + SP--, PC >> 8); - poke(0x0100 + SP--, PC & 0x00ff); - poke(0x0100 + SP--, PS()); - - I = true; - - PC = peek(0xfffe, DISASM_NONE); - PC |= (uInt16(peek(0xffff, DISASM_NONE)) << 8); -} -break; - - case 0x50: { operand = peek(PC++, DISASM_CODE); @@ -1085,7 +1099,27 @@ case 0x70: } break; +////////////////////////////////////////////////// +// BRK +case 0x00: +{ + peek(PC++, DISASM_NONE); + B = true; + + poke(0x0100 + SP--, PC >> 8); + poke(0x0100 + SP--, PC & 0x00ff); + poke(0x0100 + SP--, PS()); + + I = true; + + PC = peek(0xfffe, DISASM_DATA); + PC |= (uInt16(peek(0xffff, DISASM_DATA)) << 8); +} +break; + +////////////////////////////////////////////////// +// CLC case 0x18: { peek(PC, DISASM_NONE); @@ -1095,7 +1129,8 @@ case 0x18: } break; - +////////////////////////////////////////////////// +// CLD case 0xd8: { peek(PC, DISASM_NONE); @@ -1105,7 +1140,8 @@ case 0xd8: } break; - +////////////////////////////////////////////////// +// CLI case 0x58: { peek(PC, DISASM_NONE); @@ -1115,7 +1151,8 @@ case 0x58: } break; - +////////////////////////////////////////////////// +// CLV case 0xb8: { peek(PC, DISASM_NONE); @@ -1125,7 +1162,8 @@ case 0xb8: } break; - +////////////////////////////////////////////////// +// CMP case 0xc9: { operand = peek(PC++, DISASM_CODE); @@ -1156,7 +1194,7 @@ break; case 0xd5: { intermediateAddress = peek(PC++, DISASM_CODE); - peek(intermediateAddress, DISASM_DATA); + peek(intermediateAddress, DISASM_NONE); intermediateAddress += X; operand = peek(intermediateAddress, DISASM_DATA); } @@ -1189,11 +1227,15 @@ case 0xdd: uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); intermediateAddress = high | uInt8(low + X); - operand = peek(intermediateAddress, DISASM_DATA); if((low + X) > 0xFF) { + operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + X; operand = peek(intermediateAddress, DISASM_DATA); + } + else + { + operand = peek(intermediateAddress, DISASM_DATA); } } { @@ -1210,12 +1252,16 @@ case 0xd9: uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); intermediateAddress = high | uInt8(low + Y); - operand = peek(intermediateAddress, DISASM_DATA); if((low + Y) > 0xFF) { + operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + Y; operand = peek(intermediateAddress, DISASM_DATA); } + else + { + operand = peek(intermediateAddress, DISASM_DATA); + } } { uInt16 value = uInt16(A) - uInt16(operand); @@ -1229,7 +1275,7 @@ break; case 0xc1: { uInt8 pointer = peek(PC++, DISASM_CODE); - peek(pointer, DISASM_DATA); + peek(pointer, DISASM_NONE); pointer += X; intermediateAddress = peek(pointer++, DISASM_DATA); intermediateAddress |= (uInt16(peek(pointer, DISASM_DATA)) << 8); @@ -1250,12 +1296,16 @@ case 0xd1: uInt16 low = peek(pointer++, DISASM_DATA); uInt16 high = (uInt16(peek(pointer, DISASM_DATA)) << 8); intermediateAddress = high | uInt8(low + Y); - operand = peek(intermediateAddress, DISASM_DATA); if((low + Y) > 0xFF) { + operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + Y; operand = peek(intermediateAddress, DISASM_DATA); } + else + { + operand = peek(intermediateAddress, DISASM_DATA); + } } { uInt16 value = uInt16(A) - uInt16(operand); @@ -1266,7 +1316,8 @@ case 0xd1: } break; - +////////////////////////////////////////////////// +// CPX case 0xe0: { operand = peek(PC++, DISASM_CODE); @@ -1309,7 +1360,8 @@ case 0xec: } break; - +////////////////////////////////////////////////// +// CPY case 0xc0: { operand = peek(PC++, DISASM_CODE); @@ -1352,7 +1404,8 @@ case 0xcc: } break; - +////////////////////////////////////////////////// +// DCP case 0xcf: { operandAddress = peek(PC++, DISASM_CODE); @@ -1375,7 +1428,7 @@ case 0xdf: { uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); - peek(high | uInt8(low + X), DISASM_DATA); + peek(high | uInt8(low + X), DISASM_NONE); operandAddress = (high | low) + X; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -1395,7 +1448,7 @@ case 0xdb: { uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); - peek(high | uInt8(low + Y), DISASM_DATA); + peek(high | uInt8(low + Y), DISASM_NONE); operandAddress = (high | low) + Y; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -1431,7 +1484,7 @@ break; case 0xd7: { operandAddress = peek(PC++, DISASM_CODE); - peek(operandAddress, DISASM_DATA); + peek(operandAddress, DISASM_NONE); operandAddress = (operandAddress + X) & 0xFF; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -1450,7 +1503,7 @@ break; case 0xc3: { uInt8 pointer = peek(PC++, DISASM_CODE); - peek(pointer, DISASM_DATA); + peek(pointer, DISASM_NONE); pointer += X; operandAddress = peek(pointer++, DISASM_DATA); operandAddress |= (uInt16(peek(pointer, DISASM_DATA)) << 8); @@ -1473,7 +1526,7 @@ case 0xd3: uInt8 pointer = peek(PC++, DISASM_CODE); uInt16 low = peek(pointer++, DISASM_DATA); uInt16 high = (uInt16(peek(pointer, DISASM_DATA)) << 8); - peek(high | uInt8(low + Y), DISASM_DATA); + peek(high | uInt8(low + Y), DISASM_NONE); operandAddress = (high | low) + Y; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -1489,7 +1542,8 @@ case 0xd3: } break; - +////////////////////////////////////////////////// +// DEC case 0xc6: { operandAddress = peek(PC++, DISASM_CODE); @@ -1508,7 +1562,7 @@ break; case 0xd6: { operandAddress = peek(PC++, DISASM_CODE); - peek(operandAddress, DISASM_DATA); + peek(operandAddress, DISASM_NONE); operandAddress = (operandAddress + X) & 0xFF; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -1542,7 +1596,7 @@ case 0xde: { uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); - peek(high | uInt8(low + X), DISASM_DATA); + peek(high | uInt8(low + X), DISASM_NONE); operandAddress = (high | low) + X; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -1556,7 +1610,8 @@ case 0xde: } break; - +////////////////////////////////////////////////// +// DEX case 0xca: { peek(PC, DISASM_NONE); @@ -1569,7 +1624,8 @@ case 0xca: } break; - +////////////////////////////////////////////////// +// DEY case 0x88: { peek(PC, DISASM_NONE); @@ -1582,7 +1638,8 @@ case 0x88: } break; - +////////////////////////////////////////////////// +// EOR case 0x49: { operand = peek(PC++, DISASM_CODE); @@ -1609,7 +1666,7 @@ break; case 0x55: { intermediateAddress = peek(PC++, DISASM_CODE); - peek(intermediateAddress, DISASM_DATA); + peek(intermediateAddress, DISASM_NONE); intermediateAddress += X; operand = peek(intermediateAddress, DISASM_DATA); } @@ -1638,11 +1695,15 @@ case 0x5d: uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); intermediateAddress = high | uInt8(low + X); - operand = peek(intermediateAddress, DISASM_DATA); if((low + X) > 0xFF) { + operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + X; operand = peek(intermediateAddress, DISASM_DATA); + } + else + { + operand = peek(intermediateAddress, DISASM_DATA); } } { @@ -1657,12 +1718,16 @@ case 0x59: uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); intermediateAddress = high | uInt8(low + Y); - operand = peek(intermediateAddress, DISASM_DATA); if((low + Y) > 0xFF) { + operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + Y; operand = peek(intermediateAddress, DISASM_DATA); } + else + { + operand = peek(intermediateAddress, DISASM_DATA); + } } { A ^= operand; @@ -1674,7 +1739,7 @@ break; case 0x41: { uInt8 pointer = peek(PC++, DISASM_CODE); - peek(pointer, DISASM_DATA); + peek(pointer, DISASM_NONE); pointer += X; intermediateAddress = peek(pointer++, DISASM_DATA); intermediateAddress |= (uInt16(peek(pointer, DISASM_DATA)) << 8); @@ -1693,12 +1758,16 @@ case 0x51: uInt16 low = peek(pointer++, DISASM_DATA); uInt16 high = (uInt16(peek(pointer, DISASM_DATA)) << 8); intermediateAddress = high | uInt8(low + Y); - operand = peek(intermediateAddress, DISASM_DATA); if((low + Y) > 0xFF) { + operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + Y; operand = peek(intermediateAddress, DISASM_DATA); } + else + { + operand = peek(intermediateAddress, DISASM_DATA); + } } { A ^= operand; @@ -1707,7 +1776,8 @@ case 0x51: } break; - +////////////////////////////////////////////////// +// INC case 0xe6: { operandAddress = peek(PC++, DISASM_CODE); @@ -1726,7 +1796,7 @@ break; case 0xf6: { operandAddress = peek(PC++, DISASM_CODE); - peek(operandAddress, DISASM_DATA); + peek(operandAddress, DISASM_NONE); operandAddress = (operandAddress + X) & 0xFF; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -1760,7 +1830,7 @@ case 0xfe: { uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); - peek(high | uInt8(low + X), DISASM_DATA); + peek(high | uInt8(low + X), DISASM_NONE); operandAddress = (high | low) + X; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -1774,7 +1844,8 @@ case 0xfe: } break; - +////////////////////////////////////////////////// +// INX case 0xe8: { peek(PC, DISASM_NONE); @@ -1786,7 +1857,8 @@ case 0xe8: } break; - +////////////////////////////////////////////////// +// INY case 0xc8: { peek(PC, DISASM_NONE); @@ -1798,7 +1870,8 @@ case 0xc8: } break; - +////////////////////////////////////////////////// +// ISB case 0xef: { operandAddress = peek(PC++, DISASM_CODE); @@ -1842,7 +1915,7 @@ case 0xff: { uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); - peek(high | uInt8(low + X), DISASM_DATA); + peek(high | uInt8(low + X), DISASM_NONE); operandAddress = (high | low) + X; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -1883,7 +1956,7 @@ case 0xfb: { uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); - peek(high | uInt8(low + Y), DISASM_DATA); + peek(high | uInt8(low + Y), DISASM_NONE); operandAddress = (high | low) + Y; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -1961,7 +2034,7 @@ break; case 0xf7: { operandAddress = peek(PC++, DISASM_CODE); - peek(operandAddress, DISASM_DATA); + peek(operandAddress, DISASM_NONE); operandAddress = (operandAddress + X) & 0xFF; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -2001,7 +2074,7 @@ break; case 0xe3: { uInt8 pointer = peek(PC++, DISASM_CODE); - peek(pointer, DISASM_DATA); + peek(pointer, DISASM_NONE); pointer += X; operandAddress = peek(pointer++, DISASM_DATA); operandAddress |= (uInt16(peek(pointer, DISASM_DATA)) << 8); @@ -2045,7 +2118,7 @@ case 0xf3: uInt8 pointer = peek(PC++, DISASM_CODE); uInt16 low = peek(pointer++, DISASM_DATA); uInt16 high = (uInt16(peek(pointer, DISASM_DATA)) << 8); - peek(high | uInt8(low + Y), DISASM_DATA); + peek(high | uInt8(low + Y), DISASM_NONE); operandAddress = (high | low) + Y; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -2082,7 +2155,8 @@ case 0xf3: } break; - +////////////////////////////////////////////////// +// JMP case 0x4c: { operandAddress = peek(PC++, DISASM_CODE); @@ -2109,7 +2183,8 @@ case 0x6c: } break; - +////////////////////////////////////////////////// +// JSR case 0x20: { uInt8 low = peek(PC++, DISASM_CODE); @@ -2125,18 +2200,23 @@ case 0x20: } break; - +////////////////////////////////////////////////// +// LAS case 0xbb: { uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); intermediateAddress = high | uInt8(low + Y); - operand = peek(intermediateAddress, DISASM_DATA); if((low + Y) > 0xFF) { + operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + Y; operand = peek(intermediateAddress, DISASM_DATA); } + else + { + operand = peek(intermediateAddress, DISASM_DATA); + } } { A = X = SP = SP & operand; @@ -2169,12 +2249,16 @@ case 0xbf: uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); intermediateAddress = high | uInt8(low + Y); - operand = peek(intermediateAddress, DISASM_DATA); if((low + Y) > 0xFF) { + operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + Y; operand = peek(intermediateAddress, DISASM_DATA); } + else + { + operand = peek(intermediateAddress, DISASM_DATA); + } } SET_LAST_PEEK(myLastSrcAddressA, intermediateAddress) SET_LAST_PEEK(myLastSrcAddressX, intermediateAddress) @@ -2204,7 +2288,7 @@ break; case 0xb7: { intermediateAddress = peek(PC++, DISASM_CODE); - peek(intermediateAddress, DISASM_DATA); + peek(intermediateAddress, DISASM_NONE); intermediateAddress += Y; operand = peek(intermediateAddress, DISASM_DATA); } @@ -2221,7 +2305,7 @@ break; case 0xa3: { uInt8 pointer = peek(PC++, DISASM_CODE); - peek(pointer, DISASM_DATA); + peek(pointer, DISASM_NONE); pointer += X; intermediateAddress = peek(pointer++, DISASM_DATA); intermediateAddress |= (uInt16(peek(pointer, DISASM_DATA)) << 8); @@ -2243,12 +2327,16 @@ case 0xb3: uInt16 low = peek(pointer++, DISASM_DATA); uInt16 high = (uInt16(peek(pointer, DISASM_DATA)) << 8); intermediateAddress = high | uInt8(low + Y); - operand = peek(intermediateAddress, DISASM_DATA); if((low + Y) > 0xFF) { + operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + Y; operand = peek(intermediateAddress, DISASM_DATA); } + else + { + operand = peek(intermediateAddress, DISASM_DATA); + } } SET_LAST_PEEK(myLastSrcAddressA, intermediateAddress) SET_LAST_PEEK(myLastSrcAddressX, intermediateAddress) // TODO - check this @@ -2292,7 +2380,7 @@ break; case 0xb5: { intermediateAddress = peek(PC++, DISASM_CODE); - peek(intermediateAddress, DISASM_DATA); + peek(intermediateAddress, DISASM_NONE); intermediateAddress += X; operand = peek(intermediateAddress, DISASM_DATA); } @@ -2323,11 +2411,15 @@ case 0xbd: uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); intermediateAddress = high | uInt8(low + X); - operand = peek(intermediateAddress, DISASM_DATA); if((low + X) > 0xFF) { + operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + X; operand = peek(intermediateAddress, DISASM_DATA); + } + else + { + operand = peek(intermediateAddress, DISASM_DATA); } } SET_LAST_PEEK(myLastSrcAddressA, intermediateAddress) @@ -2343,12 +2435,16 @@ case 0xb9: uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); intermediateAddress = high | uInt8(low + Y); - operand = peek(intermediateAddress, DISASM_DATA); if((low + Y) > 0xFF) { + operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + Y; operand = peek(intermediateAddress, DISASM_DATA); } + else + { + operand = peek(intermediateAddress, DISASM_DATA); + } } SET_LAST_PEEK(myLastSrcAddressA, intermediateAddress) { @@ -2361,7 +2457,7 @@ break; case 0xa1: { uInt8 pointer = peek(PC++, DISASM_CODE); - peek(pointer, DISASM_DATA); + peek(pointer, DISASM_NONE); pointer += X; intermediateAddress = peek(pointer++, DISASM_DATA); intermediateAddress |= (uInt16(peek(pointer, DISASM_DATA)) << 8); @@ -2381,12 +2477,16 @@ case 0xb1: uInt16 low = peek(pointer++, DISASM_DATA); uInt16 high = (uInt16(peek(pointer, DISASM_DATA)) << 8); intermediateAddress = high | uInt8(low + Y); - operand = peek(intermediateAddress, DISASM_DATA); if((low + Y) > 0xFF) { + operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + Y; operand = peek(intermediateAddress, DISASM_DATA); } + else + { + operand = peek(intermediateAddress, DISASM_DATA); + } } SET_LAST_PEEK(myLastSrcAddressA, intermediateAddress) { @@ -2428,7 +2528,7 @@ break; case 0xb6: { intermediateAddress = peek(PC++, DISASM_CODE); - peek(intermediateAddress, DISASM_DATA); + peek(intermediateAddress, DISASM_NONE); intermediateAddress += Y; operand = peek(intermediateAddress, DISASM_DATA); } @@ -2459,12 +2559,16 @@ case 0xbe: uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); intermediateAddress = high | uInt8(low + Y); - operand = peek(intermediateAddress, DISASM_DATA); if((low + Y) > 0xFF) { + operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + Y; operand = peek(intermediateAddress, DISASM_DATA); } + else + { + operand = peek(intermediateAddress, DISASM_DATA); + } } SET_LAST_PEEK(myLastSrcAddressX, intermediateAddress) { @@ -2506,7 +2610,7 @@ break; case 0xb4: { intermediateAddress = peek(PC++, DISASM_CODE); - peek(intermediateAddress, DISASM_DATA); + peek(intermediateAddress, DISASM_NONE); intermediateAddress += X; operand = peek(intermediateAddress, DISASM_DATA); } @@ -2537,11 +2641,15 @@ case 0xbc: uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); intermediateAddress = high | uInt8(low + X); - operand = peek(intermediateAddress, DISASM_DATA); if((low + X) > 0xFF) { + operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + X; operand = peek(intermediateAddress, DISASM_DATA); + } + else + { + operand = peek(intermediateAddress, DISASM_DATA); } } SET_LAST_PEEK(myLastSrcAddressY, intermediateAddress) @@ -2553,7 +2661,8 @@ SET_LAST_PEEK(myLastSrcAddressY, intermediateAddress) break; ////////////////////////////////////////////////// - +////////////////////////////////////////////////// +// LSR case 0x4a: { peek(PC, DISASM_NONE); @@ -2591,7 +2700,7 @@ break; case 0x56: { operandAddress = peek(PC++, DISASM_CODE); - peek(operandAddress, DISASM_DATA); + peek(operandAddress, DISASM_NONE); operandAddress = (operandAddress + X) & 0xFF; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -2631,7 +2740,7 @@ case 0x5e: { uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); - peek(high | uInt8(low + X), DISASM_DATA); + peek(high | uInt8(low + X), DISASM_NONE); operandAddress = (high | low) + X; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -2648,7 +2757,8 @@ case 0x5e: } break; - +////////////////////////////////////////////////// +// LXA case 0xab: { operand = peek(PC++, DISASM_CODE); @@ -2663,7 +2773,8 @@ case 0xab: } break; - +////////////////////////////////////////////////// +// NOP case 0x1a: case 0x3a: case 0x5a: @@ -2709,7 +2820,7 @@ case 0xd4: case 0xf4: { intermediateAddress = peek(PC++, DISASM_CODE); - peek(intermediateAddress, DISASM_DATA); + peek(intermediateAddress, DISASM_NONE); intermediateAddress += X; operand = peek(intermediateAddress, DISASM_DATA); } @@ -2737,11 +2848,15 @@ case 0xfc: uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); intermediateAddress = high | uInt8(low + X); - operand = peek(intermediateAddress, DISASM_DATA); if((low + X) > 0xFF) { + operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + X; operand = peek(intermediateAddress, DISASM_DATA); + } + else + { + operand = peek(intermediateAddress, DISASM_DATA); } } { @@ -2779,7 +2894,7 @@ break; case 0x15: { intermediateAddress = peek(PC++, DISASM_CODE); - peek(intermediateAddress, DISASM_DATA); + peek(intermediateAddress, DISASM_NONE); intermediateAddress += X; operand = peek(intermediateAddress, DISASM_DATA); } @@ -2810,11 +2925,15 @@ case 0x1d: uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); intermediateAddress = high | uInt8(low + X); - operand = peek(intermediateAddress, DISASM_DATA); if((low + X) > 0xFF) { + operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + X; operand = peek(intermediateAddress, DISASM_DATA); + } + else + { + operand = peek(intermediateAddress, DISASM_DATA); } } SET_LAST_PEEK(myLastSrcAddressA, intermediateAddress) @@ -2830,12 +2949,16 @@ case 0x19: uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); intermediateAddress = high | uInt8(low + Y); - operand = peek(intermediateAddress, DISASM_DATA); if((low + Y) > 0xFF) { + operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + Y; operand = peek(intermediateAddress, DISASM_DATA); } + else + { + operand = peek(intermediateAddress, DISASM_DATA); + } } SET_LAST_PEEK(myLastSrcAddressA, intermediateAddress) { @@ -2848,7 +2971,7 @@ break; case 0x01: { uInt8 pointer = peek(PC++, DISASM_CODE); - peek(pointer, DISASM_DATA); + peek(pointer, DISASM_NONE); pointer += X; intermediateAddress = peek(pointer++, DISASM_DATA); intermediateAddress |= (uInt16(peek(pointer, DISASM_DATA)) << 8); @@ -2868,12 +2991,16 @@ case 0x11: uInt16 low = peek(pointer++, DISASM_DATA); uInt16 high = (uInt16(peek(pointer, DISASM_DATA)) << 8); intermediateAddress = high | uInt8(low + Y); - operand = peek(intermediateAddress, DISASM_DATA); if((low + Y) > 0xFF) { + operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + Y; operand = peek(intermediateAddress, DISASM_DATA); } + else + { + operand = peek(intermediateAddress, DISASM_DATA); + } } SET_LAST_PEEK(myLastSrcAddressA, intermediateAddress) { @@ -2884,7 +3011,8 @@ SET_LAST_PEEK(myLastSrcAddressA, intermediateAddress) break; ////////////////////////////////////////////////// - +////////////////////////////////////////////////// +// PHA case 0x48: { peek(PC, DISASM_NONE); @@ -2895,7 +3023,8 @@ case 0x48: } break; - +////////////////////////////////////////////////// +// PHP case 0x08: { peek(PC, DISASM_NONE); @@ -2906,7 +3035,8 @@ case 0x08: } break; - +////////////////////////////////////////////////// +// PLA case 0x68: { peek(PC, DISASM_NONE); @@ -2920,7 +3050,8 @@ case 0x68: } break; - +////////////////////////////////////////////////// +// PLP case 0x28: { peek(PC, DISASM_NONE); @@ -2932,7 +3063,8 @@ case 0x28: } break; - +////////////////////////////////////////////////// +// RLA case 0x2f: { operandAddress = peek(PC++, DISASM_CODE); @@ -2955,7 +3087,7 @@ case 0x3f: { uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); - peek(high | uInt8(low + X), DISASM_DATA); + peek(high | uInt8(low + X), DISASM_NONE); operandAddress = (high | low) + X; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -2975,7 +3107,7 @@ case 0x3b: { uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); - peek(high | uInt8(low + Y), DISASM_DATA); + peek(high | uInt8(low + Y), DISASM_NONE); operandAddress = (high | low) + Y; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -3011,7 +3143,7 @@ break; case 0x37: { operandAddress = peek(PC++, DISASM_CODE); - peek(operandAddress, DISASM_DATA); + peek(operandAddress, DISASM_NONE); operandAddress = (operandAddress + X) & 0xFF; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -3030,7 +3162,7 @@ break; case 0x23: { uInt8 pointer = peek(PC++, DISASM_CODE); - peek(pointer, DISASM_DATA); + peek(pointer, DISASM_NONE); pointer += X; operandAddress = peek(pointer++, DISASM_DATA); operandAddress |= (uInt16(peek(pointer, DISASM_DATA)) << 8); @@ -3053,7 +3185,7 @@ case 0x33: uInt8 pointer = peek(PC++, DISASM_CODE); uInt16 low = peek(pointer++, DISASM_DATA); uInt16 high = (uInt16(peek(pointer, DISASM_DATA)) << 8); - peek(high | uInt8(low + Y), DISASM_DATA); + peek(high | uInt8(low + Y), DISASM_NONE); operandAddress = (high | low) + Y; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -3069,7 +3201,8 @@ case 0x33: } break; - +////////////////////////////////////////////////// +// ROL case 0x2a: { peek(PC, DISASM_NONE); @@ -3087,7 +3220,6 @@ case 0x2a: } break; - case 0x26: { operandAddress = peek(PC++, DISASM_CODE); @@ -3111,7 +3243,7 @@ break; case 0x36: { operandAddress = peek(PC++, DISASM_CODE); - peek(operandAddress, DISASM_DATA); + peek(operandAddress, DISASM_NONE); operandAddress = (operandAddress + X) & 0xFF; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -3155,7 +3287,7 @@ case 0x3e: { uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); - peek(high | uInt8(low + X), DISASM_DATA); + peek(high | uInt8(low + X), DISASM_NONE); operandAddress = (high | low) + X; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -3174,7 +3306,8 @@ case 0x3e: } break; - +////////////////////////////////////////////////// +// ROR case 0x6a: { peek(PC, DISASM_NONE); @@ -3215,7 +3348,7 @@ break; case 0x76: { operandAddress = peek(PC++, DISASM_CODE); - peek(operandAddress, DISASM_DATA); + peek(operandAddress, DISASM_NONE); operandAddress = (operandAddress + X) & 0xFF; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -3259,7 +3392,7 @@ case 0x7e: { uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); - peek(high | uInt8(low + X), DISASM_DATA); + peek(high | uInt8(low + X), DISASM_NONE); operandAddress = (high | low) + X; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -3278,7 +3411,8 @@ case 0x7e: } break; - +////////////////////////////////////////////////// +// RRA case 0x6f: { operandAddress = peek(PC++, DISASM_CODE); @@ -3330,7 +3464,7 @@ case 0x7f: { uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); - peek(high | uInt8(low + X), DISASM_DATA); + peek(high | uInt8(low + X), DISASM_NONE); operandAddress = (high | low) + X; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -3379,7 +3513,7 @@ case 0x7b: { uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); - peek(high | uInt8(low + Y), DISASM_DATA); + peek(high | uInt8(low + Y), DISASM_NONE); operandAddress = (high | low) + Y; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -3473,7 +3607,7 @@ break; case 0x77: { operandAddress = peek(PC++, DISASM_CODE); - peek(operandAddress, DISASM_DATA); + peek(operandAddress, DISASM_NONE); operandAddress = (operandAddress + X) & 0xFF; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -3521,7 +3655,7 @@ break; case 0x63: { uInt8 pointer = peek(PC++, DISASM_CODE); - peek(pointer, DISASM_DATA); + peek(pointer, DISASM_NONE); pointer += X; operandAddress = peek(pointer++, DISASM_DATA); operandAddress |= (uInt16(peek(pointer, DISASM_DATA)) << 8); @@ -3573,7 +3707,7 @@ case 0x73: uInt8 pointer = peek(PC++, DISASM_CODE); uInt16 low = peek(pointer++, DISASM_DATA); uInt16 high = (uInt16(peek(pointer, DISASM_DATA)) << 8); - peek(high | uInt8(low + Y), DISASM_DATA); + peek(high | uInt8(low + Y), DISASM_NONE); operandAddress = (high | low) + Y; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -3618,7 +3752,8 @@ case 0x73: } break; - +////////////////////////////////////////////////// +// RTI case 0x40: { peek(PC, DISASM_NONE); @@ -3631,7 +3766,8 @@ case 0x40: } break; - +////////////////////////////////////////////////// +// RTS case 0x60: { peek(PC, DISASM_NONE); @@ -3644,7 +3780,8 @@ case 0x60: } break; - +////////////////////////////////////////////////// +// SAX case 0x8f: { operandAddress = peek(PC++, DISASM_CODE); @@ -3667,7 +3804,7 @@ break; case 0x97: { operandAddress = peek(PC++, DISASM_CODE); - peek(operandAddress, DISASM_DATA); + peek(operandAddress, DISASM_NONE); operandAddress = (operandAddress + Y) & 0xFF; } { @@ -3678,7 +3815,7 @@ break; case 0x83: { uInt8 pointer = peek(PC++, DISASM_CODE); - peek(pointer, DISASM_DATA); + peek(pointer, DISASM_NONE); pointer += X; operandAddress = peek(pointer++, DISASM_DATA); operandAddress |= (uInt16(peek(pointer, DISASM_DATA)) << 8); @@ -3688,7 +3825,8 @@ case 0x83: } break; - +////////////////////////////////////////////////// +// SBC case 0xe9: case 0xeb: { @@ -3760,7 +3898,7 @@ break; case 0xf5: { intermediateAddress = peek(PC++, DISASM_CODE); - peek(intermediateAddress, DISASM_DATA); + peek(intermediateAddress, DISASM_NONE); intermediateAddress += X; operand = peek(intermediateAddress, DISASM_DATA); } @@ -3833,11 +3971,15 @@ case 0xfd: uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); intermediateAddress = high | uInt8(low + X); - operand = peek(intermediateAddress, DISASM_DATA); if((low + X) > 0xFF) { + operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + X; operand = peek(intermediateAddress, DISASM_DATA); + } + else + { + operand = peek(intermediateAddress, DISASM_DATA); } } { @@ -3874,12 +4016,16 @@ case 0xf9: uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); intermediateAddress = high | uInt8(low + Y); - operand = peek(intermediateAddress, DISASM_DATA); if((low + Y) > 0xFF) { + operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + Y; operand = peek(intermediateAddress, DISASM_DATA); } + else + { + operand = peek(intermediateAddress, DISASM_DATA); + } } { // N, V, Z, C flags are the same in either mode (C calculated at the end) @@ -3913,7 +4059,7 @@ break; case 0xe1: { uInt8 pointer = peek(PC++, DISASM_CODE); - peek(pointer, DISASM_DATA); + peek(pointer, DISASM_NONE); pointer += X; intermediateAddress = peek(pointer++, DISASM_DATA); intermediateAddress |= (uInt16(peek(pointer, DISASM_DATA)) << 8); @@ -3954,12 +4100,16 @@ case 0xf1: uInt16 low = peek(pointer++, DISASM_DATA); uInt16 high = (uInt16(peek(pointer, DISASM_DATA)) << 8); intermediateAddress = high | uInt8(low + Y); - operand = peek(intermediateAddress, DISASM_DATA); if((low + Y) > 0xFF) { + operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + Y; operand = peek(intermediateAddress, DISASM_DATA); } + else + { + operand = peek(intermediateAddress, DISASM_DATA); + } } { // N, V, Z, C flags are the same in either mode (C calculated at the end) @@ -3990,7 +4140,8 @@ case 0xf1: } break; - +////////////////////////////////////////////////// +// SBX case 0xcb: { operand = peek(PC++, DISASM_CODE); @@ -4005,7 +4156,8 @@ case 0xcb: } break; - +////////////////////////////////////////////////// +// SEC case 0x38: { peek(PC, DISASM_NONE); @@ -4015,7 +4167,8 @@ case 0x38: } break; - +////////////////////////////////////////////////// +// SED case 0xf8: { peek(PC, DISASM_NONE); @@ -4025,7 +4178,8 @@ case 0xf8: } break; - +////////////////////////////////////////////////// +// SEI case 0x78: { peek(PC, DISASM_NONE); @@ -4035,12 +4189,13 @@ case 0x78: } break; - +////////////////////////////////////////////////// +// SHA case 0x9f: { uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); - peek(high | uInt8(low + Y), DISASM_DATA); + peek(high | uInt8(low + Y), DISASM_NONE); operandAddress = (high | low) + Y; } { @@ -4055,7 +4210,7 @@ case 0x93: uInt8 pointer = peek(PC++, DISASM_CODE); uInt16 low = peek(pointer++, DISASM_DATA); uInt16 high = (uInt16(peek(pointer, DISASM_DATA)) << 8); - peek(high | uInt8(low + Y), DISASM_DATA); + peek(high | uInt8(low + Y), DISASM_NONE); operandAddress = (high | low) + Y; } { @@ -4065,12 +4220,13 @@ case 0x93: } break; - +////////////////////////////////////////////////// +// SHS case 0x9b: { uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); - peek(high | uInt8(low + Y), DISASM_DATA); + peek(high | uInt8(low + Y), DISASM_NONE); operandAddress = (high | low) + Y; } { @@ -4081,12 +4237,13 @@ case 0x9b: } break; - +////////////////////////////////////////////////// +// SHX case 0x9e: { uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); - peek(high | uInt8(low + Y), DISASM_DATA); + peek(high | uInt8(low + Y), DISASM_NONE); operandAddress = (high | low) + Y; } { @@ -4096,12 +4253,13 @@ case 0x9e: } break; - +////////////////////////////////////////////////// +// SHY case 0x9c: { uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); - peek(high | uInt8(low + X), DISASM_DATA); + peek(high | uInt8(low + X), DISASM_NONE); operandAddress = (high | low) + X; } { @@ -4111,7 +4269,8 @@ case 0x9c: } break; - +////////////////////////////////////////////////// +// SLO case 0x0f: { operandAddress = peek(PC++, DISASM_CODE); @@ -4136,7 +4295,7 @@ case 0x1f: { uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); - peek(high | uInt8(low + X), DISASM_DATA); + peek(high | uInt8(low + X), DISASM_NONE); operandAddress = (high | low) + X; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -4158,7 +4317,7 @@ case 0x1b: { uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); - peek(high | uInt8(low + Y), DISASM_DATA); + peek(high | uInt8(low + Y), DISASM_NONE); operandAddress = (high | low) + Y; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -4198,7 +4357,7 @@ break; case 0x17: { operandAddress = peek(PC++, DISASM_CODE); - peek(operandAddress, DISASM_DATA); + peek(operandAddress, DISASM_NONE); operandAddress = (operandAddress + X) & 0xFF; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -4219,7 +4378,7 @@ break; case 0x03: { uInt8 pointer = peek(PC++, DISASM_CODE); - peek(pointer, DISASM_DATA); + peek(pointer, DISASM_NONE); pointer += X; operandAddress = peek(pointer++, DISASM_DATA); operandAddress |= (uInt16(peek(pointer, DISASM_DATA)) << 8); @@ -4244,7 +4403,7 @@ case 0x13: uInt8 pointer = peek(PC++, DISASM_CODE); uInt16 low = peek(pointer++, DISASM_DATA); uInt16 high = (uInt16(peek(pointer, DISASM_DATA)) << 8); - peek(high | uInt8(low + Y), DISASM_DATA); + peek(high | uInt8(low + Y), DISASM_NONE); operandAddress = (high | low) + Y; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -4262,7 +4421,8 @@ case 0x13: } break; - +////////////////////////////////////////////////// +// SRE case 0x4f: { operandAddress = peek(PC++, DISASM_CODE); @@ -4287,7 +4447,7 @@ case 0x5f: { uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); - peek(high | uInt8(low + X), DISASM_DATA); + peek(high | uInt8(low + X), DISASM_NONE); operandAddress = (high | low) + X; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -4309,7 +4469,7 @@ case 0x5b: { uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); - peek(high | uInt8(low + Y), DISASM_DATA); + peek(high | uInt8(low + Y), DISASM_NONE); operandAddress = (high | low) + Y; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -4349,7 +4509,7 @@ break; case 0x57: { operandAddress = peek(PC++, DISASM_CODE); - peek(operandAddress, DISASM_DATA); + peek(operandAddress, DISASM_NONE); operandAddress = (operandAddress + X) & 0xFF; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -4370,7 +4530,7 @@ break; case 0x43: { uInt8 pointer = peek(PC++, DISASM_CODE); - peek(pointer, DISASM_DATA); + peek(pointer, DISASM_NONE); pointer += X; operandAddress = peek(pointer++, DISASM_DATA); operandAddress |= (uInt16(peek(pointer, DISASM_DATA)) << 8); @@ -4395,7 +4555,7 @@ case 0x53: uInt8 pointer = peek(PC++, DISASM_CODE); uInt16 low = peek(pointer++, DISASM_DATA); uInt16 high = (uInt16(peek(pointer, DISASM_DATA)) << 8); - peek(high | uInt8(low + Y), DISASM_DATA); + peek(high | uInt8(low + Y), DISASM_NONE); operandAddress = (high | low) + Y; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -4429,7 +4589,7 @@ break; case 0x95: { operandAddress = peek(PC++, DISASM_CODE); - peek(operandAddress, DISASM_DATA); + peek(operandAddress, DISASM_NONE); operandAddress = (operandAddress + X) & 0xFF; } { @@ -4451,7 +4611,7 @@ case 0x9d: { uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); - peek(high | uInt8(low + X), DISASM_DATA); + peek(high | uInt8(low + X), DISASM_NONE); operandAddress = (high | low) + X; } { @@ -4463,7 +4623,7 @@ case 0x99: { uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); - peek(high | uInt8(low + Y), DISASM_DATA); + peek(high | uInt8(low + Y), DISASM_NONE); operandAddress = (high | low) + Y; } { @@ -4474,7 +4634,7 @@ break; case 0x81: { uInt8 pointer = peek(PC++, DISASM_CODE); - peek(pointer, DISASM_DATA); + peek(pointer, DISASM_NONE); pointer += X; operandAddress = peek(pointer++, DISASM_DATA); operandAddress |= (uInt16(peek(pointer, DISASM_DATA)) << 8); @@ -4489,7 +4649,7 @@ case 0x91: uInt8 pointer = peek(PC++, DISASM_CODE); uInt16 low = peek(pointer++, DISASM_DATA); uInt16 high = (uInt16(peek(pointer, DISASM_DATA)) << 8); - peek(high | uInt8(low + Y), DISASM_DATA); + peek(high | uInt8(low + Y), DISASM_NONE); operandAddress = (high | low) + Y; } { @@ -4514,7 +4674,7 @@ break; case 0x96: { operandAddress = peek(PC++, DISASM_CODE); - peek(operandAddress, DISASM_DATA); + peek(operandAddress, DISASM_NONE); operandAddress = (operandAddress + Y) & 0xFF; } { @@ -4549,7 +4709,7 @@ break; case 0x94: { operandAddress = peek(PC++, DISASM_CODE); - peek(operandAddress, DISASM_DATA); + peek(operandAddress, DISASM_NONE); operandAddress = (operandAddress + X) & 0xFF; } { diff --git a/src/emucore/M6502.m4 b/src/emucore/M6502.m4 index 85269877f..e849d0542 100644 --- a/src/emucore/M6502.m4 +++ b/src/emucore/M6502.m4 @@ -38,7 +38,7 @@ #ifndef CLEAR_LAST_PEEK #ifdef DEBUGGER_SUPPORT - #define CLEAR_LAST_PEEK(_addr) _addr = -1; + #define CLEAR_LAST_PEEK(_addr) _addr = 0; #else #define CLEAR_LAST_PEEK(_addr) #endif @@ -83,25 +83,29 @@ define(M6502_ABSOLUTEX_READ, `{ uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); intermediateAddress = high | uInt8(low + X); - operand = peek(intermediateAddress, DISASM_DATA); if((low + X) > 0xFF) { + operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + X; operand = peek(intermediateAddress, DISASM_DATA); + } + else + { + operand = peek(intermediateAddress, DISASM_DATA); } }') define(M6502_ABSOLUTEX_WRITE, `{ uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); - peek(high | uInt8(low + X), DISASM_DATA); + peek(high | uInt8(low + X), DISASM_NONE); operandAddress = (high | low) + X; }') define(M6502_ABSOLUTEX_READMODIFYWRITE, `{ uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); - peek(high | uInt8(low + X), DISASM_DATA); + peek(high | uInt8(low + X), DISASM_NONE); operandAddress = (high | low) + X; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -111,25 +115,29 @@ define(M6502_ABSOLUTEY_READ, `{ uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); intermediateAddress = high | uInt8(low + Y); - operand = peek(intermediateAddress, DISASM_DATA); if((low + Y) > 0xFF) { + operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + Y; operand = peek(intermediateAddress, DISASM_DATA); } + else + { + operand = peek(intermediateAddress, DISASM_DATA); + } }') define(M6502_ABSOLUTEY_WRITE, `{ uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); - peek(high | uInt8(low + Y), DISASM_DATA); + peek(high | uInt8(low + Y), DISASM_NONE); operandAddress = (high | low) + Y; }') define(M6502_ABSOLUTEY_READMODIFYWRITE, `{ uInt16 low = peek(PC++, DISASM_CODE); uInt16 high = (uInt16(peek(PC++, DISASM_CODE)) << 8); - peek(high | uInt8(low + Y), DISASM_DATA); + peek(high | uInt8(low + Y), DISASM_NONE); operandAddress = (high | low) + Y; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -152,20 +160,20 @@ define(M6502_ZERO_READMODIFYWRITE, `{ define(M6502_ZEROX_READ, `{ intermediateAddress = peek(PC++, DISASM_CODE); - peek(intermediateAddress, DISASM_DATA); + peek(intermediateAddress, DISASM_NONE); intermediateAddress += X; operand = peek(intermediateAddress, DISASM_DATA); }') define(M6502_ZEROX_WRITE, `{ operandAddress = peek(PC++, DISASM_CODE); - peek(operandAddress, DISASM_DATA); + peek(operandAddress, DISASM_NONE); operandAddress = (operandAddress + X) & 0xFF; }') define(M6502_ZEROX_READMODIFYWRITE, `{ operandAddress = peek(PC++, DISASM_CODE); - peek(operandAddress, DISASM_DATA); + peek(operandAddress, DISASM_NONE); operandAddress = (operandAddress + X) & 0xFF; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -173,20 +181,20 @@ define(M6502_ZEROX_READMODIFYWRITE, `{ define(M6502_ZEROY_READ, `{ intermediateAddress = peek(PC++, DISASM_CODE); - peek(intermediateAddress, DISASM_DATA); + peek(intermediateAddress, DISASM_NONE); intermediateAddress += Y; operand = peek(intermediateAddress, DISASM_DATA); }') define(M6502_ZEROY_WRITE, `{ operandAddress = peek(PC++, DISASM_CODE); - peek(operandAddress, DISASM_DATA); + peek(operandAddress, DISASM_NONE); operandAddress = (operandAddress + Y) & 0xFF; }') define(M6502_ZEROY_READMODIFYWRITE, `{ operandAddress = peek(PC++, DISASM_CODE); - peek(operandAddress, DISASM_DATA); + peek(operandAddress, DISASM_NONE); operandAddress = (operandAddress + Y) & 0xFF; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); @@ -205,7 +213,7 @@ define(M6502_INDIRECT, `{ define(M6502_INDIRECTX_READ, `{ uInt8 pointer = peek(PC++, DISASM_CODE); - peek(pointer, DISASM_DATA); + peek(pointer, DISASM_NONE); pointer += X; intermediateAddress = peek(pointer++, DISASM_DATA); intermediateAddress |= (uInt16(peek(pointer, DISASM_DATA)) << 8); @@ -214,7 +222,7 @@ define(M6502_INDIRECTX_READ, `{ define(M6502_INDIRECTX_WRITE, `{ uInt8 pointer = peek(PC++, DISASM_CODE); - peek(pointer, DISASM_DATA); + peek(pointer, DISASM_NONE); pointer += X; operandAddress = peek(pointer++, DISASM_DATA); operandAddress |= (uInt16(peek(pointer, DISASM_DATA)) << 8); @@ -222,7 +230,7 @@ define(M6502_INDIRECTX_WRITE, `{ define(M6502_INDIRECTX_READMODIFYWRITE, `{ uInt8 pointer = peek(PC++, DISASM_CODE); - peek(pointer, DISASM_DATA); + peek(pointer, DISASM_NONE); pointer += X; operandAddress = peek(pointer++, DISASM_DATA); operandAddress |= (uInt16(peek(pointer, DISASM_DATA)) << 8); @@ -235,19 +243,23 @@ define(M6502_INDIRECTY_READ, `{ uInt16 low = peek(pointer++, DISASM_DATA); uInt16 high = (uInt16(peek(pointer, DISASM_DATA)) << 8); intermediateAddress = high | uInt8(low + Y); - operand = peek(intermediateAddress, DISASM_DATA); if((low + Y) > 0xFF) { + operand = peek(intermediateAddress, DISASM_NONE); intermediateAddress = (high | low) + Y; operand = peek(intermediateAddress, DISASM_DATA); } + else + { + operand = peek(intermediateAddress, DISASM_DATA); + } }') define(M6502_INDIRECTY_WRITE, `{ uInt8 pointer = peek(PC++, DISASM_CODE); uInt16 low = peek(pointer++, DISASM_DATA); uInt16 high = (uInt16(peek(pointer, DISASM_DATA)) << 8); - peek(high | uInt8(low + Y), DISASM_DATA); + peek(high | uInt8(low + Y), DISASM_NONE); operandAddress = (high | low) + Y; }') @@ -255,13 +267,12 @@ define(M6502_INDIRECTY_READMODIFYWRITE, `{ uInt8 pointer = peek(PC++, DISASM_CODE); uInt16 low = peek(pointer++, DISASM_DATA); uInt16 high = (uInt16(peek(pointer, DISASM_DATA)) << 8); - peek(high | uInt8(low + Y), DISASM_DATA); + peek(high | uInt8(low + Y), DISASM_NONE); operandAddress = (high | low) + Y; operand = peek(operandAddress, DISASM_DATA); poke(operandAddress, operand); }') - define(M6502_BCC, `{ if(!C) { @@ -484,7 +495,7 @@ define(M6502_BIT, `{ }') define(M6502_BRK, `{ - peek(PC++, DISASM_CODE); + peek(PC++, DISASM_NONE); B = true; @@ -494,8 +505,8 @@ define(M6502_BRK, `{ I = true; - PC = peek(0xfffe, DISASM_NONE); - PC |= (uInt16(peek(0xffff, DISASM_NONE)) << 8); + PC = peek(0xfffe, DISASM_DATA); + PC |= (uInt16(peek(0xffff, DISASM_DATA)) << 8); }') define(M6502_CLC, `{ @@ -996,7 +1007,8 @@ define(M6502_TYA, `{ N = A & 0x80; }') - +////////////////////////////////////////////////// +// ADC case 0x69: M6502_IMMEDIATE_READ M6502_ADC @@ -1037,20 +1049,23 @@ M6502_INDIRECTY_READ M6502_ADC break; - +////////////////////////////////////////////////// +// ASR case 0x4b: M6502_IMMEDIATE_READ M6502_ASR break; - +////////////////////////////////////////////////// +// ANC case 0x0b: case 0x2b: M6502_IMMEDIATE_READ M6502_ANC break; - +////////////////////////////////////////////////// +// AND case 0x29: M6502_IMMEDIATE_READ M6502_AND @@ -1091,19 +1106,22 @@ M6502_INDIRECTY_READ M6502_AND break; - +////////////////////////////////////////////////// +// ANE case 0x8b: M6502_IMMEDIATE_READ M6502_ANE break; - +////////////////////////////////////////////////// +// ARR case 0x6b: M6502_IMMEDIATE_READ M6502_ARR break; - +////////////////////////////////////////////////// +// ASL case 0x0a: M6502_IMPLIED M6502_ASLA @@ -1129,7 +1147,20 @@ M6502_ABSOLUTEX_READMODIFYWRITE M6502_ASL break; +////////////////////////////////////////////////// +// BIT +case 0x24: +M6502_ZERO_READ +M6502_BIT +break; +case 0x2C: +M6502_ABSOLUTE_READ +M6502_BIT +break; + +////////////////////////////////////////////////// +// Branches case 0x90: M6502_IMMEDIATE_READ M6502_BCC @@ -1148,17 +1179,6 @@ M6502_BEQ break; -case 0x24: -M6502_ZERO_READ -M6502_BIT -break; - -case 0x2C: -M6502_ABSOLUTE_READ -M6502_BIT -break; - - case 0x30: M6502_IMMEDIATE_READ M6502_BMI @@ -1177,11 +1197,6 @@ M6502_BPL break; -case 0x00: -M6502_BRK -break; - - case 0x50: M6502_IMMEDIATE_READ M6502_BVC @@ -1193,31 +1208,42 @@ M6502_IMMEDIATE_READ M6502_BVS break; +////////////////////////////////////////////////// +// BRK +case 0x00: +M6502_BRK +break; +////////////////////////////////////////////////// +// CLC case 0x18: M6502_IMPLIED M6502_CLC break; - +////////////////////////////////////////////////// +// CLD case 0xd8: M6502_IMPLIED M6502_CLD break; - +////////////////////////////////////////////////// +// CLI case 0x58: M6502_IMPLIED M6502_CLI break; - +////////////////////////////////////////////////// +// CLV case 0xb8: M6502_IMPLIED M6502_CLV break; - +////////////////////////////////////////////////// +// CMP case 0xc9: M6502_IMMEDIATE_READ M6502_CMP @@ -1258,7 +1284,8 @@ M6502_INDIRECTY_READ M6502_CMP break; - +////////////////////////////////////////////////// +// CPX case 0xe0: M6502_IMMEDIATE_READ M6502_CPX @@ -1274,7 +1301,8 @@ M6502_ABSOLUTE_READ M6502_CPX break; - +////////////////////////////////////////////////// +// CPY case 0xc0: M6502_IMMEDIATE_READ M6502_CPY @@ -1290,7 +1318,8 @@ M6502_ABSOLUTE_READ M6502_CPY break; - +////////////////////////////////////////////////// +// DCP case 0xcf: M6502_ABSOLUTE_READMODIFYWRITE M6502_DCP @@ -1326,7 +1355,8 @@ M6502_INDIRECTY_READMODIFYWRITE M6502_DCP break; - +////////////////////////////////////////////////// +// DEC case 0xc6: M6502_ZERO_READMODIFYWRITE M6502_DEC @@ -1347,19 +1377,22 @@ M6502_ABSOLUTEX_READMODIFYWRITE M6502_DEC break; - +////////////////////////////////////////////////// +// DEX case 0xca: M6502_IMPLIED M6502_DEX break; - +////////////////////////////////////////////////// +// DEY case 0x88: M6502_IMPLIED M6502_DEY break; - +////////////////////////////////////////////////// +// EOR case 0x49: M6502_IMMEDIATE_READ M6502_EOR @@ -1400,7 +1433,8 @@ M6502_INDIRECTY_READ M6502_EOR break; - +////////////////////////////////////////////////// +// INC case 0xe6: M6502_ZERO_READMODIFYWRITE M6502_INC @@ -1421,19 +1455,22 @@ M6502_ABSOLUTEX_READMODIFYWRITE M6502_INC break; - +////////////////////////////////////////////////// +// INX case 0xe8: M6502_IMPLIED M6502_INX break; - +////////////////////////////////////////////////// +// INY case 0xc8: M6502_IMPLIED M6502_INY break; - +////////////////////////////////////////////////// +// ISB case 0xef: M6502_ABSOLUTE_READMODIFYWRITE M6502_ISB @@ -1469,7 +1506,8 @@ M6502_INDIRECTY_READMODIFYWRITE M6502_ISB break; - +////////////////////////////////////////////////// +// JMP case 0x4c: M6502_ABSOLUTE_WRITE M6502_JMP @@ -1480,12 +1518,14 @@ M6502_INDIRECT M6502_JMP break; - +////////////////////////////////////////////////// +// JSR case 0x20: M6502_JSR break; - +////////////////////////////////////////////////// +// LAS case 0xbb: M6502_ABSOLUTEY_READ M6502_LAS @@ -1657,7 +1697,8 @@ M6502_LDY break; ////////////////////////////////////////////////// - +////////////////////////////////////////////////// +// LSR case 0x4a: M6502_IMPLIED M6502_LSRA @@ -1684,13 +1725,15 @@ M6502_ABSOLUTEX_READMODIFYWRITE M6502_LSR break; - +////////////////////////////////////////////////// +// LXA case 0xab: M6502_IMMEDIATE_READ M6502_LXA break; - +////////////////////////////////////////////////// +// NOP case 0x1a: case 0x3a: case 0x5a: @@ -1795,35 +1838,40 @@ M6502_ORA break; ////////////////////////////////////////////////// - +////////////////////////////////////////////////// +// PHA case 0x48: M6502_IMPLIED // TODO - add tracking for this opcode M6502_PHA break; - +////////////////////////////////////////////////// +// PHP case 0x08: M6502_IMPLIED // TODO - add tracking for this opcode M6502_PHP break; - +////////////////////////////////////////////////// +// PLA case 0x68: M6502_IMPLIED // TODO - add tracking for this opcode M6502_PLA break; - +////////////////////////////////////////////////// +// PLP case 0x28: M6502_IMPLIED // TODO - add tracking for this opcode M6502_PLP break; - +////////////////////////////////////////////////// +// RLA case 0x2f: M6502_ABSOLUTE_READMODIFYWRITE M6502_RLA @@ -1859,13 +1907,13 @@ M6502_INDIRECTY_READMODIFYWRITE M6502_RLA break; - +////////////////////////////////////////////////// +// ROL case 0x2a: M6502_IMPLIED M6502_ROLA break; - case 0x26: M6502_ZERO_READMODIFYWRITE M6502_ROL @@ -1886,7 +1934,8 @@ M6502_ABSOLUTEX_READMODIFYWRITE M6502_ROL break; - +////////////////////////////////////////////////// +// ROR case 0x6a: M6502_IMPLIED M6502_RORA @@ -1912,7 +1961,8 @@ M6502_ABSOLUTEX_READMODIFYWRITE M6502_ROR break; - +////////////////////////////////////////////////// +// RRA case 0x6f: M6502_ABSOLUTE_READMODIFYWRITE M6502_RRA @@ -1948,19 +1998,22 @@ M6502_INDIRECTY_READMODIFYWRITE M6502_RRA break; - +////////////////////////////////////////////////// +// RTI case 0x40: M6502_IMPLIED M6502_RTI break; - +////////////////////////////////////////////////// +// RTS case 0x60: M6502_IMPLIED M6502_RTS break; - +////////////////////////////////////////////////// +// SAX case 0x8f: M6502_ABSOLUTE_WRITE M6502_SAX @@ -1981,7 +2034,8 @@ M6502_INDIRECTX_WRITE M6502_SAX break; - +////////////////////////////////////////////////// +// SBC case 0xe9: case 0xeb: M6502_IMMEDIATE_READ @@ -2023,31 +2077,36 @@ M6502_INDIRECTY_READ M6502_SBC break; - +////////////////////////////////////////////////// +// SBX case 0xcb: M6502_IMMEDIATE_READ M6502_SBX break; - +////////////////////////////////////////////////// +// SEC case 0x38: M6502_IMPLIED M6502_SEC break; - +////////////////////////////////////////////////// +// SED case 0xf8: M6502_IMPLIED M6502_SED break; - +////////////////////////////////////////////////// +// SEI case 0x78: M6502_IMPLIED M6502_SEI break; - +////////////////////////////////////////////////// +// SHA case 0x9f: M6502_ABSOLUTEY_WRITE M6502_SHA @@ -2058,25 +2117,29 @@ M6502_INDIRECTY_WRITE M6502_SHA break; - +////////////////////////////////////////////////// +// SHS case 0x9b: M6502_ABSOLUTEY_WRITE M6502_SHS break; - +////////////////////////////////////////////////// +// SHX case 0x9e: M6502_ABSOLUTEY_WRITE M6502_SHX break; - +////////////////////////////////////////////////// +// SHY case 0x9c: M6502_ABSOLUTEX_WRITE M6502_SHY break; - +////////////////////////////////////////////////// +// SLO case 0x0f: M6502_ABSOLUTE_READMODIFYWRITE M6502_SLO @@ -2112,7 +2175,8 @@ M6502_INDIRECTY_READMODIFYWRITE M6502_SLO break; - +////////////////////////////////////////////////// +// SRE case 0x4f: M6502_ABSOLUTE_READMODIFYWRITE M6502_SRE diff --git a/src/emucore/System.cxx b/src/emucore/System.cxx index 1f077d18a..cdc197527 100644 --- a/src/emucore/System.cxx +++ b/src/emucore/System.cxx @@ -113,6 +113,9 @@ uInt8 System::peek(uInt16 addr, uInt8 flags) { PageAccess& access = myPageAccessTable[(addr & ADDRESS_MASK) >> PAGE_SHIFT]; + if (addr == 0xf52c /*0xf505*/) + addr = addr; + #ifdef DEBUGGER_SUPPORT // Set access type if(access.codeAccessBase) @@ -142,6 +145,9 @@ void System::poke(uInt16 addr, uInt8 value) uInt16 page = (addr & ADDRESS_MASK) >> PAGE_SHIFT; PageAccess& access = myPageAccessTable[page]; + if (addr == 0xf52c /*0xf505*/) + addr = addr; + // See if this page uses direct accessing or not if(access.directPokeBase) { @@ -181,6 +187,8 @@ void System::setAccessFlags(uInt16 addr, uInt8 flags) { #ifdef DEBUGGER_SUPPORT PageAccess& access = myPageAccessTable[(addr & ADDRESS_MASK) >> PAGE_SHIFT]; + if (addr == 0xf52c /*0xf505*/) + addr = addr; if(access.codeAccessBase) *(access.codeAccessBase + (addr & PAGE_MASK)) |= flags;