]> git.sur5r.net Git - cc65/commitdiff
Renamed several expression ops and added others.
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sat, 29 Jul 2000 15:53:33 +0000 (15:53 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sat, 29 Jul 2000 15:53:33 +0000 (15:53 +0000)
Placed the DumpExpr function into the common directory, since it is
used by the assembler and linker.

git-svn-id: svn://svn.cc65.org/cc65/trunk@225 b7a2c559-68d2-44c3-8de9-860c34a00d81

14 files changed:
src/ca65/expr.c
src/ca65/expr.h
src/ca65/objcode.c
src/ca65/pseudo.c
src/ca65/scanner.c
src/ca65/scanner.h
src/cc65/segname.c
src/common/exprdefs.c [new file with mode: 0644]
src/common/exprdefs.h
src/common/make/gcc.mak
src/common/make/watcom.mak
src/common/objdefs.h
src/ld65/expr.c
src/ld65/o65.c

index fc43cdcb8e0f89306fca6a80d88920f88576ad58..535bea07d8183dc515b256a4ac05007299410441 100644 (file)
 
 
 
-#include "../common/exprdefs.h"
-#include "../common/xmalloc.h"
+/* common */
+#include "exprdefs.h"
+#include "xmalloc.h"
 
+/* ca65 */
 #include "error.h"
 #include "global.h"
 #include "instr.h"
@@ -113,145 +115,6 @@ static void FreeExprNode (ExprNode* E)
 
 
 
-/*****************************************************************************/
-/*             Dump an expression tree on stdout for debugging              */
-/*****************************************************************************/
-
-
-
-static void InternalDumpExpr (ExprNode* Expr)
-/* Dump an expression in UPN */
-{
-    if (Expr == 0) {
-       return;
-    }
-    InternalDumpExpr (Expr->Left);
-    InternalDumpExpr (Expr->Right);
-
-    switch (Expr->Op) {
-
-       case EXPR_LITERAL:
-       case EXPR_ULABEL:
-           printf (" $%04lX", Expr->V.Val & 0xFFFF);
-           break;
-
-       case EXPR_SYMBOL:
-                   printf (" %s", GetSymName (Expr->V.Sym));
-           break;
-
-       case EXPR_SEGMENT:
-           printf (" SEG");
-           break;
-
-               case EXPR_PLUS:
-           printf (" +");
-           break;
-
-               case EXPR_MINUS:
-           printf (" -");
-           break;
-
-               case EXPR_MUL:
-           printf (" *");
-           break;
-
-               case EXPR_DIV:
-           printf (" /");
-           break;
-
-               case EXPR_MOD:
-           printf (" %%");
-           break;
-
-       case EXPR_OR:
-           printf (" OR");
-           break;
-
-       case EXPR_XOR:
-           printf (" XOR");
-           break;
-
-       case EXPR_AND:
-           printf (" AND");
-           break;
-
-       case EXPR_SHL:
-           printf (" SHL");
-           break;
-
-       case EXPR_SHR:
-           printf (" SHR");
-           break;
-
-               case EXPR_EQ:
-           printf (" =");
-           break;
-
-               case EXPR_NE:
-           printf ("<>");
-           break;
-
-               case EXPR_LT:
-           printf (" <");
-           break;
-
-               case EXPR_GT:
-           printf (" >");
-           break;
-
-               case EXPR_UNARY_MINUS:
-           printf (" NEG");
-           break;
-
-               case EXPR_NOT:
-           printf (" ~");
-           break;
-
-               case EXPR_LOBYTE:
-           printf (" LO");
-           break;
-
-               case EXPR_HIBYTE:
-           printf (" HI");
-           break;
-
-               case EXPR_SWAP:
-           printf (" SWAP");
-           break;
-
-       case EXPR_BAND:
-           printf (" BOOL_AND");
-           break;
-
-       case EXPR_BOR:
-           printf (" BOOL_OR");
-           break;
-
-       case EXPR_BXOR:
-           printf (" BOOL_XOR");
-           break;
-
-       case EXPR_BNOT:
-           printf (" BOOL_NOT");
-           break;
-
-        default:
-                   Internal ("Unknown Op type: %u", Expr->Op);
-
-    }
-}
-
-
-
-void DumpExpr (ExprNode* Expr)
-/* Dump an expression tree to stdout */
-{
-    InternalDumpExpr (Expr);
-    printf ("\n");
-}
-
-
-
 /*****************************************************************************/
 /*                                          Code                                    */
 /*****************************************************************************/
@@ -682,14 +545,14 @@ static ExprNode* Factor (void)
            NextTok ();
            N = NewExprNode ();
            N->Left = Factor ();
-           N->Op   = EXPR_LOBYTE;
+           N->Op   = EXPR_BYTE0;
            break;
 
        case TOK_GT:
            NextTok ();
            N = NewExprNode ();
            N->Left = Factor ();
-           N->Op   = EXPR_HIBYTE;
+           N->Op   = EXPR_BYTE1;
            break;
 
        case TOK_LPAREN:
@@ -1273,7 +1136,8 @@ int IsByteExpr (ExprNode* Root)
            SimplifyExpr (Root);
        }
                return IsByteRange (GetExprVal (Root));
