+static ExprNode* LoByte (ExprNode* Operand)
+/* Return the low byte of the given expression */
+{
+ ExprNode* Expr;
+ long Val;
+
+ /* Special handling for const expressions */
+ if (IsEasyConst (Operand, &Val)) {
+ FreeExpr (Operand);
+ Expr = GenLiteralExpr (Val & 0xFF);
+ } else {
+ /* Extract byte #0 */
+ Expr = NewExprNode (EXPR_BYTE0);
+ Expr->Left = Operand;
+ }
+ return Expr;
+}
+
+
+
+static ExprNode* HiByte (ExprNode* Operand)
+/* Return the high byte of the given expression */
+{
+ ExprNode* Expr;
+ long Val;
+
+ /* Special handling for const expressions */
+ if (IsEasyConst (Operand, &Val)) {
+ FreeExpr (Operand);
+ Expr = GenLiteralExpr ((Val >> 8) & 0xFF);
+ } else {
+ /* Extract byte #1 */
+ Expr = NewExprNode (EXPR_BYTE1);
+ Expr->Left = Operand;
+ }
+ return Expr;
+}
+
+
+
+static ExprNode* BankByte (ExprNode* Operand)
+/* Return the bank byte of the given expression */
+{
+ ExprNode* Expr;
+ long Val;
+
+ /* Special handling for const expressions */
+ if (IsEasyConst (Operand, &Val)) {
+ FreeExpr (Operand);
+ Expr = GenLiteralExpr ((Val >> 16) & 0xFF);
+ } else {
+ /* Extract byte #2 */
+ Expr = NewExprNode (EXPR_BYTE2);
+ Expr->Left = Operand;
+ }
+ return Expr;
+}
+
+
+
+static ExprNode* LoWord (ExprNode* Operand)
+/* Return the low word of the given expression */
+{
+ ExprNode* Expr;
+ long Val;
+
+ /* Special handling for const expressions */
+ if (IsEasyConst (Operand, &Val)) {
+ FreeExpr (Operand);
+ Expr = GenLiteralExpr (Val & 0xFFFF);
+ } else {
+ /* Extract word #0 */
+ Expr = NewExprNode (EXPR_WORD0);
+ Expr->Left = Operand;
+ }
+ return Expr;
+}
+
+
+
+static ExprNode* HiWord (ExprNode* Operand)
+/* Return the high word of the given expression */
+{
+ ExprNode* Expr;
+ long Val;
+
+ /* Special handling for const expressions */
+ if (IsEasyConst (Operand, &Val)) {
+ FreeExpr (Operand);
+ Expr = GenLiteralExpr ((Val >> 16) & 0xFFFF);
+ } else {
+ /* Extract word #1 */
+ Expr = NewExprNode (EXPR_WORD1);
+ Expr->Left = Operand;
+ }
+ return Expr;
+}
+
+
+
static ExprNode* Symbol (SymEntry* S)
/* Reference a symbol and return an expression for it */
{
+static ExprNode* FuncBankByte (void)
+/* Handle the .BANKBYTE builtin function */
+{
+ return BankByte (Expression ());
+}
+
+
+
static ExprNode* FuncBlank (void)
/* Handle the .BLANK builtin function */
{
+static ExprNode* FuncHiByte (void)
+/* Handle the .HIBYTE builtin function */
+{
+ return HiByte (Expression ());
+}
+
+
+
+static ExprNode* FuncHiWord (void)
+/* Handle the .HIWORD builtin function */
+{
+ return HiWord (Expression ());
+}
+
+
+
+static ExprNode* FuncLoByte (void)
+/* Handle the .LOBYTE builtin function */
+{
+ return LoByte (Expression ());
+}
+
+
+
+static ExprNode* FuncLoWord (void)
+/* Handle the .LOWORD builtin function */
+{
+ return LoWord (Expression ());
+}
+
+
+
static ExprNode* DoMatch (enum TC EqualityLevel)
/* Handle the .MATCH and .XMATCH builtin functions */
{
case TOK_LT:
NextTok ();
- L = Factor ();
- if (IsEasyConst (L, &Val)) {
- FreeExpr (L);
- N = GenLiteralExpr (Val & 0xFF);
- } else {
- N = NewExprNode (EXPR_BYTE0);
- N->Left = L;
- }
+ N = LoByte (Factor ());
break;
case TOK_GT:
NextTok ();
- L = Factor ();
- if (IsEasyConst (L, &Val)) {
- FreeExpr (L);
- N = GenLiteralExpr ((Val >> 8) & 0xFF);
- } else {
- N = NewExprNode (EXPR_BYTE1);
- N->Left = L;
- }
+ N = HiByte (Factor ());
break;
case TOK_BANK:
NextTok ();
- L = Factor ();
- if (IsEasyConst (L, &Val)) {
- FreeExpr (L);
- N = GenLiteralExpr ((Val >> 16) & 0xFF);
- } else {
- N = NewExprNode (EXPR_BYTE2);
- N->Left = L;
- }
+ N = BankByte (Factor ());
break;
case TOK_LPAREN:
ConsumeRParen ();
break;
+ case TOK_BANKBYTE:
+ N = Function (FuncBankByte);
+ break;
+
case TOK_BLANK:
N = Function (FuncBlank);
break;
N = Function (FuncDefined);
break;
+ case TOK_HIBYTE:
+ N = Function (FuncHiByte);
+ break;
+
+ case TOK_HIWORD:
+ N = Function (FuncHiWord);
+ break;
+
+ case TOK_LOBYTE:
+ N = Function (FuncLoByte);
+ break;
+
+ case TOK_LOWORD:
+ N = Function (FuncLoWord);
+ break;
+
case TOK_MATCH:
N = Function (FuncMatch);
break;
{ ccNone, DoASCIIZ },
{ ccNone, DoAssert },
{ ccNone, DoAutoImport },
+ { ccNone, DoUnexpected }, /* .BANKBYTE */
{ ccNone, DoUnexpected }, /* .BLANK */
{ ccNone, DoBss },
{ ccNone, DoByte },
{ ccNone, DoUnexpected }, /* .FORCEWORD */
{ ccNone, DoGlobal },
{ ccNone, DoGlobalZP },
+ { ccNone, DoUnexpected }, /* .HIBYTE */
+ { ccNone, DoUnexpected }, /* .HIWORD */
{ ccNone, DoI16 },
{ ccNone, DoI8 },
{ ccKeepToken, DoConditionals }, /* .IF */
{ ccNone, DoLineCont },
{ ccNone, DoList },
{ ccNone, DoListBytes },
+ { ccNone, DoUnexpected }, /* .LOBYTE */
{ ccNone, DoUnexpected }, /* .LOCAL */
{ ccNone, DoLocalChar },
+ { ccNone, DoUnexpected }, /* .LOWORD */
{ ccNone, DoMacPack },
{ ccNone, DoMacro },
{ ccNone, DoUnexpected }, /* .MATCH */
{ ".ASCIIZ", TOK_ASCIIZ },
{ ".ASSERT", TOK_ASSERT },
{ ".AUTOIMPORT", TOK_AUTOIMPORT },
+ { ".BANKBYTE", TOK_BANKBYTE },
{ ".BITAND", TOK_AND },
{ ".BITNOT", TOK_NOT },
{ ".BITOR", TOK_OR },
{ ".FORCEWORD", TOK_FORCEWORD },
{ ".GLOBAL", TOK_GLOBAL },
{ ".GLOBALZP", TOK_GLOBALZP },
+ { ".HIBYTE", TOK_HIBYTE },
+ { ".HIWORD", TOK_HIWORD },
{ ".I16", TOK_I16 },
{ ".I8", TOK_I8 },
{ ".IF", TOK_IF },
{ ".LINECONT", TOK_LINECONT },
{ ".LIST", TOK_LIST },
{ ".LISTBYTES", TOK_LISTBYTES },
+ { ".LOBYTE", TOK_LOBYTE },
{ ".LOCAL", TOK_LOCAL },
{ ".LOCALCHAR", TOK_LOCALCHAR },
+ { ".LOWORD", TOK_LOWORD },
{ ".MAC", TOK_MACRO },
{ ".MACPACK", TOK_MACPACK },
{ ".MACRO", TOK_MACRO },
if (!IgnoreCase) {
UpcaseSVal ();
}
-
+
/* Do a linear search (a binary search is not worth the effort) */
for (I = 0; I < Count; ++I) {
if (strcmp (SVal, Keys [I]) == 0) {