Fixed up z80 port so that it works again
authormichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 3 Sep 2000 02:17:21 +0000 (02:17 +0000)
committermichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 3 Sep 2000 02:17:21 +0000 (02:17 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@345 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCsymt.c
src/altlex.c
src/avr/main.c
src/ds390/main.c
src/mcs51/main.c
src/port.h
src/z80/gen.c
src/z80/main.c

index 40aa386b1d033aaecd954fc2777a3867181b5712..438863d78e330b89fbe8732628ba4a1e41d7db81 100644 (file)
@@ -23,8 +23,6 @@
 
 #include "common.h"
 
-#define ENABLE_MICHAELH_REGPARM_HACK   0
-
 bucket   *SymbolTab [256]  ;  /* the symbol    table  */
 bucket   *StructTab [256]  ;  /* the structure table  */
 bucket   *TypedefTab[256]  ;  /* the typedef   table  */
@@ -1429,20 +1427,6 @@ void  processFuncArgs   (symbol *func, int ignoreName)
            (*port->reg_parm)(val->type)) {
            SPEC_REGPARM(val->etype) = 1;
        }
-
-#if ENABLE_MICHAELH_REGPARM_HACK
-       /* HACK: pull out later */
-       if (
-           (
-            !strcmp(func->name, "memcpy") ||
-            !strcmp(func->name, "strcpy") ||
-            !strcmp(func->name, "strcmp") ||
-            0
-            ) &&
-           port->reg_parm(val->type)) {
-           SPEC_REGPARM(val->etype) = 1;
-       }
-#endif                                         
        
        if ( IS_AGGREGATE(val->type)) {
            /* if this is a structure */
@@ -1896,7 +1880,6 @@ symbol *__conv[2][3][2];
 
 link *floatType;
 
-#if ENABLE_MICHAELH_REGPARM_HACK
 static void _makeRegParam(symbol *sym)
 {
     value *val ;
@@ -1911,7 +1894,6 @@ static void _makeRegParam(symbol *sym)
        val = val->next ;
     }
 }
-#endif
 
 /*-----------------------------------------------------------------*/ 
 /* initCSupport - create functions for C support routines          */
@@ -1987,10 +1969,8 @@ void initCSupport ()
                        sbwd[bwd]);
                __muldiv[muldivmod][bwd][su] = funcOfType(buffer, __multypes[bwd][su], __multypes[bwd][su], 2, options.intlong_rent);
                SPEC_NONBANKED(__muldiv[muldivmod][bwd][su]->etype) = 1;
-#if ENABLE_MICHAELH_REGPARM_HACK
-               if (bwd < 2) 
+               if (bwd < port->muldiv.force_reg_param_below) 
                    _makeRegParam(__muldiv[muldivmod][bwd][su]);
-#endif
            }
        }
     }
index 816b2fad5d8a5b81035bd20842115659eb850e39..6572164eebf6ccb8b4038f5af620c31da4f65816 100644 (file)
@@ -458,6 +458,14 @@ static int _yylex(void)
            *p++ = c;
            c = GETC();
        }
+       if (c == 'U' || c == 'u' || c == 'L' || c == 'l') {
+           *p++ = c;
+           c = GETC();
+       }
+       if (c == 'U' || c == 'u' || c == 'L' || c == 'l') {
+           *p++ = c;
+           c = GETC();
+       }
        *p = '\0';
        UNGETC(c);
        yylval.val = constVal(line);
index 45be337b621adc01b86b159dc626cefac39e32ef..ebd04b14274bc96d787531149d75a6a28e76e078 100644 (file)
@@ -183,7 +183,7 @@ PORT avr_port = {
     },
     /* avr has an 8 bit mul */
     {
-       1
+       1, 0
     },
     "_",
     _avr_init,
index 8920d737ecc5c49344c6dc541c839699635e3e31..88d91e00d7825309556149fcb567d5a3bcbb666a 100644 (file)
@@ -242,7 +242,7 @@ PORT ds390_port = {
     },
     /* ds390 has an 8 bit mul */
     {
-       1
+       1, 0
     },
     "_",
     _ds390_init,
index eded0bfedf0bc79b61340c87df3c2cc4ba088b60..991fb055ac2790f9435bd5303c6866886e77ff3d 100644 (file)
@@ -240,7 +240,7 @@ PORT mcs51_port = {
     },
     /* mcs51 has an 8 bit mul */
     {
-       1
+       1, 0
     },
     "_",
     _mcs51_init,
index 65cfc29da9e752f2f85a4c003c3974e5a14e518d..8a3e6401397bfe15b3dbab94b5c33033bacf2da2 100644 (file)
@@ -107,6 +107,10 @@ typedef struct {
            mul/div operation the processor can do nativley 
            Eg if the processor has an 8 bit mul, nativebelow is 2 */
        int native_below;
+       /** The mul/div/mod functions will be made to use regparams
+           for sizeof(param) < log2(force_reg)
+           i.e. Use 2 for WORD and BYTE, 0 for none. */
+       int force_reg_param_below;
     } muldiv;
 
     /** Prefix to add to a C function (eg "_") */