-    } else if (Root->Op == EXPR_LOBYTE || Root->Op == EXPR_HIBYTE) {
+    } else if (Root->Op == EXPR_BYTE0 || Root->Op == EXPR_BYTE1 ||
+              Root->Op == EXPR_BYTE2 || Root->Op == EXPR_BYTE3) {
        /* Symbol forced to have byte range */
                IsByte = 1;
     } else {
@@ -1370,12 +1234,18 @@ long GetExprVal (ExprNode* Expr)
                case EXPR_NOT:
            return ~GetExprVal (Expr->Left);
 
-               case EXPR_LOBYTE:
+               case EXPR_BYTE0:
            return GetExprVal (Expr->Left) & 0xFF;
 
-               case EXPR_HIBYTE:
+               case EXPR_BYTE1:
            return (GetExprVal (Expr->Left) >> 8) & 0xFF;
 
+               case EXPR_BYTE2:
+           return (GetExprVal (Expr->Left) >> 16) & 0xFF;
+
+               case EXPR_BYTE3:
+           return (GetExprVal (Expr->Left) >> 24) & 0xFF;
+
         case EXPR_SWAP:
            Left = GetExprVal (Expr->Left);
            return ((Left >> 8) & 0x00FF) | ((Left << 8) & 0xFF00);
index e80d3133a81107b8347e84cdbb12f05faddcabf5..b1ead1bc4b10c3ccc78f130f9ed6b07b0b12f153 100644 (file)
@@ -38,7 +38,8 @@
 
 
 
-#include "../common/exprdefs.h"
+/* common */
+#include "exprdefs.h"
 
 
 
@@ -99,9 +100,6 @@ int IsByteRange (long Val);
 int IsWordRange (long Val);
 /* Return true if this is a word value */
 
-void DumpExpr (ExprNode* Expr);
-/* Dump an expression tree to stdout */
-
 ExprNode* FinalizeExpr (ExprNode* Expr);
 /* Resolve any symbols by cloning the symbol expression tree instead of the
  * symbol reference, then try to simplify the expression as much as possible.
index 31d9a896baa4f1c7b9383375a9609372ca176322..a6bf604d9200d5c8e4848aace618b49566a1d3ee 100644 (file)
 #include <errno.h>
 #include <ctype.h>
 
-#include "../common/segdefs.h"
-#include "../common/xmalloc.h"
-
+/* common */
+#include "segdefs.h"
+#include "xmalloc.h"
+          
+/* cc65 */
 #include "error.h"
 #include "fragment.h"
 #include "global.h"
@@ -160,7 +162,7 @@ static Segment* NewSegment (const char* Name, unsigned SegType)
     return S;
 }
 
-
+         
 
 void UseCodeSeg (void)
 /* Use the code segment */
