diff --git a/src/debugger/DebuggerExpressions.hxx b/src/debugger/DebuggerExpressions.hxx index 500d241ae..f7450d635 100644 --- a/src/debugger/DebuggerExpressions.hxx +++ b/src/debugger/DebuggerExpressions.hxx @@ -21,8 +21,9 @@ #include "bspf.hxx" #include "CpuDebug.hxx" -#include "Debugger.hxx" +#include "RamDebug.hxx" #include "TIADebug.hxx" +#include "Debugger.hxx" #include "Expression.hxx" /** @@ -258,6 +259,17 @@ class PlusExpression : public Expression uInt16 evaluate() { return myLHS->evaluate() + myRHS->evaluate(); } }; +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +class RamMethodExpression : public Expression +{ + public: + RamMethodExpression(RAMDEBUG_INT_METHOD method) : Expression(0, 0), myMethod(method) {} + uInt16 evaluate() { return CALL_RAMDEBUG_METHOD(myMethod); } + + private: + RAMDEBUG_INT_METHOD myMethod; +}; + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - class ShiftLeftExpression : public Expression { diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index 95bcd0cad..6aff87f39 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -931,8 +931,9 @@ void DebuggerParser::executeHelp() commandResult += "\nBuilt-in functions:\n"; commandResult += debugger->builtinHelp(); commandResult += "\nPseudo-registers:\n"; - commandResult += "_scan Current scanline count\n"; commandResult += "_bank Currently selected bank\n"; + commandResult += "_rwport Read from a write port was triggered\n"; + commandResult += "_scan Current scanline count\n"; commandResult += "_fcount Number of frames since emulation started\n"; commandResult += "_cclocks Color clocks on current scanline\n"; commandResult += "_vsync Whether vertical sync is enabled (1 or 0)\n"; diff --git a/src/debugger/RamDebug.cxx b/src/debugger/RamDebug.cxx index 8e3399a30..a2ff12e2d 100644 --- a/src/debugger/RamDebug.cxx +++ b/src/debugger/RamDebug.cxx @@ -23,7 +23,8 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - RamDebug::RamDebug(Debugger& dbg, Console& console) - : DebuggerSystem(dbg, console) + : DebuggerSystem(dbg, console), + myReadFromWritePortAddress(0) { // Zero-page RAM is always present addRamArea(0x80, 128, 0, 0); @@ -80,6 +81,22 @@ void RamDebug::write(uInt16 addr, uInt8 value) mySystem.poke(addr, value); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +int RamDebug::readFromWritePort() +{ + int retval = myReadFromWritePortAddress; + if(retval > 0) + myReadFromWritePortAddress = 0; + + return retval; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void RamDebug::setReadFromWritePort(uInt16 address) +{ + myReadFromWritePortAddress = address; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string RamDebug::toString() { diff --git a/src/debugger/RamDebug.hxx b/src/debugger/RamDebug.hxx index 0f8d389f2..39a0c6931 100644 --- a/src/debugger/RamDebug.hxx +++ b/src/debugger/RamDebug.hxx @@ -25,6 +25,12 @@ class System; #include "Array.hxx" #include "DebuggerSystem.hxx" +// pointer types for RamDebug instance methods +typedef int (RamDebug::*RAMDEBUG_INT_METHOD)(); + +// call the pointed-to method on the (global) CPU debugger object. +#define CALL_RAMDEBUG_METHOD(method) ( ( Debugger::debugger().ramDebug().*method)() ) + class RamState : public DebuggerState { public: @@ -60,9 +66,22 @@ class RamDebug : public DebuggerSystem uInt8 read(uInt16 addr); void write(uInt16 addr, uInt8 value); + // These methods are used by the debugger when we wish to know + // if an illegal read from a write port has been performed. + // It's up to each Cartridge to report the error, and a + // conditional breakpoint must be set in the debugger to check + // for occurrences of this. + // + // Note that each time readFromWritePort() returns a hit, the status + // is reset. + int readFromWritePort(); + void setReadFromWritePort(uInt16 address); + private: RamState myState; RamState myOldState; + + uInt16 myReadFromWritePortAddress; }; #endif diff --git a/src/emucore/Cart.cxx b/src/emucore/Cart.cxx index c90855ad4..b4247f19c 100644 --- a/src/emucore/Cart.cxx +++ b/src/emucore/Cart.cxx @@ -34,16 +34,16 @@ #include "CartE7.hxx" #include "CartEF.hxx" #include "CartEFSC.hxx" +#include "CartF0.hxx" #include "CartF4.hxx" #include "CartF4SC.hxx" #include "CartF6.hxx" #include "CartF6SC.hxx" #include "CartF8.hxx" #include "CartF8SC.hxx" -#include "CartFASC.hxx" +#include "CartFA.hxx" #include "CartFE.hxx" #include "CartMC.hxx" -#include "CartMB.hxx" #include "CartCV.hxx" #include "CartUA.hxx" #include "CartSB.hxx" @@ -51,6 +51,8 @@ #include "MD5.hxx" #include "Props.hxx" #include "Settings.hxx" +#include "Debugger.hxx" +#include "RamDebug.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Cartridge* Cartridge::create(const uInt8* image, uInt32 size, string& md5, @@ -163,13 +165,13 @@ Cartridge* Cartridge::create(const uInt8* image, uInt32 size, string& md5, else if(type == "F8SC") cartridge = new CartridgeF8SC(image); else if(type == "FA" || type == "FASC") - cartridge = new CartridgeFASC(image); + cartridge = new CartridgeFA(image); else if(type == "FE") cartridge = new CartridgeFE(image); else if(type == "MC") cartridge = new CartridgeMC(image, size); else if(type == "F0" || type == "MB") - cartridge = new CartridgeMB(image); + cartridge = new CartridgeF0(image); else if(type == "CV") cartridge = new CartridgeCV(image, size); else if(type == "UA") @@ -257,6 +259,15 @@ void Cartridge::registerRamArea(uInt16 start, uInt16 size, myRamAreaList.push_back(area); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Cartridge::triggerReadFromWritePort(uInt16 address) +{ +#ifdef DEBUGGER_SUPPORT + if(&Debugger::debugger().ramDebug()) + Debugger::debugger().ramDebug().setReadFromWritePort(address); +#endif +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string Cartridge::autodetectType(const uInt8* image, uInt32 size) { diff --git a/src/emucore/Cart.hxx b/src/emucore/Cart.hxx index 0bcd7e515..f702eb890 100644 --- a/src/emucore/Cart.hxx +++ b/src/emucore/Cart.hxx @@ -23,7 +23,6 @@ #include class Cartridge; -class System; class Properties; class Settings; @@ -79,7 +78,9 @@ class Cartridge : public Device bool save(ofstream& out); /** - Lock/unlock bankswitching capability. + Lock/unlock bankswitching capability. The debugger will lock + the banks before querying the cart state, otherwise reading values + could inadvertantly cause a bankswitch to occur. */ void lockBank() { myBankLocked = true; } void unlockBank() { myBankLocked = false; } @@ -172,6 +173,14 @@ class Cartridge : public Device */ void registerRamArea(uInt16 start, uInt16 size, uInt16 roffset, uInt16 woffset); + /** + Indicate that an illegal read from the write port has occurred. + This message is sent to the debugger (if support exists). + + @param address The write port address where the read occurred + */ + void triggerReadFromWritePort(uInt16 address); + private: /** Get an image pointer and size for a ROM that is part of a larger, diff --git a/src/emucore/Cart3E.cxx b/src/emucore/Cart3E.cxx index 7e091afac..10d298e97 100644 --- a/src/emucore/Cart3E.cxx +++ b/src/emucore/Cart3E.cxx @@ -110,8 +110,13 @@ uInt8 Cartridge3E::peek(uInt16 address) // Reading from the write port triggers an unwanted write uInt8 value = mySystem->getDataBusState(0xFF); - if(myBankLocked) return value; - else return myRam[(address & 0x03FF) + ((myCurrentBank - 256) << 10)] = value; + if(myBankLocked) + return value; + else + { + triggerReadFromWritePort(address); + return myRam[(address & 0x03FF) + ((myCurrentBank - 256) << 10)] = value; + } } } } diff --git a/src/emucore/Cart4A50.cxx b/src/emucore/Cart4A50.cxx index b42287d24..f995013b8 100644 --- a/src/emucore/Cart4A50.cxx +++ b/src/emucore/Cart4A50.cxx @@ -24,6 +24,9 @@ #include "TIA.hxx" #include "Cart4A50.hxx" +// TODO - properly handle read from write port functionality +// Note: do r/w port restrictions even exist for this scheme?? + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Cartridge4A50::Cartridge4A50(const uInt8* image, uInt32 size) { diff --git a/src/emucore/CartCV.cxx b/src/emucore/CartCV.cxx index 4ccf43179..5f1e40205 100644 --- a/src/emucore/CartCV.cxx +++ b/src/emucore/CartCV.cxx @@ -113,8 +113,13 @@ uInt8 CartridgeCV::peek(uInt16 address) // Reading from the write port triggers an unwanted write uInt8 value = mySystem->getDataBusState(0xFF); - if(myBankLocked) return value; - else return myRAM[address & 0x03FF] = value; + if(myBankLocked) + return value; + else + { + triggerReadFromWritePort(address); + return myRAM[address & 0x03FF] = value; + } } else { diff --git a/src/emucore/CartDPC.cxx b/src/emucore/CartDPC.cxx index ad3189f87..8e8acc2c3 100644 --- a/src/emucore/CartDPC.cxx +++ b/src/emucore/CartDPC.cxx @@ -23,6 +23,9 @@ #include "System.hxx" #include "CartDPC.hxx" +// TODO - properly handle read from write port functionality +// Note: do r/w port restrictions even exist for this scheme?? + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeDPC::CartridgeDPC(const uInt8* image, uInt32 size) { diff --git a/src/emucore/CartE7.cxx b/src/emucore/CartE7.cxx index 23370f471..771820b81 100644 --- a/src/emucore/CartE7.cxx +++ b/src/emucore/CartE7.cxx @@ -22,6 +22,8 @@ #include "System.hxx" #include "CartE7.hxx" +// TODO - check for unwanted read from write port in the upper 256B RAM area + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeE7::CartridgeE7(const uInt8* image) { @@ -109,8 +111,13 @@ uInt8 CartridgeE7::peek(uInt16 address) // Reading from the write port triggers an unwanted write uInt8 value = mySystem->getDataBusState(0xFF); - if(myBankLocked) return value; - else return myImage[(myCurrentSlice[address >> 11] << 11) + (address & 0x07FF)] = value; + if(myBankLocked) + return value; + else + { + triggerReadFromWritePort(address); + return myImage[(myCurrentSlice[address >> 11] << 11) + (address & 0x07FF)] = value; + } } else return myImage[(myCurrentSlice[address >> 11] << 11) + (address & 0x07FF)]; diff --git a/src/emucore/CartEFSC.cxx b/src/emucore/CartEFSC.cxx index 56af8592d..f2e90395d 100644 --- a/src/emucore/CartEFSC.cxx +++ b/src/emucore/CartEFSC.cxx @@ -104,8 +104,13 @@ uInt8 CartridgeEFSC::peek(uInt16 address) // Reading from the write port triggers an unwanted write uInt8 value = mySystem->getDataBusState(0xFF); - if(myBankLocked) return value; - else return myRAM[address] = value; + if(myBankLocked) + return value; + else + { + triggerReadFromWritePort(address); + return myRAM[address] = value; + } } else return myImage[(myCurrentBank << 12) + address]; diff --git a/src/emucore/CartMB.cxx b/src/emucore/CartF0.cxx similarity index 86% rename from src/emucore/CartMB.cxx rename to src/emucore/CartF0.cxx index 8a7086b3d..fe599de1d 100644 --- a/src/emucore/CartMB.cxx +++ b/src/emucore/CartF0.cxx @@ -20,22 +20,22 @@ #include #include "System.hxx" -#include "CartMB.hxx" +#include "CartF0.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeMB::CartridgeMB(const uInt8* image) +CartridgeF0::CartridgeF0(const uInt8* image) { // Copy the ROM image into my buffer memcpy(myImage, image, 65536); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeMB::~CartridgeMB() +CartridgeF0::~CartridgeF0() { } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void CartridgeMB::reset() +void CartridgeF0::reset() { // Upon reset we switch to bank 1 myCurrentBank = 0; @@ -43,7 +43,7 @@ void CartridgeMB::reset() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void CartridgeMB::install(System& system) +void CartridgeF0::install(System& system) { mySystem = &system; uInt16 shift = mySystem->pageShift(); @@ -68,7 +68,7 @@ void CartridgeMB::install(System& system) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt8 CartridgeMB::peek(uInt16 address) +uInt8 CartridgeF0::peek(uInt16 address) { address &= 0x0FFF; @@ -80,7 +80,7 @@ uInt8 CartridgeMB::peek(uInt16 address) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void CartridgeMB::poke(uInt16 address, uInt8) +void CartridgeF0::poke(uInt16 address, uInt8) { address &= 0x0FFF; @@ -90,7 +90,7 @@ void CartridgeMB::poke(uInt16 address, uInt8) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void CartridgeMB::incbank() +void CartridgeF0::incbank() { if(myBankLocked) return; @@ -116,7 +116,7 @@ void CartridgeMB::incbank() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void CartridgeMB::bank(uInt16 bank) +void CartridgeF0::bank(uInt16 bank) { if(myBankLocked) return; @@ -125,33 +125,33 @@ void CartridgeMB::bank(uInt16 bank) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -int CartridgeMB::bank() +int CartridgeF0::bank() { return myCurrentBank; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -int CartridgeMB::bankCount() +int CartridgeF0::bankCount() { return 16; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartridgeMB::patch(uInt16 address, uInt8 value) +bool CartridgeF0::patch(uInt16 address, uInt8 value) { myImage[(myCurrentBank << 12) + (address & 0x0FFF)] = value; return true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt8* CartridgeMB::getImage(int& size) +uInt8* CartridgeF0::getImage(int& size) { size = 65536; return &myImage[0]; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartridgeMB::save(Serializer& out) const +bool CartridgeF0::save(Serializer& out) const { const string& cart = name(); @@ -163,7 +163,7 @@ bool CartridgeMB::save(Serializer& out) const } catch(const char* msg) { - cerr << "ERROR: CartridgeMB::save" << endl << " " << msg << endl; + cerr << "ERROR: CartridgeF0::save" << endl << " " << msg << endl; return false; } @@ -171,7 +171,7 @@ bool CartridgeMB::save(Serializer& out) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartridgeMB::load(Serializer& in) +bool CartridgeF0::load(Serializer& in) { const string& cart = name(); @@ -184,7 +184,7 @@ bool CartridgeMB::load(Serializer& in) } catch(const char* msg) { - cerr << "ERROR: CartridgeMB::load" << endl << " " << msg << endl; + cerr << "ERROR: CartridgeF0::load" << endl << " " << msg << endl; return false; } diff --git a/src/emucore/CartMB.hxx b/src/emucore/CartF0.hxx similarity index 89% rename from src/emucore/CartMB.hxx rename to src/emucore/CartF0.hxx index a08477492..cedc580da 100644 --- a/src/emucore/CartMB.hxx +++ b/src/emucore/CartF0.hxx @@ -16,8 +16,8 @@ // $Id$ //============================================================================ -#ifndef CARTRIDGEMB_HXX -#define CARTRIDGEMB_HXX +#ifndef CARTRIDGEF0_HXX +#define CARTRIDGEF0_HXX class System; @@ -29,15 +29,10 @@ class System; There are 16 4K banks. Accessing $1FF0 switches to next bank. - Note that while the bankswitch type for this class has historically - been 'MB', one must now use 'F0' to activate it. - This brings the bankswitch names in line with those used in z26 and - the various cart programming apps for KrokCart and Harmony/Melody. - @author Eckhard Stolberg @version $Id$ */ -class CartridgeMB : public Cartridge +class CartridgeF0 : public Cartridge { public: /** @@ -45,12 +40,12 @@ class CartridgeMB : public Cartridge @param image Pointer to the ROM image */ - CartridgeMB(const uInt8* image); + CartridgeF0(const uInt8* image); /** Destructor */ - virtual ~CartridgeMB(); + virtual ~CartridgeF0(); public: /** diff --git a/src/emucore/CartF4SC.cxx b/src/emucore/CartF4SC.cxx index 632346bce..001203c1a 100644 --- a/src/emucore/CartF4SC.cxx +++ b/src/emucore/CartF4SC.cxx @@ -104,8 +104,13 @@ uInt8 CartridgeF4SC::peek(uInt16 address) // Reading from the write port triggers an unwanted write uInt8 value = mySystem->getDataBusState(0xFF); - if(myBankLocked) return value; - else return myRAM[address] = value; + if(myBankLocked) + return value; + else + { + triggerReadFromWritePort(address); + return myRAM[address] = value; + } } else return myImage[(myCurrentBank << 12) + address]; diff --git a/src/emucore/CartF6SC.cxx b/src/emucore/CartF6SC.cxx index 3e26e416b..7917fee29 100644 --- a/src/emucore/CartF6SC.cxx +++ b/src/emucore/CartF6SC.cxx @@ -127,8 +127,13 @@ uInt8 CartridgeF6SC::peek(uInt16 address) // Reading from the write port triggers an unwanted write uInt8 value = mySystem->getDataBusState(0xFF); - if(myBankLocked) return value; - else return myRAM[address] = value; + if(myBankLocked) + return value; + else + { + triggerReadFromWritePort(address); + return myRAM[address] = value; + } } else return myImage[(myCurrentBank << 12) + address]; diff --git a/src/emucore/CartF8SC.cxx b/src/emucore/CartF8SC.cxx index 64a3c04ff..c24a83b9b 100644 --- a/src/emucore/CartF8SC.cxx +++ b/src/emucore/CartF8SC.cxx @@ -117,8 +117,13 @@ uInt8 CartridgeF8SC::peek(uInt16 address) // Reading from the write port triggers an unwanted write uInt8 value = mySystem->getDataBusState(0xFF); - if(myBankLocked) return value; - else return myRAM[address] = value; + if(myBankLocked) + return value; + else + { + triggerReadFromWritePort(address); + return myRAM[address] = value; + } } else return myImage[(myCurrentBank << 12) + address]; diff --git a/src/emucore/CartFASC.cxx b/src/emucore/CartFA.cxx similarity index 88% rename from src/emucore/CartFASC.cxx rename to src/emucore/CartFA.cxx index 619dbdf2b..95f23f193 100644 --- a/src/emucore/CartFASC.cxx +++ b/src/emucore/CartFA.cxx @@ -20,10 +20,10 @@ #include #include "System.hxx" -#include "CartFASC.hxx" +#include "CartFA.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeFASC::CartridgeFASC(const uInt8* image) +CartridgeFA::CartridgeFA(const uInt8* image) { // Copy the ROM image into my buffer memcpy(myImage, image, 12288); @@ -33,12 +33,12 @@ CartridgeFASC::CartridgeFASC(const uInt8* image) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartridgeFASC::~CartridgeFASC() +CartridgeFA::~CartridgeFA() { } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void CartridgeFASC::reset() +void CartridgeFA::reset() { // Initialize RAM with random values for(uInt32 i = 0; i < 256; ++i) @@ -49,7 +49,7 @@ void CartridgeFASC::reset() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void CartridgeFASC::install(System& system) +void CartridgeFA::install(System& system) { mySystem = &system; uInt16 shift = mySystem->pageShift(); @@ -91,7 +91,7 @@ void CartridgeFASC::install(System& system) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt8 CartridgeFASC::peek(uInt16 address) +uInt8 CartridgeFA::peek(uInt16 address) { address &= 0x0FFF; @@ -122,15 +122,20 @@ uInt8 CartridgeFASC::peek(uInt16 address) // Reading from the write port triggers an unwanted write uInt8 value = mySystem->getDataBusState(0xFF); - if(myBankLocked) return value; - else return myRAM[address] = value; + if(myBankLocked) + return value; + else + { + triggerReadFromWritePort(address); + return myRAM[address] = value; + } } else return myImage[(myCurrentBank << 12) + address]; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void CartridgeFASC::poke(uInt16 address, uInt8) +void CartridgeFA::poke(uInt16 address, uInt8) { address &= 0x0FFF; @@ -162,7 +167,7 @@ void CartridgeFASC::poke(uInt16 address, uInt8) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void CartridgeFASC::bank(uInt16 bank) +void CartridgeFA::bank(uInt16 bank) { if(myBankLocked) return; @@ -187,33 +192,33 @@ void CartridgeFASC::bank(uInt16 bank) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -int CartridgeFASC::bank() +int CartridgeFA::bank() { return myCurrentBank; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -int CartridgeFASC::bankCount() +int CartridgeFA::bankCount() { return 3; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartridgeFASC::patch(uInt16 address, uInt8 value) +bool CartridgeFA::patch(uInt16 address, uInt8 value) { myImage[(myCurrentBank << 12) + (address & 0x0FFF)] = value; return true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt8* CartridgeFASC::getImage(int& size) +uInt8* CartridgeFA::getImage(int& size) { size = 12288; return &myImage[0]; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartridgeFASC::save(Serializer& out) const +bool CartridgeFA::save(Serializer& out) const { const string& cart = name(); @@ -230,7 +235,7 @@ bool CartridgeFASC::save(Serializer& out) const } catch(const char* msg) { - cerr << "ERROR: CartridgeFASC::save" << endl << " " << msg << endl; + cerr << "ERROR: CartridgeFA::save" << endl << " " << msg << endl; return false; } @@ -238,7 +243,7 @@ bool CartridgeFASC::save(Serializer& out) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool CartridgeFASC::load(Serializer& in) +bool CartridgeFA::load(Serializer& in) { const string& cart = name(); @@ -255,7 +260,7 @@ bool CartridgeFASC::load(Serializer& in) } catch(const char* msg) { - cerr << "ERROR: CartridgeFASC::load" << endl << " " << msg << endl; + cerr << "ERROR: CartridgeFA::load" << endl << " " << msg << endl; return false; } diff --git a/src/emucore/CartFASC.hxx b/src/emucore/CartFA.hxx similarity index 89% rename from src/emucore/CartFASC.hxx rename to src/emucore/CartFA.hxx index 6997cdd0b..1f3493cf7 100644 --- a/src/emucore/CartFASC.hxx +++ b/src/emucore/CartFA.hxx @@ -16,8 +16,8 @@ // $Id$ //============================================================================ -#ifndef CARTRIDGEFASC_HXX -#define CARTRIDGEFASC_HXX +#ifndef CARTRIDGEFA_HXX +#define CARTRIDGEFA_HXX class System; @@ -28,15 +28,10 @@ class System; Cartridge class used for CBS' RAM Plus cartridges. There are three 4K banks and 256 bytes of RAM. - Note that while the bankswitch type for this class has historically - been 'FASC', one must now use 'FA' to activate it. - This brings the bankswitch names in line with those used in z26 and - the various cart programming apps for KrokCart and Harmony/Melody. - @author Bradford W. Mott @version $Id$ */ -class CartridgeFASC : public Cartridge +class CartridgeFA : public Cartridge { public: /** @@ -44,12 +39,12 @@ class CartridgeFASC : public Cartridge @param image Pointer to the ROM image */ - CartridgeFASC(const uInt8* image); + CartridgeFA(const uInt8* image); /** Destructor */ - virtual ~CartridgeFASC(); + virtual ~CartridgeFA(); public: /** diff --git a/src/emucore/CartMC.cxx b/src/emucore/CartMC.cxx index c8c1b489e..87849fbfb 100644 --- a/src/emucore/CartMC.cxx +++ b/src/emucore/CartMC.cxx @@ -22,7 +22,9 @@ #include "System.hxx" #include "CartMC.hxx" -// TODO - properly handle read from write port functionality +// TODO - much more testing of this scheme is required +// No test ROMs exist as of 2009-11-08, so we can't be sure how +// accurate the emulation is // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeMC::CartridgeMC(const uInt8* image, uInt32 size) @@ -141,8 +143,16 @@ uInt8 CartridgeMC::peek(uInt16 address) else { // Oops, reading from the write port of the RAM block! - myRAM[(uInt32)((block & 0x3F) << 9) + (address & 0x01FF)] = 0; - return 0; + // Reading from the write port triggers an unwanted write + uInt8 value = mySystem->getDataBusState(0xFF); + + if(myBankLocked) + return value; + else + { + triggerReadFromWritePort(address); + return myRAM[(uInt32)((block & 0x3F) << 9) + (address & 0x01FF)] = value; + } } } } diff --git a/src/emucore/module.mk b/src/emucore/module.mk index 6b6c96ffb..0e6a634e0 100644 --- a/src/emucore/module.mk +++ b/src/emucore/module.mk @@ -16,15 +16,15 @@ MODULE_OBJS := \ src/emucore/CartE7.o \ src/emucore/CartEF.o \ src/emucore/CartEFSC.o \ + src/emucore/CartF0.o \ src/emucore/CartF4.o \ src/emucore/CartF4SC.o \ src/emucore/CartF6.o \ src/emucore/CartF6SC.o \ src/emucore/CartF8.o \ src/emucore/CartF8SC.o \ - src/emucore/CartFASC.o \ + src/emucore/CartFA.o \ src/emucore/CartFE.o \ - src/emucore/CartMB.o \ src/emucore/CartMC.o \ src/emucore/CartSB.o \ src/emucore/CartUA.o \ diff --git a/src/yacc/YaccParser.cxx b/src/yacc/YaccParser.cxx index ba05fc086..7ed3e19cb 100644 --- a/src/yacc/YaccParser.cxx +++ b/src/yacc/YaccParser.cxx @@ -27,6 +27,7 @@ #include "Expression.hxx" #include "CpuDebug.hxx" +#include "RamDebug.hxx" #include "TIADebug.hxx" #include "DebuggerExpressions.hxx" @@ -76,7 +77,6 @@ int parse(const char *in) { } /* hand-rolled lexer. Hopefully faster than flex... */ - inline bool is_base_prefix(char x) { return ( (x=='\\' || x=='$' || x=='#') ); } inline bool is_identifier(char x) { @@ -164,8 +164,8 @@ int const_to_int(char *c) { } } -// special methods that get e.g. CPU registers // TODO: store in a map or something +// special methods that get e.g. CPU registers CPUDEBUG_INT_METHOD getCpuSpecial(char *c) { if(strcmp(c, "a") == 0) return &CpuDebug::a; @@ -209,6 +209,14 @@ CPUDEBUG_INT_METHOD getCpuSpecial(char *c) { return 0; } +// special methods that get RAM internal state +RAMDEBUG_INT_METHOD getRamSpecial(char *c) { + if(strcmp(c, "_rwport") == 0) + return &RamDebug::readFromWritePort; + + return 0; +} + // special methods that get TIA internal state TIADEBUG_INT_METHOD getTiaSpecial(char *c) { if(strcmp(c, "_scan") == 0) @@ -253,6 +261,7 @@ int yylex() { case ST_IDENTIFIER: { CPUDEBUG_INT_METHOD cpuMeth; + RAMDEBUG_INT_METHOD ramMeth; TIADEBUG_INT_METHOD tiaMeth; char *bufp = idbuf; @@ -279,6 +288,9 @@ int yylex() { } else if( (cpuMeth = getCpuSpecial(idbuf)) ) { yylval.cpuMethod = cpuMeth; return CPU_METHOD; + } else if( (ramMeth = getRamSpecial(idbuf)) ) { + yylval.ramMethod = ramMeth; + return RAM_METHOD; } else if( (tiaMeth = getTiaSpecial(idbuf)) ) { yylval.tiaMethod = tiaMeth; return TIA_METHOD; diff --git a/src/yacc/stella.y b/src/yacc/stella.y index 960119c63..c85731f71 100644 --- a/src/yacc/stella.y +++ b/src/yacc/stella.y @@ -30,6 +30,7 @@ void yyerror(const char *e) { int val; char *equate; CPUDEBUG_INT_METHOD cpuMethod; + RAMDEBUG_INT_METHOD ramMethod; TIADEBUG_INT_METHOD tiaMethod; Expression *exp; char *function; @@ -40,6 +41,7 @@ void yyerror(const char *e) { %token ERR %token EQUATE %token CPU_METHOD +%token RAM_METHOD %token TIA_METHOD %token FUNCTION @@ -95,6 +97,7 @@ expression: expression '+' expression { if(DEBUG_EXP) fprintf(stderr, " +"); $$ | NUMBER { if(DEBUG_EXP) fprintf(stderr, " %d", $1); $$ = new ConstExpression($1); lastExp = $$; } | EQUATE { if(DEBUG_EXP) fprintf(stderr, " %s", $1); $$ = new EquateExpression($1); lastExp = $$; } | CPU_METHOD { if(DEBUG_EXP) fprintf(stderr, " (CpuMethod)"); $$ = new CpuMethodExpression($1); lastExp = $$; } + | RAM_METHOD { if(DEBUG_EXP) fprintf(stderr, " (RamMethod)"); $$ = new RamMethodExpression($1); lastExp = $$; } | TIA_METHOD { if(DEBUG_EXP) fprintf(stderr, " (TiaMethod)"); $$ = new TiaMethodExpression($1); lastExp = $$; } | FUNCTION { if(DEBUG_EXP) fprintf(stderr, " (function)"); $$ = new FunctionExpression($1); lastExp = $$; } | ERR { if(DEBUG_EXP) fprintf(stderr, " ERR"); yyerror((char*)"Invalid label or constant"); return 1; } diff --git a/src/yacc/y.tab.c b/src/yacc/y.tab.c index 1bd7e7aae..3761713a4 100644 --- a/src/yacc/y.tab.c +++ b/src/yacc/y.tab.c @@ -1,24 +1,23 @@ -/* A Bison parser, made by GNU Bison 2.3. */ + +/* A Bison parser, made by GNU Bison 2.4.1. */ /* Skeleton implementation for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ + along with this program. If not, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -29,7 +28,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ @@ -47,7 +46,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.3" +#define YYBISON_VERSION "2.4.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -55,59 +54,20 @@ /* Pure parsers. */ #define YYPURE 0 +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + /* Using locations. */ #define YYLSP_NEEDED 0 -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - NUMBER = 258, - ERR = 259, - EQUATE = 260, - CPU_METHOD = 261, - TIA_METHOD = 262, - FUNCTION = 263, - LOG_OR = 264, - LOG_AND = 265, - LOG_NOT = 266, - SHL = 267, - SHR = 268, - EQ = 269, - NE = 270, - LTE = 271, - GTE = 272, - DEREF = 273, - UMINUS = 274 - }; -#endif -/* Tokens. */ -#define NUMBER 258 -#define ERR 259 -#define EQUATE 260 -#define CPU_METHOD 261 -#define TIA_METHOD 262 -#define FUNCTION 263 -#define LOG_OR 264 -#define LOG_AND 265 -#define LOG_NOT 266 -#define SHL 267 -#define SHR 268 -#define EQ 269 -#define NE 270 -#define LTE 271 -#define GTE 272 -#define DEREF 273 -#define UMINUS 274 - - - - /* Copy the first part of user declarations. */ + +/* Line 189 of yacc.c */ #line 1 "stella.y" #include @@ -137,6 +97,9 @@ void yyerror(const char *e) { +/* Line 189 of yacc.c */ +#line 102 "y.tab.c" + /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 0 @@ -155,32 +118,87 @@ void yyerror(const char *e) { # define YYTOKEN_TABLE 0 #endif + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NUMBER = 258, + ERR = 259, + EQUATE = 260, + CPU_METHOD = 261, + RAM_METHOD = 262, + TIA_METHOD = 263, + FUNCTION = 264, + LOG_OR = 265, + LOG_AND = 266, + LOG_NOT = 267, + SHL = 268, + SHR = 269, + EQ = 270, + NE = 271, + LTE = 272, + GTE = 273, + DEREF = 274, + UMINUS = 275 + }; +#endif +/* Tokens. */ +#define NUMBER 258 +#define ERR 259 +#define EQUATE 260 +#define CPU_METHOD 261 +#define RAM_METHOD 262 +#define TIA_METHOD 263 +#define FUNCTION 264 +#define LOG_OR 265 +#define LOG_AND 266 +#define LOG_NOT 267 +#define SHL 268 +#define SHR 269 +#define EQ 270 +#define NE 271 +#define LTE 272 +#define GTE 273 +#define DEREF 274 +#define UMINUS 275 + + + + #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 29 "stella.y" { + +/* Line 214 of yacc.c */ +#line 29 "stella.y" + int val; char *equate; CPUDEBUG_INT_METHOD cpuMethod; + RAMDEBUG_INT_METHOD ramMethod; TIADEBUG_INT_METHOD tiaMethod; Expression *exp; char *function; -} -/* Line 187 of yacc.c. */ -#line 171 "y.tab.c" - YYSTYPE; + + + +/* Line 214 of yacc.c */ +#line 190 "y.tab.c" +} YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 #endif - /* Copy the second part of user declarations. */ -/* Line 216 of yacc.c. */ -#line 184 "y.tab.c" +/* Line 264 of yacc.c */ +#line 202 "y.tab.c" #ifdef short # undef short @@ -255,14 +273,14 @@ typedef short int yytype_int16; #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static int -YYID (int i) +YYID (int yyi) #else static int -YYID (i) - int i; +YYID (yyi) + int yyi; #endif { - return i; + return yyi; } #endif @@ -343,9 +361,9 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ /* A type that is properly aligned for any stack member. */ union yyalloc { - yytype_int16 yyss; - YYSTYPE yyvs; - }; + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) @@ -379,12 +397,12 @@ union yyalloc elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack) \ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ @@ -393,22 +411,22 @@ union yyalloc #endif /* YYFINAL -- State number of the termination state. */ -#define YYFINAL 25 +#define YYFINAL 26 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 226 +#define YYLAST 227 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 37 +#define YYNTOKENS 38 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 3 /* YYNRULES -- Number of rules. */ -#define YYNRULES 35 +#define YYNRULES 36 /* YYNRULES -- Number of states. */ -#define YYNSTATES 66 +#define YYNSTATES 67 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 274 +#define YYMAXUTOK 275 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -419,16 +437,16 @@ static const yytype_uint8 yytranslate[] = 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 32, 2, 2, 2, 13, 19, 2, - 34, 35, 11, 10, 2, 9, 2, 12, 2, 2, + 2, 2, 2, 33, 2, 2, 2, 14, 20, 2, + 35, 36, 12, 11, 2, 10, 2, 13, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 22, 2, 23, 2, 33, 2, 2, 2, 2, 2, + 23, 2, 24, 2, 34, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 30, 2, 36, 18, 2, 2, 2, 2, 2, + 2, 31, 2, 37, 19, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 17, 2, 31, 2, 2, 2, + 2, 2, 2, 2, 18, 2, 32, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -442,8 +460,8 @@ static const yytype_uint8 yytranslate[] = 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, - 5, 6, 7, 8, 14, 15, 16, 20, 21, 24, - 25, 26, 27, 28, 29 + 5, 6, 7, 8, 9, 15, 16, 17, 21, 22, + 25, 26, 27, 28, 29, 30 }; #if YYDEBUG @@ -454,33 +472,34 @@ static const yytype_uint8 yyprhs[] = 0, 0, 3, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 80, 83, 86, 89, 92, 95, 98, 102, - 107, 109, 111, 113, 115, 117 + 107, 109, 111, 113, 115, 117, 119 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int8 yyrhs[] = { - 38, 0, -1, 39, -1, 39, 10, 39, -1, 39, - 9, 39, -1, 39, 11, 39, -1, 39, 12, 39, - -1, 39, 13, 39, -1, 39, 19, 39, -1, 39, - 17, 39, -1, 39, 18, 39, -1, 39, 22, 39, - -1, 39, 23, 39, -1, 39, 27, 39, -1, 39, - 26, 39, -1, 39, 25, 39, -1, 39, 24, 39, - -1, 39, 21, 39, -1, 39, 20, 39, -1, 39, - 14, 39, -1, 39, 15, 39, -1, 9, 39, -1, - 31, 39, -1, 32, 39, -1, 11, 39, -1, 33, - 39, -1, 22, 39, -1, 23, 39, -1, 34, 39, - 35, -1, 39, 30, 39, 36, -1, 3, -1, 5, - -1, 6, -1, 7, -1, 8, -1, 4, -1 + 39, 0, -1, 40, -1, 40, 11, 40, -1, 40, + 10, 40, -1, 40, 12, 40, -1, 40, 13, 40, + -1, 40, 14, 40, -1, 40, 20, 40, -1, 40, + 18, 40, -1, 40, 19, 40, -1, 40, 23, 40, + -1, 40, 24, 40, -1, 40, 28, 40, -1, 40, + 27, 40, -1, 40, 26, 40, -1, 40, 25, 40, + -1, 40, 22, 40, -1, 40, 21, 40, -1, 40, + 15, 40, -1, 40, 16, 40, -1, 10, 40, -1, + 32, 40, -1, 33, 40, -1, 12, 40, -1, 34, + 40, -1, 23, 40, -1, 24, 40, -1, 35, 40, + 36, -1, 40, 31, 40, 37, -1, 3, -1, 5, + -1, 6, -1, 7, -1, 8, -1, 9, -1, 4, + -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint8 yyrline[] = { - 0, 65, 65, 68, 69, 70, 71, 72, 73, 74, - 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, - 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, - 95, 96, 97, 98, 99, 100 + 0, 67, 67, 70, 71, 72, 73, 74, 75, 76, + 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, + 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, + 97, 98, 99, 100, 101, 102, 103 }; #endif @@ -490,10 +509,10 @@ static const yytype_uint8 yyrline[] = static const char *const yytname[] = { "$end", "error", "$undefined", "NUMBER", "ERR", "EQUATE", "CPU_METHOD", - "TIA_METHOD", "FUNCTION", "'-'", "'+'", "'*'", "'/'", "'%'", "LOG_OR", - "LOG_AND", "LOG_NOT", "'|'", "'^'", "'&'", "SHL", "SHR", "'<'", "'>'", - "EQ", "NE", "LTE", "GTE", "DEREF", "UMINUS", "'['", "'~'", "'!'", "'@'", - "'('", "')'", "']'", "$accept", "statement", "expression", 0 + "RAM_METHOD", "TIA_METHOD", "FUNCTION", "'-'", "'+'", "'*'", "'/'", + "'%'", "LOG_OR", "LOG_AND", "LOG_NOT", "'|'", "'^'", "'&'", "SHL", "SHR", + "'<'", "'>'", "EQ", "NE", "LTE", "GTE", "DEREF", "UMINUS", "'['", "'~'", + "'!'", "'@'", "'('", "')'", "']'", "$accept", "statement", "expression", 0 }; #endif @@ -502,20 +521,20 @@ static const char *const yytname[] = token YYLEX-NUM. */ static const yytype_uint16 yytoknum[] = { - 0, 256, 257, 258, 259, 260, 261, 262, 263, 45, - 43, 42, 47, 37, 264, 265, 266, 124, 94, 38, - 267, 268, 60, 62, 269, 270, 271, 272, 273, 274, - 91, 126, 33, 64, 40, 41, 93 + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 45, 43, 42, 47, 37, 265, 266, 267, 124, 94, + 38, 268, 269, 60, 62, 270, 271, 272, 273, 274, + 275, 91, 126, 33, 64, 40, 41, 93 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 37, 38, 39, 39, 39, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 39 + 0, 38, 39, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -524,7 +543,7 @@ static const yytype_uint8 yyr2[] = 0, 2, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 3, 4, - 1, 1, 1, 1, 1, 1 + 1, 1, 1, 1, 1, 1, 1 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state @@ -532,39 +551,39 @@ static const yytype_uint8 yyr2[] = means the default is an error. */ static const yytype_uint8 yydefact[] = { - 0, 30, 35, 31, 32, 33, 34, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 2, 21, 24, 26, - 27, 22, 23, 25, 0, 1, 0, 0, 0, 0, + 0, 30, 36, 31, 32, 33, 34, 35, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 2, 21, 24, + 26, 27, 22, 23, 25, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 28, 4, 3, 5, 6, - 7, 19, 20, 9, 10, 8, 18, 17, 11, 12, - 16, 15, 14, 13, 0, 29 + 0, 0, 0, 0, 0, 0, 28, 4, 3, 5, + 6, 7, 19, 20, 9, 10, 8, 18, 17, 11, + 12, 16, 15, 14, 13, 0, 29 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { - -1, 15, 16 + -1, 16, 17 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -14 +#define YYPACT_NINF -15 static const yytype_int16 yypact[] = { - 35, -14, -14, -14, -14, -14, -14, 35, 35, 35, - 35, 35, 35, 35, 35, 16, 116, -13, -13, 187, - 187, -13, -13, -13, 89, -14, 35, 35, 35, 35, + 35, -15, -15, -15, -15, -15, -15, -15, 35, 35, + 35, 35, 35, 35, 35, 35, 16, 116, -14, -14, + 187, 187, -14, -14, -14, 89, -15, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, - 35, 35, 35, 35, 35, -14, 136, 136, 150, 150, - 150, 164, 178, 29, 29, -12, 196, 196, 187, 187, - 187, 187, 187, 187, 61, -14 + 35, 35, 35, 35, 35, 35, -15, 136, 136, 150, + 150, 150, 164, 178, 29, 29, -13, 196, 196, 187, + 187, 187, 187, 187, 187, 61, -15 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { - -14, -14, -7 + -15, -15, -8 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If @@ -574,69 +593,69 @@ static const yytype_int8 yypgoto[] = #define YYTABLE_NINF -1 static const yytype_int8 yytable[] = { - 17, 18, 19, 20, 21, 22, 23, 24, 36, 37, - 38, 39, 40, 41, 42, 43, 25, 44, 44, 46, - 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, - 57, 58, 59, 60, 61, 62, 63, 64, 1, 2, - 3, 4, 5, 6, 7, 0, 8, 0, 35, 36, - 37, 38, 39, 40, 41, 42, 43, 9, 10, 44, - 0, 0, 0, 0, 0, 0, 11, 12, 13, 14, - 26, 27, 28, 29, 30, 31, 32, 0, 33, 34, - 35, 36, 37, 38, 39, 40, 41, 42, 43, 0, - 0, 44, 0, 0, 0, 0, 0, 65, 26, 27, - 28, 29, 30, 31, 32, 0, 33, 34, 35, 36, - 37, 38, 39, 40, 41, 42, 43, 0, 0, 44, - 0, 0, 0, 0, 45, 26, 27, 28, 29, 30, - 31, 32, 0, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 0, 0, 44, 28, 29, 30, - 31, 32, 0, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 31, 32, 44, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, 43, 0, 32, - 44, 33, 34, 35, 36, 37, 38, 39, 40, 41, - 42, 43, 0, 0, 44, 33, 34, 35, 36, 37, - 38, 39, 40, 41, 42, 43, 0, 0, 44, -1, - -1, -1, -1, -1, -1, 0, 0, 44, 38, 39, - 40, 41, 42, 43, 0, 0, 44 + 18, 19, 20, 21, 22, 23, 24, 25, 37, 38, + 39, 40, 41, 42, 43, 44, 26, 45, 45, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 1, 2, + 3, 4, 5, 6, 7, 8, 0, 9, 0, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 10, 11, + 45, 0, 0, 0, 0, 0, 0, 12, 13, 14, + 15, 27, 28, 29, 30, 31, 32, 33, 0, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 0, 0, 45, 0, 0, 0, 0, 0, 66, 27, + 28, 29, 30, 31, 32, 33, 0, 34, 35, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 0, 0, + 45, 0, 0, 0, 0, 46, 27, 28, 29, 30, + 31, 32, 33, 0, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 0, 0, 45, 29, 30, + 31, 32, 33, 0, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 32, 33, 45, 34, 35, + 36, 37, 38, 39, 40, 41, 42, 43, 44, 0, + 33, 45, 34, 35, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 0, 0, 45, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 0, 0, 45, + -1, -1, -1, -1, -1, -1, 0, 0, 45, 39, + 40, 41, 42, 43, 44, 0, 0, 45 }; static const yytype_int8 yycheck[] = { - 7, 8, 9, 10, 11, 12, 13, 14, 20, 21, - 22, 23, 24, 25, 26, 27, 0, 30, 30, 26, - 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, - 37, 38, 39, 40, 41, 42, 43, 44, 3, 4, - 5, 6, 7, 8, 9, -1, 11, -1, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 22, 23, 30, - -1, -1, -1, -1, -1, -1, 31, 32, 33, 34, - 9, 10, 11, 12, 13, 14, 15, -1, 17, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, -1, - -1, 30, -1, -1, -1, -1, -1, 36, 9, 10, - 11, 12, 13, 14, 15, -1, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, -1, -1, 30, - -1, -1, -1, -1, 35, 9, 10, 11, 12, 13, - 14, 15, -1, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, -1, -1, 30, 11, 12, 13, - 14, 15, -1, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 14, 15, 30, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, -1, 15, - 30, 17, 18, 19, 20, 21, 22, 23, 24, 25, - 26, 27, -1, -1, 30, 17, 18, 19, 20, 21, - 22, 23, 24, 25, 26, 27, -1, -1, 30, 22, - 23, 24, 25, 26, 27, -1, -1, 30, 22, 23, - 24, 25, 26, 27, -1, -1, 30 + 8, 9, 10, 11, 12, 13, 14, 15, 21, 22, + 23, 24, 25, 26, 27, 28, 0, 31, 31, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 45, 3, 4, + 5, 6, 7, 8, 9, 10, -1, 12, -1, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 23, 24, + 31, -1, -1, -1, -1, -1, -1, 32, 33, 34, + 35, 10, 11, 12, 13, 14, 15, 16, -1, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + -1, -1, 31, -1, -1, -1, -1, -1, 37, 10, + 11, 12, 13, 14, 15, 16, -1, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, -1, -1, + 31, -1, -1, -1, -1, 36, 10, 11, 12, 13, + 14, 15, 16, -1, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, -1, -1, 31, 12, 13, + 14, 15, 16, -1, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 15, 16, 31, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, -1, + 16, 31, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, -1, -1, 31, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, -1, -1, 31, + 23, 24, 25, 26, 27, 28, -1, -1, 31, 23, + 24, 25, 26, 27, 28, -1, -1, 31 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { - 0, 3, 4, 5, 6, 7, 8, 9, 11, 22, - 23, 31, 32, 33, 34, 38, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 0, 9, 10, 11, 12, - 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 30, 35, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 36 + 0, 3, 4, 5, 6, 7, 8, 9, 10, 12, + 23, 24, 32, 33, 34, 35, 39, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 0, 10, 11, 12, + 13, 14, 15, 16, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 31, 36, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, + 40, 40, 40, 40, 40, 40, 37 }; #define yyerrok (yyerrstatus = 0) @@ -821,17 +840,20 @@ yy_symbol_print (yyoutput, yytype, yyvaluep) #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) #else static void -yy_stack_print (bottom, top) - yytype_int16 *bottom; - yytype_int16 *top; +yy_stack_print (yybottom, yytop) + yytype_int16 *yybottom; + yytype_int16 *yytop; #endif { YYFPRINTF (stderr, "Stack now"); - for (; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } YYFPRINTF (stderr, "\n"); } @@ -865,11 +887,11 @@ yy_reduce_print (yyvsp, yyrule) /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { - fprintf (stderr, " $%d = ", yyi + 1); + YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]) ); - fprintf (stderr, "\n"); + YYFPRINTF (stderr, "\n"); } } @@ -1149,10 +1171,8 @@ yydestruct (yymsg, yytype, yyvaluep) break; } } - /* Prevent warnings from -Wmissing-prototypes. */ - #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus int yyparse (void *YYPARSE_PARAM); @@ -1168,11 +1188,10 @@ int yyparse (); #endif /* ! YYPARSE_PARAM */ - -/* The look-ahead symbol. */ +/* The lookahead symbol. */ int yychar; -/* The semantic value of the look-ahead symbol. */ +/* The semantic value of the lookahead symbol. */ YYSTYPE yylval; /* Number of syntax errors so far. */ @@ -1180,9 +1199,9 @@ int yynerrs; -/*----------. -| yyparse. | -`----------*/ +/*-------------------------. +| yyparse or yypush_parse. | +`-------------------------*/ #ifdef YYPARSE_PARAM #if (defined __STDC__ || defined __C99__FUNC__ \ @@ -1206,14 +1225,39 @@ yyparse () #endif #endif { - - int yystate; + + + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + `yyss': related to states. + `yyvs': related to semantic values. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + YYSIZE_T yystacksize; + int yyn; int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Look-ahead token as an internal (translated) token number. */ - int yytoken = 0; + /* Lookahead token as an internal (translated) token number. */ + int yytoken; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; @@ -1221,51 +1265,28 @@ yyparse () YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss = yyssa; - yytype_int16 *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - YYSTYPE *yyvsp; - - - #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) - YYSIZE_T yystacksize = YYINITDEPTH; - - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - - /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; + yytoken = 0; + yyss = yyssa; + yyvs = yyvsa; + yystacksize = YYINITDEPTH; + YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ + yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ - yyssp = yyss; yyvsp = yyvs; @@ -1295,7 +1316,6 @@ yyparse () YYSTYPE *yyvs1 = yyvs; yytype_int16 *yyss1 = yyss; - /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might @@ -1303,7 +1323,6 @@ yyparse () yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); yyss = yyss1; @@ -1326,9 +1345,8 @@ yyparse () (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); @@ -1339,7 +1357,6 @@ yyparse () yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; - YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); @@ -1349,6 +1366,9 @@ yyparse () YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + if (yystate == YYFINAL) + YYACCEPT; + goto yybackup; /*-----------. @@ -1357,16 +1377,16 @@ yyparse () yybackup: /* Do appropriate processing given the current state. Read a - look-ahead token if we need one and don't already have one. */ + lookahead token if we need one and don't already have one. */ - /* First try to decide what to do without reference to look-ahead token. */ + /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; - /* Not known => get a look-ahead token if don't already have one. */ + /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); @@ -1398,20 +1418,16 @@ yybackup: goto yyreduce; } - if (yyn == YYFINAL) - YYACCEPT; - /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; - /* Shift the look-ahead token. */ + /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - /* Discard the shifted token unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; + /* Discard the shifted token. */ + yychar = YYEMPTY; yystate = yyn; *++yyvsp = yylval; @@ -1451,178 +1467,254 @@ yyreduce: switch (yyn) { case 2: -#line 65 "stella.y" + +/* Line 1455 of yacc.c */ +#line 67 "stella.y" { if(DEBUG_EXP) fprintf(stderr, "\ndone\n"); result.exp = (yyvsp[(1) - (1)].exp); } break; case 3: -#line 68 "stella.y" + +/* Line 1455 of yacc.c */ +#line 70 "stella.y" { if(DEBUG_EXP) fprintf(stderr, " +"); (yyval.exp) = new PlusExpression((yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp)); lastExp = (yyval.exp); } break; case 4: -#line 69 "stella.y" + +/* Line 1455 of yacc.c */ +#line 71 "stella.y" { if(DEBUG_EXP) fprintf(stderr, " -"); (yyval.exp) = new MinusExpression((yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp)); lastExp = (yyval.exp); } break; case 5: -#line 70 "stella.y" + +/* Line 1455 of yacc.c */ +#line 72 "stella.y" { if(DEBUG_EXP) fprintf(stderr, " *"); (yyval.exp) = new MultExpression((yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp)); lastExp = (yyval.exp); } break; case 6: -#line 71 "stella.y" + +/* Line 1455 of yacc.c */ +#line 73 "stella.y" { if(DEBUG_EXP) fprintf(stderr, " /"); (yyval.exp) = new DivExpression((yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp)); lastExp = (yyval.exp); } break; case 7: -#line 72 "stella.y" + +/* Line 1455 of yacc.c */ +#line 74 "stella.y" { if(DEBUG_EXP) fprintf(stderr, " %%"); (yyval.exp) = new ModExpression((yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp)); lastExp = (yyval.exp); } break; case 8: -#line 73 "stella.y" + +/* Line 1455 of yacc.c */ +#line 75 "stella.y" { if(DEBUG_EXP) fprintf(stderr, " &"); (yyval.exp) = new BinAndExpression((yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp)); lastExp = (yyval.exp); } break; case 9: -#line 74 "stella.y" + +/* Line 1455 of yacc.c */ +#line 76 "stella.y" { if(DEBUG_EXP) fprintf(stderr, " |"); (yyval.exp) = new BinOrExpression((yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp)); lastExp = (yyval.exp); } break; case 10: -#line 75 "stella.y" + +/* Line 1455 of yacc.c */ +#line 77 "stella.y" { if(DEBUG_EXP) fprintf(stderr, " ^"); (yyval.exp) = new BinXorExpression((yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp)); lastExp = (yyval.exp); } break; case 11: -#line 76 "stella.y" + +/* Line 1455 of yacc.c */ +#line 78 "stella.y" { if(DEBUG_EXP) fprintf(stderr, " <"); (yyval.exp) = new LessExpression((yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp)); lastExp = (yyval.exp); } break; case 12: -#line 77 "stella.y" + +/* Line 1455 of yacc.c */ +#line 79 "stella.y" { if(DEBUG_EXP) fprintf(stderr, " >"); (yyval.exp) = new GreaterExpression((yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp)); lastExp = (yyval.exp); } break; case 13: -#line 78 "stella.y" + +/* Line 1455 of yacc.c */ +#line 80 "stella.y" { if(DEBUG_EXP) fprintf(stderr, " >="); (yyval.exp) = new GreaterEqualsExpression((yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp)); lastExp = (yyval.exp); } break; case 14: -#line 79 "stella.y" + +/* Line 1455 of yacc.c */ +#line 81 "stella.y" { if(DEBUG_EXP) fprintf(stderr, " <="); (yyval.exp) = new LessEqualsExpression((yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp)); lastExp = (yyval.exp); } break; case 15: -#line 80 "stella.y" + +/* Line 1455 of yacc.c */ +#line 82 "stella.y" { if(DEBUG_EXP) fprintf(stderr, " !="); (yyval.exp) = new NotEqualsExpression((yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp)); lastExp = (yyval.exp); } break; case 16: -#line 81 "stella.y" + +/* Line 1455 of yacc.c */ +#line 83 "stella.y" { if(DEBUG_EXP) fprintf(stderr, " =="); (yyval.exp) = new EqualsExpression((yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp)); lastExp = (yyval.exp); } break; case 17: -#line 82 "stella.y" + +/* Line 1455 of yacc.c */ +#line 84 "stella.y" { if(DEBUG_EXP) fprintf(stderr, " >>"); (yyval.exp) = new ShiftRightExpression((yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp)); lastExp = (yyval.exp); } break; case 18: -#line 83 "stella.y" + +/* Line 1455 of yacc.c */ +#line 85 "stella.y" { if(DEBUG_EXP) fprintf(stderr, " <<"); (yyval.exp) = new ShiftLeftExpression((yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp)); lastExp = (yyval.exp); } break; case 19: -#line 84 "stella.y" + +/* Line 1455 of yacc.c */ +#line 86 "stella.y" { if(DEBUG_EXP) fprintf(stderr, " ||"); (yyval.exp) = new LogOrExpression((yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp)); lastExp = (yyval.exp); } break; case 20: -#line 85 "stella.y" + +/* Line 1455 of yacc.c */ +#line 87 "stella.y" { if(DEBUG_EXP) fprintf(stderr, " &&"); (yyval.exp) = new LogAndExpression((yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp)); lastExp = (yyval.exp); } break; case 21: -#line 86 "stella.y" + +/* Line 1455 of yacc.c */ +#line 88 "stella.y" { if(DEBUG_EXP) fprintf(stderr, " U-"); (yyval.exp) = new UnaryMinusExpression((yyvsp[(2) - (2)].exp)); lastExp = (yyval.exp); } break; case 22: -#line 87 "stella.y" + +/* Line 1455 of yacc.c */ +#line 89 "stella.y" { if(DEBUG_EXP) fprintf(stderr, " ~"); (yyval.exp) = new BinNotExpression((yyvsp[(2) - (2)].exp)); lastExp = (yyval.exp); } break; case 23: -#line 88 "stella.y" + +/* Line 1455 of yacc.c */ +#line 90 "stella.y" { if(DEBUG_EXP) fprintf(stderr, " !"); (yyval.exp) = new LogNotExpression((yyvsp[(2) - (2)].exp)); lastExp = (yyval.exp); } break; case 24: -#line 89 "stella.y" + +/* Line 1455 of yacc.c */ +#line 91 "stella.y" { if(DEBUG_EXP) fprintf(stderr, " U*"); (yyval.exp) = new ByteDerefExpression((yyvsp[(2) - (2)].exp)); lastExp = (yyval.exp); } break; case 25: -#line 90 "stella.y" + +/* Line 1455 of yacc.c */ +#line 92 "stella.y" { if(DEBUG_EXP) fprintf(stderr, " U@"); (yyval.exp) = new WordDerefExpression((yyvsp[(2) - (2)].exp)); lastExp = (yyval.exp); } break; case 26: -#line 91 "stella.y" + +/* Line 1455 of yacc.c */ +#line 93 "stella.y" { if(DEBUG_EXP) fprintf(stderr, " U<"); (yyval.exp) = new LoByteExpression((yyvsp[(2) - (2)].exp)); lastExp = (yyval.exp); } break; case 27: -#line 92 "stella.y" + +/* Line 1455 of yacc.c */ +#line 94 "stella.y" { if(DEBUG_EXP) fprintf(stderr, " U>"); (yyval.exp) = new HiByteExpression((yyvsp[(2) - (2)].exp)); lastExp = (yyval.exp); } break; case 28: -#line 93 "stella.y" + +/* Line 1455 of yacc.c */ +#line 95 "stella.y" { if(DEBUG_EXP) fprintf(stderr, " ()"); (yyval.exp) = (yyvsp[(2) - (3)].exp); lastExp = (yyval.exp); } break; case 29: -#line 94 "stella.y" + +/* Line 1455 of yacc.c */ +#line 96 "stella.y" { if(DEBUG_EXP) fprintf(stderr, " []"); (yyval.exp) = new ByteDerefOffsetExpression((yyvsp[(1) - (4)].exp), (yyvsp[(3) - (4)].exp)); lastExp = (yyval.exp); } break; case 30: -#line 95 "stella.y" + +/* Line 1455 of yacc.c */ +#line 97 "stella.y" { if(DEBUG_EXP) fprintf(stderr, " %d", (yyvsp[(1) - (1)].val)); (yyval.exp) = new ConstExpression((yyvsp[(1) - (1)].val)); lastExp = (yyval.exp); } break; case 31: -#line 96 "stella.y" + +/* Line 1455 of yacc.c */ +#line 98 "stella.y" { if(DEBUG_EXP) fprintf(stderr, " %s", (yyvsp[(1) - (1)].equate)); (yyval.exp) = new EquateExpression((yyvsp[(1) - (1)].equate)); lastExp = (yyval.exp); } break; case 32: -#line 97 "stella.y" + +/* Line 1455 of yacc.c */ +#line 99 "stella.y" { if(DEBUG_EXP) fprintf(stderr, " (CpuMethod)"); (yyval.exp) = new CpuMethodExpression((yyvsp[(1) - (1)].cpuMethod)); lastExp = (yyval.exp); } break; case 33: -#line 98 "stella.y" - { if(DEBUG_EXP) fprintf(stderr, " (TiaMethod)"); (yyval.exp) = new TiaMethodExpression((yyvsp[(1) - (1)].tiaMethod)); lastExp = (yyval.exp); } + +/* Line 1455 of yacc.c */ +#line 100 "stella.y" + { if(DEBUG_EXP) fprintf(stderr, " (RamMethod)"); (yyval.exp) = new RamMethodExpression((yyvsp[(1) - (1)].ramMethod)); lastExp = (yyval.exp); } break; case 34: -#line 99 "stella.y" - { if(DEBUG_EXP) fprintf(stderr, " (function)"); (yyval.exp) = new FunctionExpression((yyvsp[(1) - (1)].function)); lastExp = (yyval.exp); } + +/* Line 1455 of yacc.c */ +#line 101 "stella.y" + { if(DEBUG_EXP) fprintf(stderr, " (TiaMethod)"); (yyval.exp) = new TiaMethodExpression((yyvsp[(1) - (1)].tiaMethod)); lastExp = (yyval.exp); } break; case 35: -#line 100 "stella.y" + +/* Line 1455 of yacc.c */ +#line 102 "stella.y" + { if(DEBUG_EXP) fprintf(stderr, " (function)"); (yyval.exp) = new FunctionExpression((yyvsp[(1) - (1)].function)); lastExp = (yyval.exp); } + break; + + case 36: + +/* Line 1455 of yacc.c */ +#line 103 "stella.y" { if(DEBUG_EXP) fprintf(stderr, " ERR"); yyerror((char*)"Invalid label or constant"); return 1; } break; -/* Line 1267 of yacc.c. */ -#line 1626 "y.tab.c" + +/* Line 1455 of yacc.c */ +#line 1718 "y.tab.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -1633,7 +1725,6 @@ yyreduce: *++yyvsp = yyval; - /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ @@ -1698,7 +1789,7 @@ yyerrlab: if (yyerrstatus == 3) { - /* If just tried and failed to reuse look-ahead token after an + /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) @@ -1715,7 +1806,7 @@ yyerrlab: } } - /* Else will try to reuse look-ahead token after shifting the error + /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; @@ -1772,9 +1863,6 @@ yyerrlab1: YY_STACK_PRINT (yyss, yyssp); } - if (yyn == YYFINAL) - YYACCEPT; - *++yyvsp = yylval; @@ -1799,7 +1887,7 @@ yyabortlab: yyresult = 1; goto yyreturn; -#ifndef yyoverflow +#if !defined(yyoverflow) || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ @@ -1810,7 +1898,7 @@ yyexhaustedlab: #endif yyreturn: - if (yychar != YYEOF && yychar != YYEMPTY) + if (yychar != YYEMPTY) yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval); /* Do not reclaim the symbols of the rule which action triggered @@ -1836,6 +1924,8 @@ yyreturn: } -#line 102 "stella.y" + +/* Line 1675 of yacc.c */ +#line 105 "stella.y" diff --git a/src/yacc/y.tab.h b/src/yacc/y.tab.h index 34b9cc473..65b1a8c43 100644 --- a/src/yacc/y.tab.h +++ b/src/yacc/y.tab.h @@ -1,24 +1,23 @@ -/* A Bison parser, made by GNU Bison 2.3. */ + +/* A Bison parser, made by GNU Bison 2.4.1. */ /* Skeleton interface for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ + along with this program. If not, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -29,10 +28,11 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ + /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE @@ -43,19 +43,20 @@ ERR = 259, EQUATE = 260, CPU_METHOD = 261, - TIA_METHOD = 262, - FUNCTION = 263, - LOG_OR = 264, - LOG_AND = 265, - LOG_NOT = 266, - SHL = 267, - SHR = 268, - EQ = 269, - NE = 270, - LTE = 271, - GTE = 272, - DEREF = 273, - UMINUS = 274 + RAM_METHOD = 262, + TIA_METHOD = 263, + FUNCTION = 264, + LOG_OR = 265, + LOG_AND = 266, + LOG_NOT = 267, + SHL = 268, + SHR = 269, + EQ = 270, + NE = 271, + LTE = 272, + GTE = 273, + DEREF = 274, + UMINUS = 275 }; #endif /* Tokens. */ @@ -63,41 +64,49 @@ #define ERR 259 #define EQUATE 260 #define CPU_METHOD 261 -#define TIA_METHOD 262 -#define FUNCTION 263 -#define LOG_OR 264 -#define LOG_AND 265 -#define LOG_NOT 266 -#define SHL 267 -#define SHR 268 -#define EQ 269 -#define NE 270 -#define LTE 271 -#define GTE 272 -#define DEREF 273 -#define UMINUS 274 +#define RAM_METHOD 262 +#define TIA_METHOD 263 +#define FUNCTION 264 +#define LOG_OR 265 +#define LOG_AND 266 +#define LOG_NOT 267 +#define SHL 268 +#define SHR 269 +#define EQ 270 +#define NE 271 +#define LTE 272 +#define GTE 273 +#define DEREF 274 +#define UMINUS 275 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 29 "stella.y" { + +/* Line 1676 of yacc.c */ +#line 29 "stella.y" + int val; char *equate; CPUDEBUG_INT_METHOD cpuMethod; + RAMDEBUG_INT_METHOD ramMethod; TIADEBUG_INT_METHOD tiaMethod; Expression *exp; char *function; -} -/* Line 1489 of yacc.c. */ -#line 96 "y.tab.h" - YYSTYPE; + + + +/* Line 1676 of yacc.c */ +#line 104 "y.tab.h" +} YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 #endif extern YYSTYPE yylval; +