Added initial Yacc parser. This will replace DebuggerParser::decipher_args()

and become the "mini-language" for conditional breaks/traps.

The current lexer/parser combo benchmarks at 1/2 million parses/sec
on my Athlon 2100. By comparison, Pitfall runs approx. 360,000
instructions/sec. We need to be able to check for a conditional break
once per instruction, so on my box, I'll probably be able to run the
emulator at full speed with one breakcond set, using all the CPU.

Am still working on a way to speed things up: there's no reason we
should have to fully lex and parse an expression every time we want to
evaluate it.

For now, the only place the new parser hooks into Stella is with an
undocumented "expr" command. Try "expr 2+2" at the prompt.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@585 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
urchlay 2005-07-01 04:22:37 +00:00
parent 18b37a5ed6
commit 073ae410ad
7 changed files with 33 additions and 12 deletions

View File

@ -13,7 +13,7 @@
## See the file "license" for information on usage and redistribution of
## this file, and for a DISCLAIMER OF ALL WARRANTIES.
##
## $Id: Makefile,v 1.4 2005-06-29 13:11:03 stephena Exp $
## $Id: Makefile,v 1.5 2005-07-01 04:22:26 urchlay Exp $
##
## Based on code from ScummVM - Scumm Interpreter
## Copyright (C) 2002-2004 The ScummVM project
@ -90,7 +90,8 @@ MODULES += \
src/emucore \
src/emucore/m6502 \
src/gui \
src/common
src/common \
src/yacc
######################################################################
# The build rules follow - normally you should have no need to

3
stella/configure vendored
View File

@ -646,6 +646,7 @@ CORE="$SRC/emucore"
COMMON="$SRC/common"
GUI="$SRC/gui"
DBG="$SRC/debugger"
YACC="$SRC/yacc"
INCLUDES="-I$CORE -I$CORE/m6502/src -I$CORE/m6502/src/bspf/src -I$COMMON -I$GUI"
@ -688,7 +689,7 @@ fi
if test "$_build_developer" = yes ; then
DEFINES="$DEFINES -DDEVELOPER_SUPPORT"
MODULES="$MODULES $DBG"
INCLUDES="$INCLUDES -I$DBG"
INCLUDES="$INCLUDES -I$DBG -I$YACC"
fi
if test "$_build_snapshot" = yes ; then

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Debugger.cxx,v 1.42 2005-06-29 13:11:03 stephena Exp $
// $Id: Debugger.cxx,v 1.43 2005-07-01 04:22:27 urchlay Exp $
//============================================================================
#include "bspf.hxx"
@ -213,6 +213,9 @@ const string Debugger::state()
result += " Frame:";
sprintf(buf, "%d", myTIAdebug->frameCount());
result += buf;
result += " 6502Ins:";
sprintf(buf, "%d", mySystem->m6502().totalInstructionCount());
result += buf;
result += "\n ";
result += disassemble(myDebugger->pc(), 1);

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: DebuggerParser.cxx,v 1.42 2005-06-29 00:31:48 urchlay Exp $
// $Id: DebuggerParser.cxx,v 1.43 2005-07-01 04:22:27 urchlay Exp $
//============================================================================
#include "bspf.hxx"
@ -21,9 +21,8 @@
#include "DebuggerParser.hxx"
#include "D6502.hxx"
#include "DebuggerParser.hxx"
#include "YaccParser.hxx"
// TODO: finish this, replace run() and getArgs() with versions
// that use this table.
Command DebuggerParser::commands[] = {
{
"a",
@ -854,6 +853,16 @@ bool DebuggerParser::validateArgs(int cmd) {
string DebuggerParser::run(const string& command) {
int i=0;
// special case: parser testing
if(strncmp(command.c_str(), "expr ", 5) == 0) {
commandResult = "parser test: status==";
int status = YaccParser::parse(command.c_str() + 5);
commandResult += debugger->valueToString(status);
commandResult += ", result==";
commandResult += debugger->valueToString(YaccParser::getResult());
return commandResult;
}
getArgs(command);
commandResult = "";

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: M6502.cxx,v 1.7 2005-06-21 05:00:45 urchlay Exp $
// $Id: M6502.cxx,v 1.8 2005-07-01 04:22:37 urchlay Exp $
//============================================================================
#include "M6502.hxx"
@ -43,6 +43,8 @@ M6502::M6502(uInt32 systemCyclesPerProcessorCycle)
myInstructionSystemCycleTable[t] = ourInstructionProcessorCycleTable[t] *
mySystemCyclesPerProcessorCycle;
}
myTotalInstructionCount = 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: M6502.hxx,v 1.6 2005-06-21 05:00:45 urchlay Exp $
// $Id: M6502.hxx,v 1.7 2005-07-01 04:22:37 urchlay Exp $
//============================================================================
#ifndef M6502_HXX
@ -35,7 +35,7 @@ class Debugger;
has a 64K addressing space.
@author Bradford W. Mott
@version $Id: M6502.hxx,v 1.6 2005-06-21 05:00:45 urchlay Exp $
@version $Id: M6502.hxx,v 1.7 2005-07-01 04:22:37 urchlay Exp $
*/
class M6502
{
@ -178,6 +178,7 @@ class M6502
public:
void setBreakPoints(PackedBitArray *bp);
void setTraps(PackedBitArray *read, PackedBitArray *write);
int totalInstructionCount() { return myTotalInstructionCount; }
protected:
/**
@ -262,5 +263,7 @@ class M6502
// did we just now hit a trap?
bool justHitTrap;
int myTotalInstructionCount;
};
#endif

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: M6502Hi.cxx,v 1.8 2005-06-28 12:20:06 urchlay Exp $
// $Id: M6502Hi.cxx,v 1.9 2005-07-01 04:22:37 urchlay Exp $
//============================================================================
#include "M6502Hi.hxx"
@ -89,8 +89,8 @@ bool M6502High::execute(uInt32 number)
if(justHitTrap)
{
justHitTrap = false;
if(myDebugger->start()) {
justHitTrap = false;
return true;
}
}
@ -127,6 +127,8 @@ bool M6502High::execute(uInt32 number)
myExecutionStatus |= FatalErrorBit;
}
myTotalInstructionCount++;
#ifdef DEBUG
debugStream << hex << setw(4) << operandAddress << " ";
debugStream << setw(4) << ourInstructionMnemonicTable[IR];