index 003f59462de5f13ed13cb421e938116baddef41c..2bdd7f38d866f20ce06015c7cacb9dfdeb19362d 100644 (file)
@@ -17,6 +17,7 @@
   Better reg packing, first peephole           20038   163     1873
   With assign packing                          19281   165     1849
   5/3/00                                       17741   185     17B6
+  With reg params for mul and div              16234   202     162D
 
   Michael Hope <michaelh@earthling.net>        2000
   Based on the mcs51 generator - 
@@ -1035,7 +1036,9 @@ static char *aopGet(asmop *aop, int offset, bool bit16)
            tsprintf(s, "!*hl");
        }
        else {
-           tsprintf(s,"!*ixx", aop->aopu.aop_stk+offset);
+           if (aop->aopu.aop_stk >= 0)
+               offset += _G.stack.param_offset;
+           tsprintf(s,"!*ixx ; x", aop->aopu.aop_stk+offset);
        }
        ALLOC_ATOMIC(rs,strlen(s)+1);
        strcpy(rs,s);   
@@ -1171,6 +1174,8 @@ static void aopPut (asmop *aop, const char *s, int offset)
                emit2("ld !*hl,%s", s);
        }
        else {
+           if (aop->aopu.aop_stk >= 0)
+               offset += _G.stack.param_offset;
            if (!canAssignToPtr(s)) {
                emit2("ld a,%s", s);
                emit2("ld !*ixx,a", aop->aopu.aop_stk+offset);
@@ -2625,7 +2630,7 @@ static void genIfxJump (iCode *ic, char *jval)
     ic->generated = 1;
 }
 
-const char *getPairIdName(PAIR_ID id)
+static const char *_getPairIdName(PAIR_ID id)
 {
     return _pairs[id].name;
 }
@@ -2668,9 +2673,11 @@ static void genCmp (operand *left,operand *right,
                        Load -lit into HL, add to right via, check sense.
            */
            if (size == 2 && (AOP_TYPE(right) == AOP_LIT || AOP_TYPE(left) == AOP_LIT)) {
+               PAIR_ID id = PAIR_DE;
                asmop *lit = AOP(right);
                asmop *op = AOP(left);
                swap_sense = TRUE;
+
                if (AOP_TYPE(left) == AOP_LIT) {
                    swap_sense = FALSE;
                    lit = AOP(left);
@@ -2682,8 +2689,16 @@ static void genCmp (operand *left,operand *right,
                    emit2("xor a,!immedbyte", 0x80);
                    emit2("ld d,a");
                }
+               else {
+                   id = getPairId(op);
+                   if (id == PAIR_INVALID) {
+                       fetchPair(PAIR_DE, op);
+                       id = PAIR_DE;
+                   }
+               }
+               spillPair(PAIR_HL);
                emit2("ld hl,%s", fetchLitSpecial(lit, TRUE, sign));
-               emit2("add hl,de");
+               emit2("add hl,%s", _getPairIdName(id));
                goto release;
            }
             if(AOP_TYPE(right) == AOP_LIT) {
@@ -4404,7 +4419,10 @@ static void genAddrOf (iCode *ic)
        spillCached();
        if (sym->onStack) {
            /* if it has an offset  then we need to compute it */
-           emitcode("ld", "hl,#%d+%d+%d", sym->stack, _G.stack.pushed, _G.stack.offset);
+           if (sym->stack > 0) 
+               emitcode("ld", "hl,#%d+%d+%d+%d", sym->stack, _G.stack.pushed, _G.stack.offset, _G.stack.param_offset);
+           else
+               emitcode("ld", "hl,#%d+%d+%d", sym->stack, _G.stack.pushed, _G.stack.offset);
            emitcode("add", "hl,sp");
        }
        else {
index 53f097865fcb27c2165c2c02be8f58dd73d0d577..e48ed3e21bc5a34c4e36e3028cabf02a34dd51df 100644 (file)
@@ -260,7 +260,7 @@ static const char *_z80_linkCmd[] = {
 };
 
 static const char *_z80_asmCmd[] = {
-    "as-z80", "-plosgff", "$1.asm", NULL
+    "as-z80", "-plosgff", "$1.o", "$1.asm", NULL
 };
 
 /** $1 is always the basename.
@@ -325,7 +325,7 @@ PORT z80_port = {
     },
     /* Z80 has no native mul/div commands */
     {  
-       0
+       0, 2
     },
     "_",
     _z80_init,
@@ -392,7 +392,7 @@ PORT gbz80_port = {
     },
     /* gbZ80 has no native mul/div commands */
     {  
-       0
+       0, 2
     },
     "_",
     _gbz80_init,