/*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2010, Ullrich von Bassewitz                                      */
+/* (C) 1998-2013, Ullrich von Bassewitz                                      */
 /*                Roemerstrasse 52                                           */
 /*                D-70794 Filderstadt                                        */
 /* EMail:         uz@cc65.org                                                */
 /* Print an error message about an invalid operand type */
 {
     /* Special handling for floats here: */
-    if ((type & CF_TYPE) == CF_FLOAT) {
+    if ((type & CF_TYPEMASK) == CF_FLOAT) {
         Fatal ("Floating point type is currently unsupported");
     } else {
-        Internal ("Invalid type in CF flags: %04X, type = %u", type, type & CF_TYPE);
+        Internal ("Invalid type in CF flags: %04X, type = %u", type, type & CF_TYPEMASK);
     }
 }
 
 unsigned sizeofarg (unsigned flags)
 /* Return the size of a function argument type that is encoded in flags */
 {
-    switch (flags & CF_TYPE) {
+    switch (flags & CF_TYPEMASK) {
 
         case CF_CHAR:
             return (flags & CF_FORCECHAR)? 1 : 2;
     if ((Flags & CF_CONST) != 0) {
 
         /* Numeric constant */
-        switch (Flags & CF_TYPE) {
+        switch (Flags & CF_TYPEMASK) {
 
             case CF_CHAR:
                 if ((Flags & CF_FORCECHAR) != 0) {
     const char* lbuf = GetLabelName (flags, label, offs);
 
     /* Check the size and generate the correct load operation */
-    switch (flags & CF_TYPE) {
+    switch (flags & CF_TYPEMASK) {
 
         case CF_CHAR:
             if ((flags & CF_FORCECHAR) || (flags & CF_TEST)) {
 /* Fetch specified local object (local var). */
 {
     Offs -= StackPtr;
-    switch (Flags & CF_TYPE) {
+    switch (Flags & CF_TYPEMASK) {
 
         case CF_CHAR:
             CheckLocalOffs (Offs);
     Offs = MakeByteOffs (Flags, Offs);
 
     /* Handle the indirect fetch */
-    switch (Flags & CF_TYPE) {
+    switch (Flags & CF_TYPEMASK) {
 
         case CF_CHAR:
             /* Character sized */
     const char* lbuf = GetLabelName (flags, label, offs);
 
     /* Check the size and generate the correct store operation */
-    switch (flags & CF_TYPE) {
+    switch (flags & CF_TYPEMASK) {
 
         case CF_CHAR:
             AddCodeLine ("sta %s", lbuf);
 {
     Offs -= StackPtr;
     CheckLocalOffs (Offs);
-    switch (Flags & CF_TYPE) {
+    switch (Flags & CF_TYPEMASK) {
 
         case CF_CHAR:
             if (Flags & CF_CONST) {
 
     /* Check the size and determine operation */
     AddCodeLine ("ldy #$%02X", Offs);
-    switch (Flags & CF_TYPE) {
+    switch (Flags & CF_TYPEMASK) {
 
         case CF_CHAR:
             AddCodeLine ("jsr staspidx");
 void g_toslong (unsigned flags)
 /* Make sure, the value on TOS is a long. Convert if necessary */
 {
-    switch (flags & CF_TYPE) {
+    switch (flags & CF_TYPEMASK) {
 
         case CF_CHAR:
         case CF_INT:
 void g_tosint (unsigned flags)
 /* Make sure, the value on TOS is an int. Convert if necessary */
 {
-    switch (flags & CF_TYPE) {
+    switch (flags & CF_TYPEMASK) {
 
         case CF_CHAR:
         case CF_INT:
 {
     unsigned L;
 
-    switch (Flags & CF_TYPE) {
+    switch (Flags & CF_TYPEMASK) {
 
         case CF_CHAR:
             if (Flags & CF_FORCECHAR) {
 {
     unsigned L;
 
-    switch (Flags & CF_TYPE) {
+    switch (Flags & CF_TYPEMASK) {
 
         case CF_CHAR:
             if (Flags & CF_FORCECHAR) {
     unsigned result;
 
     /* Get the type spec from the flags */
-    ltype = lhs & CF_TYPE;
-    rtype = rhs & CF_TYPE;
+    ltype = lhs & CF_TYPEMASK;
+    rtype = rhs & CF_TYPEMASK;
 
     /* Check if a conversion is needed */
     if (ltype == CF_LONG && rtype != CF_LONG && (rhs & CF_CONST) == 0) {
         /* We must promote the primary register to long */
         g_reglong (rhs);
         /* Get the new rhs type */
-        rhs = (rhs & ~CF_TYPE) | CF_LONG;
+        rhs = (rhs & ~CF_TYPEMASK) | CF_LONG;
         rtype = CF_LONG;
     } else if (ltype != CF_LONG && (lhs & CF_CONST) == 0 && rtype == CF_LONG) {
         /* We must promote the lhs to long */
             g_toslong (lhs);
         }
         /* Get the new rhs type */
-        lhs = (lhs & ~CF_TYPE) | CF_LONG;
+        lhs = (lhs & ~CF_TYPEMASK) | CF_LONG;
         ltype = CF_LONG;
     }
 
     unsigned ltype, rtype;
 
     /* Get the type spec from the flags */
-    ltype = lhs & CF_TYPE;
-    rtype = rhs & CF_TYPE;
+    ltype = lhs & CF_TYPEMASK;
+    rtype = rhs & CF_TYPEMASK;
 
     /* Check if a conversion is needed */
     if ((rhs & CF_CONST) == 0) {
         if ((p2 = PowerOf2 (val)) > 0 && p2 <= 4) {
 
             /* Factor is 2, 4, 8 and 16, use special function */
-            switch (flags & CF_TYPE) {
+            switch (flags & CF_TYPEMASK) {
 
                 case CF_CHAR:
                     if (flags & CF_FORCECHAR) {
         if ((p2 = PowerOf2 (val)) > 0 && p2 <= 4) {
 
             /* Factor is 2, 4, 8 and 16 use special function */
-            switch (flags & CF_TYPE) {
+            switch (flags & CF_TYPEMASK) {
 
                 case CF_CHAR:
                     if (flags & CF_FORCECHAR) {
     offs -= StackPtr;
     CheckLocalOffs (offs);
 
-    switch (flags & CF_TYPE) {
+    switch (flags & CF_TYPEMASK) {
 
         case CF_CHAR:
             L = GetLocalLabel();
     /* Create the correct label name */
     const char* lbuf = GetLabelName (flags, label, offs);
 
-    switch (flags & CF_TYPE) {
+    switch (flags & CF_TYPEMASK) {
 
         case CF_CHAR:
             L = GetLocalLabel();
     const char* lbuf = GetLabelName (flags, label, offs);
 
     /* Check the size and determine operation */
-    switch (flags & CF_TYPE) {
+    switch (flags & CF_TYPEMASK) {
 
         case CF_CHAR:
             if (flags & CF_FORCECHAR) {
     CheckLocalOffs (Offs);
 
     /* Check the size and determine operation */
-    switch (flags & CF_TYPE) {
+    switch (flags & CF_TYPEMASK) {
 
         case CF_CHAR:
             if (flags & CF_FORCECHAR) {
     offs = MakeByteOffs (flags, offs);
 
     /* Check the size and determine operation */
-    switch (flags & CF_TYPE) {
+    switch (flags & CF_TYPEMASK) {
 
         case CF_CHAR:
             AddCodeLine ("sta ptr1");
     const char* lbuf = GetLabelName (flags, label, offs);
 
     /* Check the size and determine operation */
-    switch (flags & CF_TYPE) {
+    switch (flags & CF_TYPEMASK) {
 
         case CF_CHAR:
             if (flags & CF_FORCECHAR) {
     CheckLocalOffs (Offs);
 
     /* Check the size and determine operation */
-    switch (flags & CF_TYPE) {
+    switch (flags & CF_TYPEMASK) {
 
         case CF_CHAR:
             if (flags & CF_FORCECHAR) {
     offs = MakeByteOffs (flags, offs);
 
     /* Check the size and determine operation */
-    switch (flags & CF_TYPE) {
+    switch (flags & CF_TYPEMASK) {
 
         case CF_CHAR:
             AddCodeLine ("sta ptr1");
 /* Copy primary register to hold register. */
 {
     /* Check the size and determine operation */
-    switch (flags & CF_TYPE) {
+    switch (flags & CF_TYPEMASK) {
 
         case CF_CHAR:
             if (flags & CF_FORCECHAR) {
 /* Copy hold register to primary. */
 {
     /* Check the size and determine operation */
-    switch (flags & CF_TYPE) {
+    switch (flags & CF_TYPEMASK) {
 
         case CF_CHAR:
             if (flags & CF_FORCECHAR) {
     unsigned L;
 
     /* Check the size and determine operation */
-    switch (flags & CF_TYPE) {
+    switch (flags & CF_TYPEMASK) {
 
         case CF_CHAR:
             if (flags & CF_FORCECHAR) {
     if (Flags & CF_UNSIGNED) {
         ++Subs;
     }
-    if ((Flags & CF_TYPE) == CF_LONG) {
+    if ((Flags & CF_TYPEMASK) == CF_LONG) {
         Subs += 2;
     }
 
 void g_test (unsigned flags)
 /* Test the value in the primary and set the condition codes */
 {
-    switch (flags & CF_TYPE) {
+    switch (flags & CF_TYPEMASK) {
 
         case CF_CHAR:
             if (flags & CF_FORCECHAR) {
 void g_push (unsigned flags, unsigned long val)
 /* Push the primary register or a constant value onto the stack */
 {
-    if (flags & CF_CONST && (flags & CF_TYPE) != CF_LONG) {
+    if (flags & CF_CONST && (flags & CF_TYPEMASK) != CF_LONG) {
 
         /* We have a constant 8 or 16 bit value */
-        if ((flags & CF_TYPE) == CF_CHAR && (flags & CF_FORCECHAR)) {
+        if ((flags & CF_TYPEMASK) == CF_CHAR && (flags & CF_FORCECHAR)) {
 
             /* Handle as 8 bit value */
             AddCodeLine ("lda #$%02X", (unsigned char) val);
         }
 
         /* Push the primary register */
-        switch (flags & CF_TYPE) {
+        switch (flags & CF_TYPEMASK) {
 
             case CF_CHAR:
                 if (flags & CF_FORCECHAR) {
  * of *both* values (must have same size).
  */
 {
-    switch (flags & CF_TYPE) {
+    switch (flags & CF_TYPEMASK) {
 
         case CF_CHAR:
         case CF_INT:
      */
     if (flags & CF_CONST) {
 
-        switch (flags & CF_TYPE) {
+        switch (flags & CF_TYPEMASK) {
 
             case CF_CHAR:
                 if (flags & CF_FORCECHAR) {
      */
     if (flags & CF_CONST) {
 
-        switch (flags & CF_TYPE) {
+        switch (flags & CF_TYPEMASK) {
 
             case CF_CHAR:
                 if (flags & CF_FORCECHAR) {
      */
     if (flags & CF_CONST) {
 
-        switch (flags & CF_TYPE) {
+        switch (flags & CF_TYPEMASK) {
 
             case CF_CHAR:
                 if (flags & CF_FORCECHAR) {
      */
     if (Flags & CF_CONST) {
 
-        switch (Flags & CF_TYPE) {
+        switch (Flags & CF_TYPEMASK) {
 
             case CF_CHAR:
                 if (Flags & CF_FORCECHAR) {
      */
     if (flags & CF_CONST) {
 
-        switch (flags & CF_TYPE) {
+        switch (flags & CF_TYPEMASK) {
 
             case CF_CHAR:
             case CF_INT:
      */
     if (flags & CF_CONST) {
 
-        switch (flags & CF_TYPE) {
+        switch (flags & CF_TYPEMASK) {
 
             case CF_CHAR:
             case CF_INT:
 void g_neg (unsigned Flags)
 /* Primary = -Primary */
 {
-    switch (Flags & CF_TYPE) {
+    switch (Flags & CF_TYPEMASK) {
 
         case CF_CHAR:
             if (Flags & CF_FORCECHAR) {
 void g_bneg (unsigned flags)
 /* Primary = !Primary */
 {
-    switch (flags & CF_TYPE) {
+    switch (flags & CF_TYPEMASK) {
 
         case CF_CHAR:
             AddCodeLine ("jsr bnega");
 void g_com (unsigned Flags)
 /* Primary = ~Primary */
 {
-    switch (Flags & CF_TYPE) {
+    switch (Flags & CF_TYPEMASK) {
 
         case CF_CHAR:
             if (Flags & CF_FORCECHAR) {
 
     /* Generate code for the supported types */
     flags &= ~CF_CONST;
-    switch (flags & CF_TYPE) {
+    switch (flags & CF_TYPEMASK) {
 
         case CF_CHAR:
             if (flags & CF_FORCECHAR) {
 
     /* Generate code for the supported types */
     flags &= ~CF_CONST;
-    switch (flags & CF_TYPE) {
+    switch (flags & CF_TYPEMASK) {
 
         case CF_CHAR:
             if (flags & CF_FORCECHAR) {
      */
     if (flags & CF_CONST) {
 
-        switch (flags & CF_TYPE) {
+        switch (flags & CF_TYPEMASK) {
 
             case CF_CHAR:
                 if (flags & CF_FORCECHAR) {
      */
     if (flags & CF_CONST) {
 
-        switch (flags & CF_TYPE) {
+        switch (flags & CF_TYPEMASK) {
 
             case CF_CHAR:
                 if (flags & CF_FORCECHAR) {
             }
 
             /* Look at the type */
-            switch (flags & CF_TYPE) {
+            switch (flags & CF_TYPEMASK) {
 
                 case CF_CHAR:
                     if (flags & CF_FORCECHAR) {
         } else if (val == 0) {
 
             /* A signed compare against zero must only look at the sign bit */
-            switch (flags & CF_TYPE) {
+            switch (flags & CF_TYPEMASK) {
 
                 case CF_CHAR:
                     if (flags & CF_FORCECHAR) {
         } else {
 
             /* Signed compare against a constant != zero */
-            switch (flags & CF_TYPE) {
+            switch (flags & CF_TYPEMASK) {
 
                 case CF_CHAR:
                     if (flags & CF_FORCECHAR) {
     if (flags & CF_CONST) {
 
         /* Look at the type */
-        switch (flags & CF_TYPE) {
+        switch (flags & CF_TYPEMASK) {
 
             case CF_CHAR:
                 if (flags & CF_FORCECHAR) {
     if (flags & CF_CONST) {
 
         /* Look at the type */
-        switch (flags & CF_TYPE) {
+        switch (flags & CF_TYPEMASK) {
 
             case CF_CHAR:
                 if (flags & CF_FORCECHAR) {
             }
 
             /* Look at the type */
-            switch (flags & CF_TYPE) {
+            switch (flags & CF_TYPEMASK) {
 
                 case CF_CHAR:
                     if (flags & CF_FORCECHAR) {
         } else if (val == 0) {
 
             /* A signed compare against zero must only look at the sign bit */
-            switch (flags & CF_TYPE) {
+            switch (flags & CF_TYPEMASK) {
 
                 case CF_CHAR:
                     if (flags & CF_FORCECHAR) {
         } else {
 
             /* Signed compare against a constant != zero */
-            switch (flags & CF_TYPE) {
+            switch (flags & CF_TYPEMASK) {
 
                 case CF_CHAR:
                     if (flags & CF_FORCECHAR) {
     if (flags & CF_CONST) {
 
         /* Numeric constant */
-        switch (flags & CF_TYPE) {
+        switch (flags & CF_TYPEMASK) {
 
             case CF_CHAR:
                AddDataLine ("\t.byte\t$%02lX", val & 0xFF);