@@ -629,10 +631,6 @@ static Fragment* NewFragment (unsigned char Type, unsigned short Len)
     if (LineCur) {
        if (LineCur->FragList == 0) {
            LineCur->FragList = F;
-           /* First fragment - set the PC
-           LineCur->PC    = GetPC ();
-           LineCur->Reloc = RelocMode;
-*/
        } else {
                    LineCur->FragLast->LineList = F;
        }
index 29befcea6d9d17045523f4ae15f5d46c3ab3c0f5..057eead6c80b1691040e2e90b6550ebd0c7b7b1e 100644 (file)
@@ -1131,6 +1131,7 @@ static CtrlDesc CtrlCmdTab [] = {
     { ccNone,          DoFarAddr       },
     { ccNone,          DoFeature       },
     { ccNone,          DoFileOpt       },
+    { ccNone,          DoUnexpected    },      /* .FORCEWORD */
     { ccNone,          DoGlobal        },
     { ccNone,          DoGlobalZP      },
     { ccNone,          DoI16           },
index 901a8761a481ee808df25b5cf976359fa0faae46..4ebe06774cde810dabe29b6a79f4376b6b4ac81c 100644 (file)
@@ -122,7 +122,7 @@ struct DotKeyword {
 } DotKeywords [] = {
     { "A16",           TOK_A16         },
     { "A8",            TOK_A8          },
-    { "ADDR",          TOK_ADDR        },
+    { "ADDR",          TOK_ADDR        },
     { "ALIGN",         TOK_ALIGN       },
     { "AND",           TOK_BAND        },
     { "ASCIIZ",                TOK_ASCIIZ      },
@@ -164,6 +164,7 @@ struct DotKeyword {
     { "FEATURE",       TOK_FEATURE     },
     { "FILEOPT",       TOK_FILEOPT     },
     { "FOPT",                  TOK_FILEOPT     },
+    { "FORCEWORD",     TOK_FORCEWORD   },
     { "GLOBAL",                TOK_GLOBAL      },
     { "GLOBALZP",      TOK_GLOBALZP    },
     { "I16",                   TOK_I16         },
@@ -500,7 +501,7 @@ static void NextChar (void)
                /* End of file. Add an empty line to the listing. This is a
                 * small hack needed to keep the PC output in sync.
                 */
-               NewListingLine ("", IFile->Pos.Name, ICount);
+               NewListingLine ("", IFile->Pos.Name, ICount);
                C = EOF;
                return;
            }
@@ -731,7 +732,7 @@ Again:
        IVal = 0;
        while (IsDigit (C)) {
            if (IVal > (0xFFFFFFFF / 10)) {
-                       Error (ERR_NUM_OVERFLOW);
+                       Error (ERR_NUM_OVERFLOW);
                IVal = 0;
            }
            IVal = (IVal * 10) + DigitVal (C);
index 952c6bab0da5d9e6fa3dc5f2a93fca30dad58c4c..1c4073b01f049f8f94000fab79ad85ae27259f21 100644 (file)
@@ -143,6 +143,7 @@ enum Token {
     TOK_FARADDR,
     TOK_FEATURE,
     TOK_FILEOPT,
+    TOK_FORCEWORD,
     TOK_GLOBAL,
     TOK_GLOBALZP,
     TOK_I16,
index 150960cbeb04c6d0308ff8967dad2f07860c9f7d..a2e4b981db49f367ad3c53b7cdf113b23fdad73b 100644 (file)
 
 
 
-#include <ctype.h>
+#include <string.h>
+#include <ctype.h>                                           
 
-/* common */ 
+/* common */
 #include "xmalloc.h"
 
 /* cc65 */
@@ -45,7 +46,7 @@
 
 
 /*****************************************************************************/
-/*                                  Data                                    */
+/*                                  Data                                    */
 /*****************************************************************************/
 
 
@@ -89,7 +90,7 @@ int ValidSegName (const char* Name)
 /* Return true if the given segment name is valid, return false otherwise */
 {
     /* Must start with '_' or a letter */
-    if (*Name != '_' && !isalpha(*Name)) {
+    if ((*Name != '_' && !isalpha(*Name)) || strlen(Name) > 80) {
        return 0;
     }
 
diff --git a/src/common/exprdefs.c b/src/common/exprdefs.c
new file mode 100644 (file)
index 0000000..d4a2130
--- /dev/null
@@ -0,0 +1,189 @@
+/*****************************************************************************/
+/*                                                                           */
+/*                                       exprdefs.c                                 */
+/*                                                                           */
+/*                       Expression tree definitions                        */
+/*                                                                           */
+/*                                                                           */
+/*                                                                           */
+/* (C) 1998-2000 Ullrich von Bassewitz                                       */
+/*               Wacholderweg 14                                             */
+/*               D-70597 Stuttgart                                           */
+/* EMail:        uz@musoftware.de                                            */
+/*                                                                           */
+/*                                                                           */
+/* This software is provided 'as-is', without any expressed or implied       */
+/* warranty.  In no event will the authors be held liable for any damages    */
+/* arising from the use of this software.                                    */
+/*                                                                           */
+/* Permission is granted to anyone to use this software for any purpose,     */
+/* including commercial applications, and to alter it and redistribute it    */
+/* freely, subject to the following restrictions:                            */
+/*                                                                           */
+/* 1. The origin of this software must not be misrepresented; you must not   */
+/*    claim that you wrote the original software. If you use this software   */
+/*    in a product, an acknowledgment in the product documentation would be  */
+/*    appreciated but is not required.                                       */
+/* 2. Altered source versions must be plainly marked as such, and must not   */
+/*    be misrepresented as being the original software.                      */
+/* 3. This notice may not be removed or altered from any source              */
+/*    distribution.                                                          */
+/*                                                                           */
+/*****************************************************************************/
+
+
+
+#include <stdio.h>
+
+#include "abend.h"
+#include "exprdefs.h"
+
+
+
+/*****************************************************************************/
+/*                                          Code                                    */
+/*****************************************************************************/
+
+
+
+static void InternalDumpExpr (const ExprNode* Expr)
+/* Dump an expression in RPN to stdout */
+{
+    if (Expr == 0) {
+       return;
+    }
+    InternalDumpExpr (Expr->Left);
+    InternalDumpExpr (Expr->Right);
+
+    switch (Expr->Op) {
+
+       case EXPR_LITERAL:
+       case EXPR_ULABEL:
+           printf (" $%04lX", Expr->V.Val & 0xFFFF);
+           break;
+
+       case EXPR_SYMBOL:
+                   printf (" SYM");
+           break;
+
+       case EXPR_SEGMENT:
+           printf (" SEG");
+           break;
+
+               case EXPR_PLUS:
+           printf (" +");
+           break;
+
+               case EXPR_MINUS:
+           printf (" -");
+           break;
+
+               case EXPR_MUL:
+           printf (" *");
+           break;
+
+               case EXPR_DIV:
+           printf (" /");
+           break;
+
+               case EXPR_MOD:
+           printf (" MOD");
+           break;
+
+       case EXPR_OR:
+           printf (" OR");
+           break;
+
+       case EXPR_XOR:
+           printf (" XOR");
+           break;
+
+       case EXPR_AND:
+           printf (" AND");
+           break;
+
+       case EXPR_SHL:
+           printf (" SHL");
+           break;
+
+       case EXPR_SHR:
+           printf (" SHR");
+           break;
+
+               case EXPR_EQ:
+           printf (" =");
+           break;
+
+               case EXPR_NE:
+           printf ("<>");
+           break;
+
+               case EXPR_LT:
+           printf (" <");
+           break;
+
+               case EXPR_GT:
+           printf (" >");
+           break;
+
+               case EXPR_UNARY_MINUS:
+           printf (" NEG");
+           break;
+
+               case EXPR_NOT:
+           printf (" ~");
+           break;
+
+               case EXPR_BYTE0:
+           printf (" BYTE0");
+           break;
+
+               case EXPR_BYTE1:
+           printf (" BYTE1");
+           break;
+
+               case EXPR_BYTE2:
+           printf (" BYTE2");
+           break;
+
+               case EXPR_BYTE3:
+           printf (" BYTE3");
+           break;
+
+               case EXPR_SWAP:
+           printf (" SWAP");
+           break;
+
+       case EXPR_BAND:
+           printf (" BOOL_AND");
+           break;
+
+       case EXPR_BOR:
+           printf (" BOOL_OR");
+           break;
+
+       case EXPR_BXOR:
+           printf (" BOOL_XOR");
+           break;       
+
+       case EXPR_BNOT:
+           printf (" BOOL_NOT");
+           break;
+
+        default:
+                   AbEnd ("Unknown Op type: %u", Expr->Op);
+
+    }
+}
+
+
+
+void DumpExpr (const ExprNode* Expr)
+/* Dump an expression tree to stdout */
+{
+    InternalDumpExpr (Expr);
+    printf ("\n");
+}
+
+
+
index 8eca9ea4f41d1ef4dbf621a6a0152f066d358c78..fec970b72add32efab23e6c1c82d2b41b7607684 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998     Ullrich von Bassewitz                                        */
-/*              Wacholderweg 14                                              */
-/*              D-70597 Stuttgart                                            */
-/* EMail:       uz@musoftware.de                                             */
+/* (C) 1998-2000 Ullrich von Bassewitz                                       */
+/*               Wacholderweg 14                                             */
+/*               D-70597 Stuttgart                                           */
+/* EMail:        uz@musoftware.de                                            */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
 /* Unary operations, right hand side is empty */
 #define EXPR_UNARY_MINUS               (EXPR_UNARYNODE | 0x01)
 #define EXPR_NOT                       (EXPR_UNARYNODE | 0x02)
-#define EXPR_LOBYTE                    (EXPR_UNARYNODE | 0x03)
-#define EXPR_HIBYTE                    (EXPR_UNARYNODE | 0x04)
-#define EXPR_SWAP                      (EXPR_UNARYNODE | 0x05)
-#define EXPR_BNOT              (EXPR_UNARYNODE | 0x06)
+#define EXPR_SWAP                      (EXPR_UNARYNODE | 0x03)
+#define EXPR_BNOT              (EXPR_UNARYNODE | 0x04)
+#define EXPR_FORCEWORD         (EXPR_UNARYNODE | 0x05)
+#define EXPR_FORCEFAR          (EXPR_UNARYNODE | 0x06)
+
+#define EXPR_BYTE0             (EXPR_UNARYNODE | 0x08) 
+#define EXPR_BYTE1             (EXPR_UNARYNODE | 0x09)
+#define EXPR_BYTE2             (EXPR_UNARYNODE | 0x0A)
+#define EXPR_BYTE3             (EXPR_UNARYNODE | 0x0B)
+#define EXPR_WORD0             (EXPR_UNARYNODE | 0x0C)
+#define EXPR_WORD1             (EXPR_UNARYNODE | 0x0D)
 
 
 
@@ -101,7 +108,7 @@ struct ExprNode_ {
     union {
                long                Val;        /* If this is a value */
                struct SymEntry_*   Sym;        /* If this is a symbol */
-       unsigned            SegNum;     /* If this is a segment */
+       unsigned            SegNum;     /* If this is a segment */
        unsigned            ImpNum;     /* If this is an import */
        struct Memory_*     MemArea;    /* If this is a memory area */
     } V;
@@ -116,6 +123,17 @@ struct ExprNode_ {
 
 
 
+/*****************************************************************************/
+/*                                          Code                                    */
+/*****************************************************************************/
+
+
+
+void DumpExpr (const ExprNode* Expr);
+/* Dump an expression tree to stdout */
+
+
+
 /* End of exprdefs.h */
 
 #endif
index 9b49c46bf2cf2ee1360e9bc36d3ad613f0ac3678..ce194ab85b4098c56088f89a93885600cb2e5e11 100644 (file)
@@ -12,6 +12,7 @@ LIB   = common.a
 OBJS = abend.o         \
        bitops.o        \
        cmdline.o       \
+       exprdefs.o      \
        fname.o         \
        hashstr.o       \
        xmalloc.o       \
index 909f44a80906275fb9081339916c526e340e2693..5c5d6a03ec541ba716f85253f6351f4f91b47cb8 100644 (file)
@@ -68,6 +68,7 @@ CCCFG  = -bt=$(TARGET) -d1 -onatx -zp4 -5 -zq -w2
 OBJS = abend.obj       \
        bitops.obj      \
        cmdline.obj     \
+       exprdefs.obj    \
        fname.obj       \
        hashstr.obj     \
        wildargv.obj    \
index 5a17ea888a43f3fe0d569480c5d0821905b6c803..d80434abbc81bd4f3dbd0285cc51b254c98b7e0a 100644 (file)
@@ -46,7 +46,7 @@
 
 /* Defines for magic and version */
 #define OBJ_MAGIC      0x616E7A55
-#define OBJ_VERSION    0x0005
+#define OBJ_VERSION    0x0006
 
 /* Size of an object file header */
 #define        OBJ_HDR_SIZE    56
index ed65a991c273d9d5ac276d1467032c69d6e8d53f..51471bb30cff258cc140ccc7377d1206ddb61947 100644 (file)
@@ -36,7 +36,7 @@
 /* common */
 #include "exprdefs.h"
 #include "xmalloc.h"
-         
+
 /* ld65 */
 #include "global.h"
 #include "error.h"
@@ -77,144 +77,6 @@ static void FreeExprNode (ExprNode* E)
 
 
 
-/*****************************************************************************/
-/*             Dump an expression tree on stdout for debugging              */
-/*****************************************************************************/
-
-
-
-static void InternalDumpExpr (const ExprNode* Expr)
-/* Dump an expression in UPN */
-{
-    if (Expr == 0) {
-       return;
-    }
-    InternalDumpExpr (Expr->Left);
-    InternalDumpExpr (Expr->Right);
-
-    switch (Expr->Op) {
-
-       case EXPR_LITERAL:
-           printf (" $%04lX", Expr->V.Val & 0xFFFF);
-           break;
-
-       case EXPR_SYMBOL:
-                   printf (" SYM");
-           break;
-
-       case EXPR_SEGMENT:
-           printf (" SEG");
-           break;
-
-               case EXPR_PLUS:
-           printf (" +");
-           break;
-
-               case EXPR_MINUS:
-           printf (" -");
-           break;
-
-               case EXPR_MUL:
-           printf (" *");
-           break;
-
-               case EXPR_DIV:
-           printf (" /");
-           break;
-
-               case EXPR_MOD:
-           printf (" %%");
-           break;
-
-       case EXPR_OR:
-           printf (" OR");
-           break;
-
-       case EXPR_XOR:
-           printf (" XOR");
-           break;
-
-       case EXPR_AND:
-           printf (" AND");
-           break;
-
-       case EXPR_SHL:
-           printf (" SHL");
-           break;
-
-       case EXPR_SHR:
-           printf (" SHR");
-           break;
-
-               case EXPR_EQ:
-           printf (" =");
-           break;
-
-               case EXPR_NE:
-           printf ("<>");
-           break;
-
-               case EXPR_LT:
-           printf (" <");
-           break;
-
-               case EXPR_GT:
-           printf (" >");
-           break;
-
-               case EXPR_UNARY_MINUS:
-           printf (" NEG");
-           break;
-
-               case EXPR_NOT:
-           printf (" ~");
-           break;
-
-               case EXPR_LOBYTE:
-           printf (" LO");
-           break;
-
-               case EXPR_HIBYTE:
-           printf (" HI");
-           break;
-
-               case EXPR_SWAP:
-           printf (" SWAP");
-           break;
-
-       case EXPR_BAND:
-           printf (" BOOL_AND");
-           break;
-
-       case EXPR_BOR:
-           printf (" BOOL_OR");
-           break;
-
-       case EXPR_BXOR:
-           printf (" BOOL_XOR");
-           break;
-
-       case EXPR_BNOT:
-           printf (" BOOL_NOT");
-           break;
-
-        default:
-                   Internal ("Unknown Op type: %u", Expr->Op);
-
-    }
-}
-
-
-
-void DumpExpr (const ExprNode* Expr)
-/* Dump an expression tree to stdout */
-{
-    InternalDumpExpr (Expr);
-    printf ("\n");
-}
-
-
-
 /*****************************************************************************/
 /*                                          Code                                    */
 /*****************************************************************************/
@@ -451,12 +313,18 @@ long GetExprVal (ExprNode* Expr)
                case EXPR_NOT:
            return ~GetExprVal (Expr->Left);
 
-               case EXPR_LOBYTE:
+               case EXPR_BYTE0:
            return GetExprVal (Expr->Left) & 0xFF;
 
-               case EXPR_HIBYTE:
+               case EXPR_BYTE1:
            return (GetExprVal (Expr->Left) >> 8) & 0xFF;
 
+               case EXPR_BYTE2:
+           return (GetExprVal (Expr->Left) >> 16) & 0xFF;
+
+               case EXPR_BYTE3:
+           return (GetExprVal (Expr->Left) >> 24) & 0xFF;
+
         case EXPR_SWAP:
            Left = GetExprVal (Expr->Left);
            return ((Left >> 8) & 0x00FF) | ((Left << 8) & 0xFF00);
index a30d5916451bbf55d24ad50958e63e89001aaa3d..a630cc0352f3a429b8b77e2c8776c20d78a73fdf 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1999     Ullrich von Bassewitz                                        */
-/*              Wacholderweg 14                                              */
-/*              D-70597 Stuttgart                                            */
-/* EMail:       uz@musoftware.de                                             */
+/* (C) 1999-2000 Ullrich von Bassewitz                                       */
+/*               Wacholderweg 14                                             */
+/*               D-70597 Stuttgart                                           */
+/* EMail:        uz@musoftware.de                                            */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
 #include <errno.h>
 #include <time.h>
 
-#include "../common/version.h"
-#include "../common/xmalloc.h"
+/* common */
+#include "version.h"
+#include "xmalloc.h"
 
+/* ld65 */
 #include "error.h"
 #include "exports.h"
 #include "expr.h"
@@ -448,7 +450,7 @@ static unsigned O65WriteExpr (ExprNode* E, int Signed, unsigned Size,
      * Calculate the number of bytes between this entry and the last one, and
      * setup all necessary intermediate bytes in the relocation table.
      */
-    Offs += D->SegSize;                /* Calulate full offset */
+    Offs += D->SegSize;                /* Calulate full offset */
     Diff = ((long) Offs) - D->LastOffs;
     while (Diff > 0xFE) {
        O65RelocPutByte (D->CurReloc, 0xFF);
@@ -461,7 +463,9 @@ static unsigned O65WriteExpr (ExprNode* E, int Signed, unsigned Size,
 
     /* Determine the expression to relocate */
     Expr = E;
-    if (E->Op == EXPR_LOBYTE || E->Op == EXPR_HIBYTE) {
+    if (E->Op == EXPR_BYTE0 || E->Op == EXPR_BYTE1 ||
+       E->Op == EXPR_BYTE2 || E->Op == EXPR_BYTE3 ||
+       E->Op == EXPR_WORD0 || E->Op == EXPR_WORD1) {
        /* Use the real expression */
                Expr = E->Left;
     }
@@ -491,19 +495,22 @@ static unsigned O65WriteExpr (ExprNode* E, int Signed, unsigned Size,
 
     /* Write out the offset that goes into the segment. */
     BinVal = ED.Val;
-    if (E->Op == EXPR_LOBYTE) {
-       BinVal &= 0x00FF;
-    } else if (E->Op == EXPR_HIBYTE) {
-               BinVal = (BinVal >> 8) & 0x00FF;
+    switch (E->Op) {
+       case EXPR_BYTE0:    BinVal &= 0xFF;                     break;
+       case EXPR_BYTE1:    BinVal = (BinVal >>  8) & 0xFF;     break;
+       case EXPR_BYTE2:    BinVal = (BinVal >> 16) & 0xFF;     break;
+       case EXPR_BYTE3:    BinVal = (BinVal >> 24) & 0xFF;     break;
+       case EXPR_WORD0:    BinVal &= 0xFFFF;                   break;
+       case EXPR_WORD1:    BinVal = (BinVal >> 16) & 0xFFFF;   break;
     }
     WriteVal (D->F, BinVal, Size);
 
     /* Determine the actual type of relocation entry needed from the
      * information gathered about the expression.
      */
-    if (E->Op == EXPR_LOBYTE) {
+    if (E->Op == EXPR_BYTE0) {
        RelocType = O65RELOC_LOW;
-    } else if (E->Op == EXPR_HIBYTE) {
+    } else if (E->Op == EXPR_BYTE1) {
        RelocType = O65RELOC_HIGH;
     } else {
        switch (Size) {
@@ -526,7 +533,7 @@ static unsigned O65WriteExpr (ExprNode* E, int Signed, unsigned Size,
 
            default:
                Internal ("O65WriteExpr: Invalid expression size: %u", Size);
-               RelocType = 0;          /* Avoid gcc warnings */
+               RelocType = 0;          /* Avoid gcc warnings */
        }
     }