For gbdk-2.94
authormichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 8 May 2000 03:11:36 +0000 (03:11 +0000)
committermichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 8 May 2000 03:11:36 +0000 (03:11 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@243 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/z80/Makefile
src/z80/gen.c
src/z80/mappings.i
src/z80/z80.h

index 2c5ed30bc89d670db170cb8fd428057a7733dd28..9d6207c724dffbc6ef1b9b06285cf2962025bb3e 100644 (file)
@@ -2,7 +2,7 @@ PRJDIR = ../..
 
 include $(PRJDIR)/Makefile.common
 
-OBJ = gen.o ralloc.o main.o
+OBJ = gen.o ralloc.o main.o support.o
 LIB = port.a
 
 CFLAGS = -ggdb -Wall
index c73d1ae22a70175bff287e0ab4deeba2cbdbc190..8d97b83b5854114ed1a0e8fabebe74f828f8638c 100644 (file)
@@ -680,8 +680,6 @@ char *aopGetLitWordLong(asmop *aop, int offset, bool with_hash)
     if (aop->size != 2 && aop->type != AOP_HL)
        return NULL;
 #endif
-    wassert(offset == 0);
-
     /* depending on type */
     switch (aop->type) {
     case AOP_HL:
@@ -689,9 +687,9 @@ char *aopGetLitWordLong(asmop *aop, int offset, bool with_hash)
     case AOP_IMMD:
        /* PENDING: for re-target */
        if (with_hash)
-           tsprintf(s, "!hashedstr", aop->aopu.aop_immd);
+           tsprintf(s, "!hashedstr + %d", aop->aopu.aop_immd, offset);
        else
-           strcpy(s, aop->aopu.aop_immd);
+           tsprintf(s, "%s + %d", aop->aopu.aop_immd, offset);
        ALLOC_ATOMIC(rs,strlen(s)+1);
        strcpy(rs,s);   
        return rs;
@@ -701,6 +699,8 @@ char *aopGetLitWordLong(asmop *aop, int offset, bool with_hash)
        /* otherwise it is fairly simple */
        if (!IS_FLOAT(val->type)) {
            unsigned long v = floatFromVal(val);
+           if (offset == 2)
+               v >>= 16;
            if (with_hash)
                tsprintf(buffer, "!immedword", v);
            else
@@ -708,8 +708,17 @@ char *aopGetLitWordLong(asmop *aop, int offset, bool with_hash)
            ALLOC_ATOMIC(rs,strlen(buffer)+1);
            return strcpy (rs,buffer);
        }
-       wassert(0);
-       return NULL;
+       else {
+           /* A float */
+           Z80_FLOAT f;
+           convertFloat(&f, floatFromVal(val));
+           if (with_hash) 
+               tsprintf(buffer, "!immedword", f.w[offset/2]);
+           else
+               tsprintf(buffer, "!constword", f.w[offset/2]);
+           ALLOC_ATOMIC(rs,strlen(buffer)+1);
+           return strcpy (rs,buffer);
+       }
     }
     default:
        return NULL;
@@ -773,7 +782,7 @@ static void fetchLitPair(PAIR_ID pairId, asmop *left, int offset)
 {
     const char *l;
     const char *pair = _pairs[pairId].name;
-    l = aopGetLitWordLong(left, 0, FALSE);
+    l = aopGetLitWordLong(left, offset, FALSE);
     wassert(l && pair);
 
     if (isPtr(pair)) {
@@ -796,9 +805,11 @@ static void fetchLitPair(PAIR_ID pairId, asmop *left, int offset)
     }
     /* Both a lit on the right and a true symbol on the left */
     /* PENDING: for re-target */
+#if 0
     if (offset)
        emit2("ld %s,!hashedstr + %d", pair, l, offset);
     else 
+#endif
        emit2("ld %s,!hashedstr", pair, l);
 }
 
@@ -865,11 +876,6 @@ static void setupPair(PAIR_ID pairId, asmop *aop, int offset)
     _G.pairs[pairId].last_type = aop->type;
 }
 
-static void emitIntLabel(int key)
-{
-    emit2("!tlabeldef", key);
-}
-
 static void emitLabel(int key)
 {
     emit2("!tlabeldef", key);
@@ -1350,8 +1356,10 @@ void assignResultValue(operand * oper)
     wassert(size <= 4);
     topInA = requiresHL(AOP(oper));
 
+#if 0
     if (!IS_GB)
        wassert(size <= 2);
+#endif
     if (IS_GB && size == 4 && requiresHL(AOP(oper))) {
        /* We do it the hard way here. */
        emitcode("push", "hl");
@@ -1427,6 +1435,17 @@ static void genIpush (iCode *ic)
            _G.stack.pushed += 2;
            goto release;
        }
+       if (size == 4) {
+           fetchPairLong(PAIR_HL, AOP(IC_LEFT(ic)), 2);
+           emitcode("push", "hl");
+           spillPair(PAIR_HL);
+           _G.stack.pushed += 2;
+           fetchPairLong(PAIR_HL, AOP(IC_LEFT(ic)), 0);
+           emitcode("push", "hl");
+           spillPair(PAIR_HL);
+           _G.stack.pushed += 2;
+           goto release;
+       }
        offset = size;
        while (size--) {
            l = aopGet(AOP(IC_LEFT(ic)), --offset, FALSE);
index 1bc2d5fbb81655e4bb991099adc00f468000dcf1..53c593385fbc7f578fb74f3d5f5766da2036b23b 100644 (file)
@@ -35,6 +35,8 @@ static const ASM_MAPPING _asxxxx_gb_mapping[] = {
 };
 
 static const ASM_MAPPING _asxxxx_z80_mapping[] = {
+    { "*ixx", "%d(ix)" },
+    { "*iyx", "%d(iy)" },
     { "*hl", "(hl)" },
     { "di", "di" },
     { "ldahli", "ld a,(hl+)" },
index d8dc33b9eb92d66d8a6215a161ee8df6fa1c4b6c..288d91a42ea404a53995cf028a02138890dcc0c0 100644 (file)
@@ -3,6 +3,7 @@
 */
 #include "common.h"
 #include "ralloc.h"
+#include "support.h"
 
 typedef enum {
     SUB_Z80,