From 7c5a400e01d78f9e183f09f8c6c3bf261e65e10a Mon Sep 17 00:00:00 2001 From: cuz Date: Wed, 12 Nov 2003 16:40:14 +0000 Subject: [PATCH] Cosmetic changes git-svn-id: svn://svn.cc65.org/cc65/trunk@2650 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/ld65/expr.c | 41 ++++++++++++++++++++++++++--------------- src/ld65/o65.c | 30 +++++------------------------- 2 files changed, 31 insertions(+), 40 deletions(-) diff --git a/src/ld65/expr.c b/src/ld65/expr.c index 6c13c86d3..c5967732d 100644 --- a/src/ld65/expr.c +++ b/src/ld65/expr.c @@ -335,12 +335,33 @@ long GetExprVal (ExprNode* Expr) case EXPR_GE: return (GetExprVal (Expr->Left) >= GetExprVal (Expr->Right)); + case EXPR_BOOLAND: + return GetExprVal (Expr->Left) && GetExprVal (Expr->Right); + + case EXPR_BOOLOR: + return GetExprVal (Expr->Left) || GetExprVal (Expr->Right); + + case EXPR_BOOLXOR: + return (GetExprVal (Expr->Left) != 0) ^ (GetExprVal (Expr->Right) != 0); + case EXPR_UNARY_MINUS: return -GetExprVal (Expr->Left); case EXPR_NOT: return ~GetExprVal (Expr->Left); + case EXPR_SWAP: + Left = GetExprVal (Expr->Left); + return ((Left >> 8) & 0x00FF) | ((Left << 8) & 0xFF00); + + case EXPR_BOOLNOT: + return !GetExprVal (Expr->Left); + + case EXPR_FORCEWORD: + case EXPR_FORCEFAR: + /* These two have no effect on the expression result */ + return GetExprVal (Expr->Left); + case EXPR_BYTE0: return GetExprVal (Expr->Left) & 0xFF; @@ -353,23 +374,13 @@ long GetExprVal (ExprNode* Expr) case EXPR_BYTE3: return (GetExprVal (Expr->Left) >> 24) & 0xFF; - case EXPR_SWAP: - Left = GetExprVal (Expr->Left); - return ((Left >> 8) & 0x00FF) | ((Left << 8) & 0xFF00); - - case EXPR_BOOLAND: - return GetExprVal (Expr->Left) && GetExprVal (Expr->Right); + case EXPR_WORD0: + return GetExprVal (Expr->Left) & 0xFFFF; - case EXPR_BOOLOR: - return GetExprVal (Expr->Left) || GetExprVal (Expr->Right); - - case EXPR_BOOLXOR: - return (GetExprVal (Expr->Left) != 0) ^ (GetExprVal (Expr->Right) != 0); - - case EXPR_BOOLNOT: - return !GetExprVal (Expr->Left); + case EXPR_WORD1: + return (GetExprVal (Expr->Left) >> 16) & 0xFFFF; - default: + default: Internal ("Unknown expression Op type: %u", Expr->Op); /* NOTREACHED */ return 0; diff --git a/src/ld65/o65.c b/src/ld65/o65.c index c831b8595..efc7856bc 100644 --- a/src/ld65/o65.c +++ b/src/ld65/o65.c @@ -7,7 +7,7 @@ /* */ /* */ /* (C) 1999-2003 Ullrich von Bassewitz */ -/* Römerstrasse 52 */ +/* Römerstraße 52 */ /* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ /* */ @@ -350,16 +350,11 @@ static void O65ParseExpr (ExprNode* Expr, ExprDesc* D, int Sign) */ { Export* E; - unsigned long Val; switch (Expr->Op) { case EXPR_LITERAL: - if (Sign < 0) { - D->Val -= Expr->V.Val; - } else { - D->Val += Expr->V.Val; - } + D->Val += (Sign * Expr->V.Val); break; case EXPR_SYMBOL: @@ -397,12 +392,7 @@ static void O65ParseExpr (ExprNode* Expr, ExprDesc* D, int Sign) /* Remember the segment reference */ D->SecRef = GetExprSection (Expr); /* Add the offset of the section to the constant value */ - Val = D->SecRef->Offs + D->SecRef->Seg->PC; - if (Sign < 0) { - D->Val -= Val; - } else { - D->Val += Val; - } + D->Val += Sign * (D->SecRef->Offs + D->SecRef->Seg->PC); } break; @@ -414,12 +404,7 @@ static void O65ParseExpr (ExprNode* Expr, ExprDesc* D, int Sign) /* Remember the segment reference */ D->SegRef = Expr->V.Seg; /* Add the offset of the segment to the constant value */ - Val = D->SegRef->PC; - if (Sign < 0) { - D->Val -= Val; - } else { - D->Val += Val; - } + D->Val += (Sign * D->SegRef->PC); } break; @@ -433,12 +418,7 @@ static void O65ParseExpr (ExprNode* Expr, ExprDesc* D, int Sign) /* Add the start address of the memory area to the constant * value */ - Val = D->MemRef->Start; - if (Sign < 0) { - D->Val -= Val; - } else { - D->Val += Val; - } + D->Val += (Sign * D->MemRef->Start); } break; -- 2.39.5