]> git.sur5r.net Git - cc65/commitdiff
Cosmetic changes
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Wed, 12 Nov 2003 16:40:14 +0000 (16:40 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Wed, 12 Nov 2003 16:40:14 +0000 (16:40 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@2650 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/ld65/expr.c
src/ld65/o65.c

index 6c13c86d3638b4b5343b2385302e5a5fce18dbab..c5967732d487cc7770a5f28b979ffc3ec17cd558 100644 (file)
@@ -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;
index c831b8595957f92ce667177c5929cfaf7b26c3eb..efc7856bc151bf6bada953246244513df99f55a4 100644 (file)
@@ -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;