From: michaelh Date: Mon, 8 May 2000 03:11:36 +0000 (+0000) Subject: For gbdk-2.94 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=f4fe6afd73d77df854640914cf1a2a38fdb1befd;p=fw%2Fsdcc For gbdk-2.94 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@243 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/z80/Makefile b/src/z80/Makefile index 2c5ed30b..9d6207c7 100644 --- a/src/z80/Makefile +++ b/src/z80/Makefile @@ -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 diff --git a/src/z80/gen.c b/src/z80/gen.c index c73d1ae2..8d97b83b 100644 --- a/src/z80/gen.c +++ b/src/z80/gen.c @@ -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); diff --git a/src/z80/mappings.i b/src/z80/mappings.i index 1bc2d5fb..53c59338 100644 --- a/src/z80/mappings.i +++ b/src/z80/mappings.i @@ -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+)" }, diff --git a/src/z80/z80.h b/src/z80/z80.h index d8dc33b9..288d91a4 100644 --- a/src/z80/z80.h +++ b/src/z80/z80.h @@ -3,6 +3,7 @@ */ #include "common.h" #include "ralloc.h" +#include "support.h" typedef enum { SUB_Z80,