Added < and > (low byte and hi byte) operators. These are really just

a convenience: <foo is equivalent to foo&$ff (or foo%$100), and >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
This commit is contained in:
urchlay 2005-07-15 01:40:34 +00:00
parent 460c7b5254
commit 1c7cb335d6
8 changed files with 135 additions and 5 deletions

View File

@ -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)
{
}

View File

@ -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

View File

@ -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)
{
}

View File

@ -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

View File

@ -9,6 +9,8 @@ MODULE_OBJS := \
src/debugger/WordDerefExpression.o \ src/debugger/WordDerefExpression.o \
src/debugger/ConstExpression.o \ src/debugger/ConstExpression.o \
src/debugger/EquateExpression.o \ src/debugger/EquateExpression.o \
src/debugger/LoByteExpression.o \
src/debugger/HiByteExpression.o \
src/debugger/NotEqualsExpression.o \ src/debugger/NotEqualsExpression.o \
src/debugger/EqualsExpression.o \ src/debugger/EqualsExpression.o \
src/debugger/PlusExpression.o \ src/debugger/PlusExpression.o \

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // 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 // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -40,6 +40,8 @@
#include "Expression.hxx" #include "Expression.hxx"
#include "GreaterEqualsExpression.hxx" #include "GreaterEqualsExpression.hxx"
#include "GreaterExpression.hxx" #include "GreaterExpression.hxx"
#include "HiByteExpression.hxx"
#include "LoByteExpression.hxx"
#include "LessEqualsExpression.hxx" #include "LessEqualsExpression.hxx"
#include "LessExpression.hxx" #include "LessExpression.hxx"
#include "LogAndExpression.hxx" #include "LogAndExpression.hxx"

View File

@ -67,8 +67,8 @@ expression: expression '+' expression { fprintf(stderr, " +"); $$ = new PlusExpr
| '!' expression %prec UMINUS { fprintf(stderr, " !"); $$ = new LogNotExpression($2); } | '!' expression %prec UMINUS { fprintf(stderr, " !"); $$ = new LogNotExpression($2); }
| '*' expression %prec DEREF { fprintf(stderr, " U*"); $$ = new ByteDerefExpression($2); } | '*' expression %prec DEREF { fprintf(stderr, " U*"); $$ = new ByteDerefExpression($2); }
| '@' expression %prec DEREF { fprintf(stderr, " U@"); $$ = new WordDerefExpression($2); } | '@' expression %prec DEREF { fprintf(stderr, " U@"); $$ = new WordDerefExpression($2); }
| '<' expression { fprintf(stderr, " U<"); /* $$ = new LoByteExpression($2); */ } | '<' expression { fprintf(stderr, " U<"); $$ = new LoByteExpression($2); }
| '>' expression { fprintf(stderr, " U>"); /* $$ = new HiByteExpression($2); */ } | '>' expression { fprintf(stderr, " U>"); $$ = new HiByteExpression($2); }
| '(' expression ')' { fprintf(stderr, " ()"); $$ = $2; } | '(' expression ')' { fprintf(stderr, " ()"); $$ = $2; }
| NUMBER { fprintf(stderr, " %d", $1); $$ = new ConstExpression($1); } | NUMBER { fprintf(stderr, " %d", $1); $$ = new ConstExpression($1); }
| EQUATE { fprintf(stderr, " %s", $1); $$ = new EquateExpression($1); } | EQUATE { fprintf(stderr, " %s", $1); $$ = new EquateExpression($1); }

View File

@ -1033,11 +1033,11 @@ case 24:
break; break;
case 25: case 25:
#line 70 "stella.y" #line 70 "stella.y"
{ fprintf(stderr, " U<"); /* $$ = new LoByteExpression($2); */ } { fprintf(stderr, " U<"); yyval.exp = new LoByteExpression(yyvsp[0].exp); }
break; break;
case 26: case 26:
#line 71 "stella.y" #line 71 "stella.y"
{ fprintf(stderr, " U>"); /* $$ = new HiByteExpression($2); */ } { fprintf(stderr, " U>"); yyval.exp = new HiByteExpression(yyvsp[0].exp); }
break; break;
case 27: case 27:
#line 72 "stella.y" #line 72 "stella.y"