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;
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;
/* */
/* */
/* (C) 1999-2003 Ullrich von Bassewitz */
-/* Römerstrasse 52 */
+/* Römerstraße 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
*/
{
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:
/* 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;
/* 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;
/* 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;