From 1c7cb335d648f6da0c779d5c902f251c5122dd80 Mon Sep 17 00:00:00 2001 From: urchlay Date: Fri, 15 Jul 2005 01:40:34 +0000 Subject: [PATCH] Added < and > (low byte and hi byte) operators. These are really just a convenience: foo is equivalent to foo/$100, assuming foo is a 16-bit quantity. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@650 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/debugger/HiByteExpression.cxx | 27 ++++++++++++++++++ stella/src/debugger/HiByteExpression.hxx | 36 ++++++++++++++++++++++++ stella/src/debugger/LoByteExpression.cxx | 27 ++++++++++++++++++ stella/src/debugger/LoByteExpression.hxx | 36 ++++++++++++++++++++++++ stella/src/debugger/module.mk | 2 ++ stella/src/yacc/YaccParser.cxx | 4 ++- stella/src/yacc/stella.y | 4 +-- stella/src/yacc/y.tab.c | 4 +-- 8 files changed, 135 insertions(+), 5 deletions(-) create mode 100644 stella/src/debugger/HiByteExpression.cxx create mode 100644 stella/src/debugger/HiByteExpression.hxx create mode 100644 stella/src/debugger/LoByteExpression.cxx create mode 100644 stella/src/debugger/LoByteExpression.hxx diff --git a/stella/src/debugger/HiByteExpression.cxx b/stella/src/debugger/HiByteExpression.cxx new file mode 100644 index 000000000..2061c0447 --- /dev/null +++ b/stella/src/debugger/HiByteExpression.cxx @@ -0,0 +1,27 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: HiByteExpression.cxx,v 1.1 2005-07-15 01:40:34 urchlay Exp $ +//============================================================================ + +#include "Expression.hxx" +#include "HiByteExpression.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +HiByteExpression::HiByteExpression(Expression *left) + : Expression(left, 0) +{ +} + diff --git a/stella/src/debugger/HiByteExpression.hxx b/stella/src/debugger/HiByteExpression.hxx new file mode 100644 index 000000000..53bf7afac --- /dev/null +++ b/stella/src/debugger/HiByteExpression.hxx @@ -0,0 +1,36 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: HiByteExpression.hxx,v 1.1 2005-07-15 01:40:34 urchlay Exp $ +//============================================================================ + +#ifndef HIBYTE_EXPRESSION_HXX +#define HIBYTE_EXPRESSION_HXX + +#include "Expression.hxx" + +/** + @author B. Watson + @version $Id: HiByteExpression.hxx,v 1.1 2005-07-15 01:40:34 urchlay Exp $ +*/ +class HiByteExpression : public Expression +{ + public: + HiByteExpression(Expression *left); + int evaluate() { return 0xff & (myLHS->evaluate() >> 8); } +}; + +#endif + diff --git a/stella/src/debugger/LoByteExpression.cxx b/stella/src/debugger/LoByteExpression.cxx new file mode 100644 index 000000000..5b14cd497 --- /dev/null +++ b/stella/src/debugger/LoByteExpression.cxx @@ -0,0 +1,27 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: LoByteExpression.cxx,v 1.1 2005-07-15 01:40:34 urchlay Exp $ +//============================================================================ + +#include "Expression.hxx" +#include "LoByteExpression.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +LoByteExpression::LoByteExpression(Expression *left) + : Expression(left, 0) +{ +} + diff --git a/stella/src/debugger/LoByteExpression.hxx b/stella/src/debugger/LoByteExpression.hxx new file mode 100644 index 000000000..458d35e91 --- /dev/null +++ b/stella/src/debugger/LoByteExpression.hxx @@ -0,0 +1,36 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: LoByteExpression.hxx,v 1.1 2005-07-15 01:40:34 urchlay Exp $ +//============================================================================ + +#ifndef LOBYTE_EXPRESSION_HXX +#define LOBYTE_EXPRESSION_HXX + +#include "Expression.hxx" + +/** + @author B. Watson + @version $Id: LoByteExpression.hxx,v 1.1 2005-07-15 01:40:34 urchlay Exp $ +*/ +class LoByteExpression : public Expression +{ + public: + LoByteExpression(Expression *left); + int evaluate() { return 0xff & myLHS->evaluate(); } +}; + +#endif + diff --git a/stella/src/debugger/module.mk b/stella/src/debugger/module.mk index e03a58133..0177b1827 100644 --- a/stella/src/debugger/module.mk +++ b/stella/src/debugger/module.mk @@ -9,6 +9,8 @@ MODULE_OBJS := \ src/debugger/WordDerefExpression.o \ src/debugger/ConstExpression.o \ src/debugger/EquateExpression.o \ + src/debugger/LoByteExpression.o \ + src/debugger/HiByteExpression.o \ src/debugger/NotEqualsExpression.o \ src/debugger/EqualsExpression.o \ src/debugger/PlusExpression.o \ diff --git a/stella/src/yacc/YaccParser.cxx b/stella/src/yacc/YaccParser.cxx index 0419bd6df..eaa905051 100644 --- a/stella/src/yacc/YaccParser.cxx +++ b/stella/src/yacc/YaccParser.cxx @@ -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: YaccParser.cxx,v 1.6 2005-07-15 01:20:11 urchlay Exp $ +// $Id: YaccParser.cxx,v 1.7 2005-07-15 01:40:34 urchlay Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -40,6 +40,8 @@ #include "Expression.hxx" #include "GreaterEqualsExpression.hxx" #include "GreaterExpression.hxx" +#include "HiByteExpression.hxx" +#include "LoByteExpression.hxx" #include "LessEqualsExpression.hxx" #include "LessExpression.hxx" #include "LogAndExpression.hxx" diff --git a/stella/src/yacc/stella.y b/stella/src/yacc/stella.y index 7b78139b2..d13914d22 100644 --- a/stella/src/yacc/stella.y +++ b/stella/src/yacc/stella.y @@ -67,8 +67,8 @@ expression: expression '+' expression { fprintf(stderr, " +"); $$ = new PlusExpr | '!' expression %prec UMINUS { fprintf(stderr, " !"); $$ = new LogNotExpression($2); } | '*' expression %prec DEREF { fprintf(stderr, " U*"); $$ = new ByteDerefExpression($2); } | '@' expression %prec DEREF { fprintf(stderr, " U@"); $$ = new WordDerefExpression($2); } - | '<' expression { fprintf(stderr, " U<"); /* $$ = new LoByteExpression($2); */ } - | '>' expression { fprintf(stderr, " U>"); /* $$ = new HiByteExpression($2); */ } + | '<' expression { fprintf(stderr, " U<"); $$ = new LoByteExpression($2); } + | '>' expression { fprintf(stderr, " U>"); $$ = new HiByteExpression($2); } | '(' expression ')' { fprintf(stderr, " ()"); $$ = $2; } | NUMBER { fprintf(stderr, " %d", $1); $$ = new ConstExpression($1); } | EQUATE { fprintf(stderr, " %s", $1); $$ = new EquateExpression($1); } diff --git a/stella/src/yacc/y.tab.c b/stella/src/yacc/y.tab.c index f8c330171..3879131b0 100644 --- a/stella/src/yacc/y.tab.c +++ b/stella/src/yacc/y.tab.c @@ -1033,11 +1033,11 @@ case 24: break; case 25: #line 70 "stella.y" -{ fprintf(stderr, " U<"); /* $$ = new LoByteExpression($2); */ } +{ fprintf(stderr, " U<"); yyval.exp = new LoByteExpression(yyvsp[0].exp); } break; case 26: #line 71 "stella.y" -{ fprintf(stderr, " U>"); /* $$ = new HiByteExpression($2); */ } +{ fprintf(stderr, " U>"); yyval.exp = new HiByteExpression(yyvsp[0].exp); } break; case 27: #line 72 "stella.y"