]> git.gag.com Git - fw/sdcc/commitdiff
xa51, work in progress
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 25 Jan 2002 16:46:18 +0000 (16:46 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 25 Jan 2002 16:46:18 +0000 (16:46 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1839 4a8a32a2-be11-0410-ad9d-d568d2c75423

as/xa51/xa_asm.y
device/lib/Makefile.in
src/SDCCglue.c
src/mcs51/gen.c
src/port.h
src/xa51/gen.c
src/xa51/main.c
src/xa51/ralloc.c

index 8ef50d5e21eb4860dd051264da9a2cf4338e1c7a..7791e7bef41ba7f4232c28caf91bd157fcd6c5c2 100644 (file)
@@ -111,6 +111,10 @@ directive:     '.' ORG expr {
                        if (p1 || p2) assign_value(symbol_name, $5);
                        $$ = 0;
                }
+             | normal_or_bit_symbol '=' expr {
+                       if (p1) build_sym_list(symbol_name);
+                       if (p1 || p2) assign_value(symbol_name, $3);
+               }
             | symbol EQU expr {
                        if (p1) build_sym_list(symbol_name);
                        if (p1 || p2) assign_value(symbol_name, $3);
@@ -132,6 +136,14 @@ directive:     '.' ORG expr {
                         if (p1 || p2) assign_value(symbol_name, $3);
                         $$ = 0;
                 }
+            | bitsymbol BITDEF expr {
+                       if (p1) {
+                                build_sym_list(symbol_name);
+                                mk_bit(symbol_name);
+                        }
+                        if (p1 || p2) assign_value(symbol_name, $3);
+                        $$ = 0;
+                }
             | '.' REGDEF regsymbol ',' REG {
                        if (p1) {
                                build_sym_list(symbol_name);
index 4b97353a51ebec26d73d987a301ffc663017f35a..8efe2a186ff047ce281b105a9cdf57c746ed26d0 100644 (file)
@@ -106,6 +106,7 @@ XA51SOURCES      = _atoi.c _atol.c _schar2fs.c \
                  _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
                  _strstr.c _strtok.c _uchar2fs.c _uint2fs.c \
                  _ulong2fs.c malloc.c puts.c gets.c \
+                 printf_large.c puts.c gets.c \
                  assert.c _strcat.c time.c \
                  fabsf.c frexpf.c ldexpf.c expf.c powf.c sincosf.c sinf.c \
                  cosf.c logf.c log10f.c sqrtf.c tancotf.c tanf.c cotf.c \
index 3ef987054d3f432fdc94e1516915e289eda2bd7d..da74378f09a5e7171c73f0948c6a41c96106a4df 100644 (file)
@@ -279,11 +279,19 @@ emitRegularMap (memmap * map, bool addPublics, bool arFlag)
          an equate for this no need to allocate space */
       if (SPEC_ABSA (sym->etype))
        {
+         char *equ="=";
          if (options.debug) {
            fprintf (map->oFile, " == 0x%04x\n", SPEC_ADDR (sym->etype));
          }
-         fprintf (map->oFile, "%s\t=\t0x%04x\n",
-                  sym->rname,
+         if (TARGET_IS_XA51) {
+           if (map==sfr) {
+             equ="sfr";
+           } else if (map==bit || map==sfrbit) {
+             equ="bit";
+           }
+         }
+         fprintf (map->oFile, "%s\t%s\t0x%04x\n",
+                  sym->rname, equ,
                   SPEC_ADDR (sym->etype));
        }
       else {
index 383d148e4b180d9d806902c8f6fdaee6edc3efdb..ceaf3b50d69e961582265a68d18ddb483d83b2a6 100644 (file)
@@ -4906,7 +4906,7 @@ genOr (iCode * ic, iCode * ifx)
     {
       if (AOP_TYPE (right) == AOP_LIT)
        {
-         // c = bit & literal;
+         // c = bit | literal;
          if (lit)
            {
              // lit != 0 => result = 1
index 7a6220adc80c84bf90afc68e9585bf224d6f198d..672a701b3b89e86f36b791adaa83166564554101 100644 (file)
@@ -28,6 +28,7 @@
 #define TARGET_IS_PIC   (port->id==TARGET_ID_PIC)
 #define TARGET_IS_I186 (port->id==TARGET_ID_I186)
 #define TARGET_IS_TCLS900H (port->id==TARGET_ID_TCLS900H)
+#define TARGET_IS_XA51 (port->id==TARGET_ID_XA51)
 
 #define MAX_BUILTIN_ARGS       16
 /* definition of builtin functions */
index 51a226da77922a143a71e1fe20bad371e1ac986f..67690d5ee86d0c4029fa76abe98c9e682c57f969 100755 (executable)
@@ -23,9 +23,6 @@
   You are forbidden to forbid anyone else to use, share and improve
   what you give them.   Help stamp out software-hoarding!
 
-  Notes:
-  000123 mlh  Moved aopLiteral to SDCCglue.c to help the split
-      Made everything static
 -------------------------------------------------------------------------*/
 
 //#define D(x)
@@ -94,10 +91,13 @@ static lineNode *lineCurr = NULL;
 #define MSB24   2
 #define MSB32   3
 
+static char *MOV="mov";
 static char *MOVB="mov.b";
 static char *MOVW="mov.w";
-//static char *MOVCB="movc.b";
-//static char *MOVCW="movc.w";
+static char *MOVC="movc";
+
+static char *R1L="r1l";
+static char *R1="r1";
 
 void bailOut (char *mesg) {
   fprintf (stderr, "%s: bailing out\n", mesg);
@@ -178,7 +178,8 @@ char *aopTypeName(asmop *aop) {
 /*-----------------------------------------------------------------*/
 /* aopForSym - for a true symbol                                   */
 /*-----------------------------------------------------------------*/
-static asmop *aopForSym(symbol *sym, bool result, bool cantUsePointer) {
+static asmop *aopForSym(symbol *sym, 
+                       bool canUsePointer, bool canUseOffset) {
   int size;
   asmop *aop;
 
@@ -197,7 +198,7 @@ static asmop *aopForSym(symbol *sym, bool result, bool cantUsePointer) {
 
   // if it is on stack
   if (sym->onStack) {
-    if (cantUsePointer) {
+    if (!canUsePointer || !canUseOffset) {
       aop->type=AOP_REG;
       switch (size) 
        {
@@ -222,7 +223,6 @@ static asmop *aopForSym(symbol *sym, bool result, bool cantUsePointer) {
          sprintf (aop->name[1], "r1");
          return aop;
        }
-      bailOut("aopForSym: onStack CantUsePointer unknown size");
     }
     aop->type=AOP_STK;
     sprintf (aop->name[0], "[%s]", getStackOffset(sym->stack));
@@ -234,7 +234,7 @@ static asmop *aopForSym(symbol *sym, bool result, bool cantUsePointer) {
 
   // if it has a spillLoc
   if (sym->usl.spillLoc) {
-    return aopForSym (sym->usl.spillLoc, result, cantUsePointer);
+    return aopForSym (sym->usl.spillLoc, canUsePointer, canUseOffset);
   }
 
   // if in bit space
@@ -256,29 +256,89 @@ static asmop *aopForSym(symbol *sym, bool result, bool cantUsePointer) {
 
   // if in code space
   if (IN_CODESPACE(SPEC_OCLS(sym->etype))) {
-    if (result) {
-      bailOut("aopForSym: result can not be in code space");
-    }
-    aop->type=AOP_CODE;
-    emitcode ("mov", "r0,#%s ; aopForSym:code", sym->rname);
-    sprintf (aop->name[0], "[r0]");
-    if (size>2) {
-      sprintf (aop->name[1], "[r0+2]");
+    if (!canUsePointer) {
+      aop->type=AOP_REG;
+      switch (size) 
+       {
+       case 1:
+         emitcode (MOV, "r0,#%s", sym->rname);
+         emitcode (MOVC, "r0l,[r0]");
+         sprintf (aop->name[0], "r0l");
+         return aop;
+       case 2:
+         emitcode (MOV, "r0,#%s", sym->rname);
+         emitcode (MOVC, "r0,[r0]");
+         sprintf (aop->name[0], "r0");
+         return aop;
+       case 3:
+         emitcode (MOV, "r0,#%s", sym->rname);
+         emitcode (MOVC, "r1l,[r0+2]");
+         sprintf (aop->name[1], "r1l");
+         emitcode (MOV, "r0,[r0]");
+         sprintf (aop->name[0], "r0");
+         return aop;
+       case 4:
+         emitcode (MOV, "r0,#%s", sym->rname);
+         emitcode (MOVC, "r1,[r0+2]");
+         sprintf (aop->name[1], "r1");
+         emitcode (MOVC, "r0,[r0]");
+         sprintf (aop->name[0], "r0");
+         return aop;
+       }
+      
+    } else {
+      aop->type=AOP_CODE;
+      emitcode ("mov", "r0,#%s ; aopForSym:code", sym->rname);
+      sprintf (aop->name[0], "[r0]");
+      if (size>2) {
+       sprintf (aop->name[1], "[r0+2]");
+      }
     }
     return aop;
   }
 
   // if in far space
   if (IN_FARSPACE(SPEC_OCLS(sym->etype))) {
-    aop->type=AOP_FAR;
-    emitcode ("mov", "r0,#%s ; aopForSym:far", sym->rname);
-    sprintf (aop->name[0], "[r0]");
-    if (size>2) {
-      sprintf (aop->name[1], "[r0+2]");
+    if (!canUsePointer) {
+      aop->type=AOP_REG;
+      switch (size) 
+       {
+       case 1:
+         emitcode (MOV, "r0,#%s", sym->rname);
+         emitcode (MOV, "r0l,[r0]");
+         sprintf (aop->name[0], "r0l");
+         return aop;
+       case 2:
+         emitcode (MOV, "r0,#%s", sym->rname);
+         emitcode (MOV, "r0,[r0]");
+         sprintf (aop->name[0], "r0");
+         return aop;
+       case 3:
+         emitcode (MOV, "r0,#%s", sym->rname);
+         emitcode (MOV, "r1l,[r0+2]");
+         sprintf (aop->name[1], "r1l");
+         emitcode (MOV, "r0,[r0]");
+         sprintf (aop->name[0], "r0");
+         return aop;
+       case 4:
+         emitcode (MOV, "r0,#%s", sym->rname);
+         emitcode (MOV, "r1,[r0+2]");
+         sprintf (aop->name[1], "r1");
+         emitcode (MOV, "r0,[r0]");
+         sprintf (aop->name[0], "r0");
+         return aop;
+       }
+    } else {
+      aop->type=AOP_FAR;
+      emitcode ("mov", "r0,#%s ; aopForSym:far", sym->rname);
+      sprintf (aop->name[0], "[r0]");
+      if (size>2) {
+       sprintf (aop->name[1], "[r0+2]");
+      }
+      return aop;
     }
-    return aop;
   }
-
+  
   bailOut("aopForSym");
   return NULL;
 }
@@ -342,21 +402,35 @@ static asmop *aopForVal(operand *op) {
   return NULL;
 }
 
-static void aopOp(operand *op, bool result, bool cantUsePointer) {
+static int aopOp(operand *op, 
+                 bool canUsePointer, bool canUseOffset) {
 
   if (IS_SYMOP(op)) {
-    op->aop=aopForSym (OP_SYMBOL(op), result, cantUsePointer);
-    return;
+    op->aop=aopForSym (OP_SYMBOL(op), canUsePointer, canUseOffset);
+    return AOP_SIZE(op);
   }
   if (IS_VALOP(op)) {
-    if (result) {
-      bailOut("aopOp: result can not be a value");
-    }
     op->aop=aopForVal (op);
-    return;
+    return AOP_SIZE(op);
   }
 
   bailOut("aopOp: unexpected operand");
+  return 0;
+}
+
+bool aopEqual(asmop *aop1, asmop *aop2, int offset) {
+  if (strcmp(aop1->name[offset], aop2->name[offset])) {
+    return FALSE;
+  }
+  return TRUE;
+}
+
+bool aopIsDir(operand *op) {
+  return AOP_TYPE(op)==AOP_DIR;
+}
+
+bool aopIsBit(operand *op) {
+  return AOP_TYPE(op)==AOP_BIT;
 }
 
 bool aopIsPtr(operand *op) {
@@ -692,7 +766,7 @@ static void genRet (iCode * ic) {
 
   printIc ("genRet", ic, 0,1,0);
 
-  aopOp(IC_LEFT(ic),FALSE, FALSE);
+  aopOp(IC_LEFT(ic), TRUE, TRUE);
 
   switch (AOP_SIZE(IC_LEFT(ic)))
     {
@@ -779,19 +853,19 @@ static void genCmpGt (iCode * ic) {
 /* genCmpGt :- greater than comparison                             */
 /*-----------------------------------------------------------------*/
 static void genCmpLe (iCode * ic) {
-  printIc ("genCmpGt", ic, 1,1,1);
+  printIc ("genCmpLe", ic, 1,1,1);
 }
 /*-----------------------------------------------------------------*/
 /* genCmpGt :- greater than comparison                             */
 /*-----------------------------------------------------------------*/
 static void genCmpGe (iCode * ic) {
-  printIc ("genCmpGt", ic, 1,1,1);
+  printIc ("genCmpGe", ic, 1,1,1);
 }
 /*-----------------------------------------------------------------*/
 /* genCmpGt :- greater than comparison                             */
 /*-----------------------------------------------------------------*/
 static void genCmpNe (iCode * ic) {
-  printIc ("genCmpGt", ic, 1,1,1);
+  printIc ("genCmpNe", ic, 1,1,1);
 }
 /*-----------------------------------------------------------------*/
 /* genCmpLt - less than comparisons                                */
@@ -886,7 +960,50 @@ static void genAnd (iCode * ic, iCode * ifx) {
 /* genOr  - code for or                                            */
 /*-----------------------------------------------------------------*/
 static void genOr (iCode * ic, iCode * ifx) {
+  operand *result=IC_RESULT(ic), *left=IC_LEFT(ic), *right=IC_RIGHT(ic);
+  int size=aopOp(result, TRUE, TRUE);
+  char *instr;
+
   printIc ("genOr", ic, 1,1,1);
+
+  /* if left is a literal, then exchange them */
+  if (IS_LITERAL(operandType(left))) {
+    operand *tmp = right;
+    right = left;
+    left = tmp;
+  }
+    
+  if (aopIsBit(result)) {
+    if (IS_LITERAL(operandType(right))) {
+      if (operandLitValue(right)) {
+       emitcode ("setb", AOP_NAME(result)[0]);
+       return;
+      }
+      aopOp(left, TRUE, TRUE);
+      emitcode ("mov", "%s,%s", AOP_NAME(result)[0], toBoolean(left));
+      return;
+    }
+  }
+  
+  aopOp(left, !aopIsPtr(result), !aopIsDir(result));
+  aopOp(right, !aopIsPtr(result), !aopIsDir(result));
+
+  if (size>1) {
+    instr="or.w";
+  } else {
+    instr="or.b";
+  }
+  if (!aopEqual(result->aop, left->aop, 0)) {
+    emitcode ("mov", "%s,%s", AOP_NAME(result)[0], AOP_NAME(left)[0]);
+  }
+  emitcode (instr, "%s,%s", AOP_NAME(result)[0], AOP_NAME(right)[0]);
+  if (size>2) {
+    if (!aopEqual(result->aop, left->aop, 1)) {
+      emitcode ("mov", "%s,%s", AOP_NAME(result)[1], AOP_NAME(left)[1]);
+    }
+    emitcode (instr, "%s,%s", AOP_NAME(result)[1], AOP_NAME(right)[1]);
+  }
+  return;
 }
 
 /*-----------------------------------------------------------------*/
@@ -900,7 +1017,10 @@ static void genXor (iCode * ic, iCode * ifx) {
 /* genInline - write the inline code out                           */
 /*-----------------------------------------------------------------*/
 static void genInline (iCode * ic) {
+
   printIc ("genInline", ic, 0,0,0);
+  
+  emitcode ("", IC_INLINE(ic));
 }
 
 /*-----------------------------------------------------------------*/
@@ -942,17 +1062,18 @@ static void genRightShift (iCode * ic) {
 /* genPointerGet - generate code for pointer get                   */
 /*-----------------------------------------------------------------*/
 static void genPointerGet (iCode * ic, iCode *pi) {
-  printIc ("genPointerGet", ic, 1,1,0);
-#if 0
   char *instr, *scratchReg;
   operand *result=IC_RESULT(ic), *left=IC_LEFT(ic);
+  int size;
+
+  printIc ("genPointerGet", ic, 1,1,0);
 
   if (!IS_PTR(operandType(left))) {
     bailOut ("genPointerGet: pointer required");
   }
 
-  aopOp(left,FALSE);
-  aopOp(result,TRUE);
+  aopOp(left,FALSE,FALSE);
+  size=aopOp(result,TRUE,aopIsDir(left));
 
   if (IS_GENPTR(operandType(left))) {
     emitcode (";", "INLINE\t_gptrget ; %s %s = [%s %s]", 
@@ -963,128 +1084,88 @@ static void genPointerGet (iCode * ic, iCode *pi) {
 
   switch (AOP_TYPE(left)) 
     {
-    case AOP_CODE:
-      if (AOP_SIZE(result)==1) {
-       instr=MOVCB;
-      } else {
-       instr=MOVCW;
-      }
-      emitcode (instr, "%s,[%s]", AOP_NAME(result)[0], AOP_NAME(left)[0]);
-      if (AOP_SIZE(result) > 2) {
-       if (AOP_SIZE(result)==3) {
-         instr=MOVCB;
-       } else {
-         instr=MOVCW;
-       }
-       emitcode (instr, "%s,[%s+2]", AOP_NAME(result)[1], AOP_NAME(left)[0]);
-      }
-      return;
-    case AOP_FAR:
-      if (AOP_SIZE(result)==1) {
-       instr=MOVB;
-      } else {
+    case AOP_REG:
+      if (size>1) {
        instr=MOVW;
-      }
-      emitcode (instr, "%s,[%s]", AOP_NAME(result)[0], AOP_NAME(left)[0]);
-      if (AOP_SIZE(result) > 2) {
-       if (AOP_SIZE(result)==3) {
-         instr=MOVB;
-       } else {
-         instr=MOVW;
-       }
-       emitcode (instr, "%s,[%s+2]", AOP_NAME(result)[1], AOP_NAME(left)[0]);
-      }
-      return;
-    case AOP_DIR:
-      if (AOP_SIZE(result)==1) {
-       instr=MOVB;
+       scratchReg=R1;
       } else {
-       instr=MOVW;
-      }
-      emitcode (instr, "%s,%s", AOP_NAME(result)[0], AOP_NAME(left)[0]);
-      if (AOP_SIZE(result) > 2) {
-       if (AOP_SIZE(result)==3) {
-         instr=MOVB;
-       } else {
-         instr=MOVW;
-       }
-       emitcode (instr, "%s,%s+2", AOP_NAME(result)[1], AOP_NAME(left)[0]);
-      }
-      return;
-    case AOP_REG:
-      if (AOP_SIZE(result)==1) {
        instr=MOVB;
-       scratchReg=R0L;
-      } else {
-       instr=MOVW;
-       scratchReg=R0;
+       scratchReg=R1L;
       }
-      // if result=onstack
       if (AOP_TYPE(result)==AOP_STK) {
-       emitcode (instr, "%s,[%s]", scratchReg, AOP_NAME(left)[0]);
-       emitcode (instr, "%s,%s", AOP_NAME(result)[0], scratchReg);
+       emitcode (MOV, "%s,[%s]", scratchReg, AOP_NAME(left)[0]);
+       emitcode (MOV, "%s,%s", AOP_NAME(result)[0], scratchReg);
       } else {
        emitcode (instr, "%s,[%s]", AOP_NAME(result)[0], AOP_NAME(left)[0]);
       }
-      if (AOP_SIZE(result) > 2) {
-       // result is generic pointer
-       sym_link *optype=operandType(left);
-       sym_link *opetype=getSpec(optype);
-       if (IS_PTR(optype) && !IS_GENPTR(optype)) {
-         emitcode (MOVB, "%s,#0x%02x", AOP_NAME(result)[1], 
-                   PTR_TYPE(SPEC_OCLS(opetype)));
-       } else {
-         emitcode (MOVB, "%s,[%s]", AOP_NAME(result)[1], AOP_NAME(left)[1]);
-       }
-      }
-      return;
-    case AOP_STK:
-      // if both on stack
-      if (AOP_TYPE(result)==AOP_STK) {
-       if (AOP_SIZE(result)==1) {
-         emitcode ("mov", "r0l,%s", AOP_NAME(left)[0]);
-         emitcode ("mov", "%s,r0l", AOP_NAME(result)[0]);
-       } else {
-         emitcode ("mov", "r0,%s", AOP_NAME(left)[0]);
-         emitcode ("mov", "%s,r0", AOP_NAME(result)[0]);
-       }
-      } else {
-       if (AOP_SIZE(result)==1) {
-         emitcode ("mov.b", "%s,%s", AOP_NAME(result)[0], AOP_NAME(left)[0]);
-       } else {
-         emitcode ("mov.w", "%s,%s", AOP_NAME(result)[0], AOP_NAME(left)[0]);
+      if (size > 2) {
+       if (size==3) {
+         instr=MOVB;
+         scratchReg=R1L;
        }
-      }
-      if (AOP_SIZE(result) > 2) {
        if (AOP_TYPE(result)==AOP_STK) {
-         if (AOP_SIZE(result)==3) {
-           emitcode ("mov", "r0l,%s", AOP_NAME(left)[1]);
-           emitcode ("mov", "%s,r0l", AOP_NAME(result)[1]);
-         } else {
-           emitcode ("mov", "r0,%s", AOP_NAME(left)[1]);
-           emitcode ("mov", "%s,r0", AOP_NAME(result)[1]);
-         }
+         emitcode (MOV, "%s,[%s+2]", scratchReg, AOP_NAME(left)[0]);
+         emitcode (MOV, "%s,%s", AOP_NAME(result)[1], scratchReg);
        } else {
-         emitcode ("mov", "%s,%s", AOP_NAME(result)[1], AOP_NAME(left)[1]);
+         emitcode (instr, "%s,[%s+2]", AOP_NAME(result)[1], 
+                   AOP_NAME(left)[0]);
        }
       }
       return;
     }
-  bailOut ("genPointerGet: unknown pointer");
-#endif
+  bailOut ("genPointerGet");
 }
 
 /*-----------------------------------------------------------------*/
 /* genPointerSet - stores the value into a pointer location        */
 /*-----------------------------------------------------------------*/
 static void genPointerSet (iCode * ic, iCode *pi) {
+  char *instr;
+  operand *result=IC_RESULT(ic), *right=IC_RIGHT(ic);
+  int size;
+
   printIc ("genPointerSet", ic, 1,0,1);
+
+  if (!IS_PTR(operandType(result))) {
+    bailOut ("genPointerSet: pointer required");
+  }
+
+  aopOp(result,FALSE,FALSE);
+  size=aopOp(right,FALSE, FALSE);
+
+  if (IS_GENPTR(operandType(result))) {
+    emitcode (";", "INLINE\t_gptrset ; [%s %s] = %s %s", 
+             AOP_NAME(result)[0], AOP_NAME(result)[1],
+             AOP_NAME(right)[0], AOP_NAME(right)[1]);
+    return;
+  }
+
+  switch (AOP_TYPE(right)) 
+    {
+    case AOP_LIT:
+    case AOP_REG:
+      if (size>1) {
+       instr=MOVW;
+      } else {
+       instr=MOVB;
+      }
+      emitcode (instr, "[%s],%s", AOP_NAME(result)[0], AOP_NAME(right)[0]);
+      if (size > 2) {
+       if (size==3) {
+         instr=MOVB;
+       }
+       emitcode (instr, "[%s+2],%s", AOP_NAME(result)[0], AOP_NAME(right)[1]);
+      }
+      return;
+    }
+  bailOut ("genPointerSet");
 }
 
 /*-----------------------------------------------------------------*/
 /* genIfx - generate code for Ifx statement                        */
 /*-----------------------------------------------------------------*/
 static void genIfx (iCode * ic, iCode * popIc) {
+  int size;
   char *instr;
   bool trueOrFalse;
   symbol *jlbl, *tlbl;
@@ -1095,7 +1176,7 @@ static void genIfx (iCode * ic, iCode * popIc) {
            IC_TRUE(ic) ? IC_TRUE(ic)->name : "NULL",
            IC_FALSE(ic) ? IC_FALSE(ic)->name : "NULL");
 
-  aopOp(cond,FALSE,FALSE);
+  size=aopOp(cond,TRUE,TRUE);
 
   if (IC_TRUE(ic)) {
     trueOrFalse=TRUE;
@@ -1116,21 +1197,20 @@ static void genIfx (iCode * ic, iCode * popIc) {
     case AOP_FAR:
     case AOP_STK:
       tlbl=newiTempLabel(NULL);
-      if (AOP_SIZE(cond)==1) {
-       instr="cmp.b";
-      } else {
+      if (size>1) {
        instr="cmp.w";
+      } else {
+       instr="cmp.b";
       }
       emitcode (instr, "%s,#0", AOP_NAME(cond)[0]);
       emitcode (trueOrFalse ? "beq" : "bne", "%05d$", tlbl->key+100);
-      if (AOP_SIZE(cond) > 2) {
-       if (AOP_SIZE(cond)==3) {
-         instr="cmp.b";
+      if (size > 2) {
+       if (size==3) {
+         // generic pointer, just consider the pointer part
        } else {
-         instr="cmp.w";
+         emitcode (instr, "%s,#0", AOP_NAME(cond)[1]);
+         emitcode (trueOrFalse ? "beq" : "bne", "%05d$", tlbl->key+100);
        }
-       emitcode (instr, "%s,#0", AOP_NAME(cond)[1]);
-       emitcode (trueOrFalse ? "beq" : "bne", "%05d$", tlbl->key+100);
       }
       emitcode ("jmp", "%05d$", jlbl->key+100);
       emitcode ("", "%05d$:", tlbl->key+100);
@@ -1143,16 +1223,17 @@ static void genIfx (iCode * ic, iCode * popIc) {
 /* genAddrOf - generates code for address of                       */
 /*-----------------------------------------------------------------*/
 static void genAddrOf (iCode * ic) {
+  int size;
   operand *left=IC_LEFT(ic);
 
   printIc ("genAddrOf", ic, 1,1,0);
 
-  aopOp (IC_RESULT(ic),TRUE, FALSE);
+  size=aopOp (IC_RESULT(ic), FALSE, TRUE);
 
   if (isOperandOnStack(left)) {
     emitcode ("lea", "%s,%s", AOP_NAME(IC_RESULT(ic))[0],
              getStackOffset(OP_SYMBOL(left)->stack));
-    if (AOP_SIZE(IC_RESULT(ic)) > 2) {
+    if (size > 2) {
       // this must be a generic pointer
       emitcode ("mov", "%s,#0x%02x", AOP_NAME(IC_RESULT(ic))[1], FPOINTER);
     }
@@ -1164,7 +1245,7 @@ static void genAddrOf (iCode * ic) {
       isOperandInCodeSpace(left)) {
     emitcode ("mov.w", "%s,#%s", AOP_NAME(IC_RESULT(ic))[0],
              OP_SYMBOL(left)->rname);
-    if (AOP_SIZE(IC_RESULT(ic)) > 2) {
+    if (size > 2) {
       // this must be a generic pointer
       int space=0; // dir space
       if (isOperandInFarSpace(left)) {
@@ -1194,8 +1275,8 @@ static void genAssign (iCode * ic) {
     bailOut("genAssign: result is not a symbol");
   }
   
-  aopOp(result, TRUE, FALSE);
-  aopOp(right, FALSE, aopIsPtr(result));
+  aopOp(result, TRUE, TRUE);
+  aopOp(right, !aopIsPtr(result), AOP_TYPE(result)!=AOP_DIR);
   size=AOP_SIZE(result);
 
   /* if result is a bit */
@@ -1221,19 +1302,17 @@ static void genAssign (iCode * ic) {
   }
 
   /* general case */
-  if (size==1) {
-    instr=MOVB;
-  } else {
+  if (size>1) {
     instr=MOVW;
+  } else {
+    instr=MOVB;
   }
   emitcode (instr, "%s,%s", AOP_NAME(result)[0], AOP_NAME(right)[0]);
 
-  if (AOP_SIZE(result) > 2) {
+  if (size > 2) {
     if (size==3) {
       // generic pointer
       instr=MOVB;
-    } else {
-      instr=MOVW;
     }
     emitcode (instr, "%s,%s", AOP_NAME(result)[1], AOP_NAME(right)[1]);
     return;
@@ -1288,7 +1367,7 @@ static bool genDjnz (iCode * ic, iCode * ifx) {
   lbl = newiTempLabel (NULL);
   lbl1 = newiTempLabel (NULL);
 
-  aopOp (IC_RESULT (ic), TRUE, FALSE);
+  aopOp (IC_RESULT (ic), FALSE, TRUE);
 
   if (AOP_TYPE(IC_RESULT(ic))==AOP_REG || AOP_TYPE(IC_RESULT(ic))==AOP_DIR) {
     emitcode ("djnz", "%s,%05d$", AOP_NAME(IC_RESULT(ic)), lbl->key+100);
index 0a465ca1065392da6ebaad963d6943e969a7ef60..f9476de06b5219ad219d15438d817d71363a9269 100755 (executable)
@@ -114,13 +114,7 @@ _xa51_getRegName (struct regs *reg)
 static void
 _xa51_genAssemblerPreamble (FILE * of)
 {
-  // this needs to be an include file someday
-  fputs ("pswl\tsfr\t0x400\n", of);
-  fputs ("z\tbit\tpswl.0\n", of);
-  fputs ("n\tbit\tpswl.1\n", of);
-  fputs ("v\tbit\tpswl.2\n", of);
-  fputs ("ac\tbit\tpswl.6\n", of);
-  fputs ("cy\tbit\tpswl.7\n", of);
+  fprintf (of, "_errno\tsfr\t0x00; to keep the fp-lib's happy for now\n");
 }
 
 /* Generate interrupt vector table. */
@@ -184,7 +178,7 @@ static const char *_linkCmd[] =
 /* $3 is replaced by assembler.debug_opts resp. port->assembler.plain_opts */
 static const char *_asmCmd[] =
 {
-  "xa_asm -dontcomplain", "$l", "$3", "$1.xa", NULL
+  "xa_asm", "$l", "$3", "$1.xa", NULL
 };
 
 /* Globals */
index 66cdeb4fed0ae56e001aafdaa083c1959f9bddb7..cc294a21a23dfc6ed4f90cb0922ed548c0bc2878 100755 (executable)
@@ -203,7 +203,7 @@ static bool allocReg (short size, short type, symbol *sym,
 
   switch (size) 
     {
-      // TODO: gaps should be filled for dwords too
+      // TODO: gaps could be filled for dwords too
     case 1:
       // let's see if we can fill a gap
       for (i=0; i<xa51_nRegs; i++) {
@@ -1030,6 +1030,39 @@ serialRegAssign (eBBlock ** ebbs, int count)
                (IC_RESULT (ic) && POINTER_SET (ic)))
                continue;
 
+#if 0
+           /* xa51 has advance compare instructions */
+           if (ic->op == '<' || ic->op == '>' || 
+               ic->op == LE_OP || ic->op == GE_OP ||
+               ic->op == NE_OP || ic->op == EQ_OP) {
+             /* if this result is only used for an ifx, we don't
+                need registers nor the ifx */
+             int used=bitVectnBitsOn(OP_SYMBOL(IC_RESULT(ic))->uses);
+             iCode *nic;
+             if (used!=1) {
+               fprintf (stderr, "unexpected \"used\" for cmp:%d\n", ic->op);
+               exit (1);
+             }
+             // find the ifx
+             for (nic=ic->next; nic; nic=nic->next) {
+               if (nic->op == IFX) {
+                 break;
+               }
+             }
+             if (!nic) {
+               // we are in big trouble
+               fprintf (stderr, "No ifx found for %d\n",
+                        ic->op);
+               exit (1);
+             }
+             // remove the ifx
+             nic->prev->next=nic->next;
+             if (nic->next) {
+               nic->next->prev=nic->prev;
+             }
+           }
+#endif
+
            /* now we need to allocate registers
               only for the result */
            if (IC_RESULT (ic)) {
@@ -1067,24 +1100,24 @@ serialRegAssign (eBBlock ** ebbs, int count)
                /* if it has a spillocation & is used less than
                   all other live ranges then spill this */
                if (willCS) {
-                   if (sym->usl.spillLoc) {
-                       symbol *leastUsed = leastUsedLR (liveRangesWith (spillable,
-                                                                        allLRs, ebbs[i], ic));
-                       if (leastUsed && leastUsed->used > sym->used) {
-                           spillThis (sym);
-                           continue;
-                       }
-                   } else {
-                       /* if none of the liveRanges have a spillLocation then better
-                          to spill this one than anything else already assigned to registers */
-                       if (liveRangesWith(spillable,noSpilLoc,ebbs[i],ic)) {
-                           /* if this is local to this block then we might find a block spil */
-                           if (!(sym->liveFrom >= ebbs[i]->fSeq && sym->liveTo <= ebbs[i]->lSeq)) {
-                               spillThis (sym);
-                               continue;
-                           }
-                       }
+                 if (sym->usl.spillLoc) {
+                   symbol *leastUsed = leastUsedLR (liveRangesWith (spillable,
+                                                                    allLRs, ebbs[i], ic));
+                   if (leastUsed && leastUsed->used > sym->used) {
+                     spillThis (sym);
+                     continue;
+                   }
+                 } else {
+                   /* if none of the liveRanges have a spillLocation then better
+                      to spill this one than anything else already assigned to registers */
+                   if (liveRangesWith(spillable,noSpilLoc,ebbs[i],ic)) {
+                     /* if this is local to this block then we might find a block spil */
+                     if (!(sym->liveFrom >= ebbs[i]->fSeq && sym->liveTo <= ebbs[i]->lSeq)) {
+                       spillThis (sym);
+                       continue;
+                     }
                    }
+                 }
                }
 
                /* else we assign registers to it */