From 3c54611818c1ca56b3ae06ef14b5872982fe754a Mon Sep 17 00:00:00 2001 From: michaelh Date: Wed, 5 Apr 2000 03:45:42 +0000 Subject: [PATCH] For gbdk-2.94. Seems to work. git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@220 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/asm.c | 4 ++-- src/z80/gen.c | 19 ++++++++++++------- src/z80/main.c | 46 +++++++++++++++++++++++----------------------- src/z80/mappings.i | 2 +- 4 files changed, 38 insertions(+), 33 deletions(-) diff --git a/src/asm.c b/src/asm.c index 998e8f76..0b954512 100644 --- a/src/asm.c +++ b/src/asm.c @@ -148,8 +148,8 @@ static const ASM_MAPPING _asxxxx_mapping[] = { { "immedword", "#0x%04X" }, { "immedbyte", "#0x%02X" }, { "hashedstr", "#%s" }, - { "lsbimmeds", "#<%s" }, - { "msbimmeds", "#>%s" }, + { "lsbimmeds", "#>%s" }, + { "msbimmeds", "#<%s" }, { "module", ".module %s" }, { "global", ".globl %s" }, { "fileprelude", "" }, diff --git a/src/z80/gen.c b/src/z80/gen.c index e86cc75b..b0e206a9 100644 --- a/src/z80/gen.c +++ b/src/z80/gen.c @@ -685,7 +685,7 @@ char *aopGetLitWordLong(asmop *aop, int offset, bool with_hash) case AOP_IMMD: /* PENDING: for re-target */ if (with_hash) - tsprintf(s, "!hashed", aop->aopu.aop_immd); + tsprintf(s, "!hashedstr", aop->aopu.aop_immd); else strcpy(s, aop->aopu.aop_immd); ALLOC_ATOMIC(rs,strlen(s)+1); @@ -1027,7 +1027,7 @@ static void aopPut (asmop *aop, char *s, int offset) case AOP_HL: wassert(IS_GB); /* PENDING: for re-target */ - if (!strcmp(s, "!*hl")) { + if (!strcmp(s, "!*hl") || !strcmp(s, "(hl)") || !strcmp(s, "[hl]")) { emit2("ld a,!*hl"); s = "a"; } @@ -1039,7 +1039,7 @@ static void aopPut (asmop *aop, char *s, int offset) case AOP_STK: if (IS_GB) { /* PENDING: re-target */ - if (!strcmp("!*hl", s)) { + if (!strcmp(s, "!*hl") || !strcmp(s, "(hl)") || !strcmp(s, "[hl]")) { emit2("ld a,!*hl"); s = "a"; } @@ -1493,7 +1493,7 @@ static void emitCall (iCode *ic, bool ispcall) _G.stack.pushed += 2; fetchHL(AOP(IC_LEFT(ic))); - emit2("jp", "!*hl"); + emit2("jp !*hl"); emit2("!tlabeldef", (rlbl->key+100)); _G.stack.pushed -= 2; } @@ -1595,6 +1595,8 @@ static void genFunction (iCode *ic) nregssaved = 0; /* create the function header */ emit2("!functionheader", sym->name); + /* PENDING: portability. */ + emit2("__%s_start:", sym->rname); emit2("!functionlabeldef", sym->rname); fetype = getSpec(operandType(IC_LEFT(ic))); @@ -1652,6 +1654,8 @@ static void genEndFunction (iCode *ic) emit2("!leavex", _G.stack.offset); else emit2("!leave"); + /* PENDING: portability. */ + emit2("__%s_end:", sym->rname); } _G.stack.pushed = 0; _G.stack.offset = 0; @@ -2772,9 +2776,10 @@ static void genAnd (iCode *ic, iCode *ifx) wassert(0); } else { - MOVA(aopGet(AOP(right),offset,FALSE)); - emitcode("and","%s,a", - aopGet(AOP(left),offset,FALSE)); + MOVA(aopGet(AOP(left),offset,FALSE)); + emitcode("and","a,%s", + aopGet(AOP(right),offset,FALSE)); + emitcode("ld", "%s,a", aopGet(AOP(left),offset,FALSE)); } } } diff --git a/src/z80/main.c b/src/z80/main.c index 17e5bc23..6ad0e012 100644 --- a/src/z80/main.c +++ b/src/z80/main.c @@ -27,7 +27,7 @@ static void _z80_init(void) static void _gbz80_init(void) { z80_opts.sub = SUB_GBZ80; - asm_addTree(&_rgbds_gb); + asm_addTree(&_asxxxx_gb); } static int regParmFlg = 0; /* determine if we can register a parameter */ @@ -145,17 +145,17 @@ PORT z80_port = { 1, 1, 2, 4, 2, 2, 2, 1, 4, 4 }, { - "XSEG", - "STACK", - "CODE", - "DATA", - "ISEG", - "XSEG", - "BSEG", - "RSEG", - "GSINIT", - "OVERLAY", - "GSFINAL", + "_XSEG", + "_STACK", + "_CODE", + "_DATA", + "_ISEG", + "_XSEG", + "_BSEG", + "_RSEG", + "_GSINIT", + "_OVERLAY", + "_GSFINAL", NULL, NULL, 1 @@ -203,17 +203,17 @@ PORT gbz80_port = { 1, 1, 2, 4, 2, 2, 2, 1, 4, 4 }, { - "XSEG", - "STACK", - "CODE", - "DATA", - "ISEG", - "XSEG", - "BSEG", - "RSEG", - "GSINIT", - "OVERLAY", - "GSFINAL", + "_XSEG", + "_STACK", + "_CODE", + "_DATA", + "_ISEG", + "_XSEG", + "_BSEG", + "_RSEG", + "_GSINIT", + "_OVERLAY", + "_GSFINAL", NULL, NULL, 1 diff --git a/src/z80/mappings.i b/src/z80/mappings.i index c2755211..649f7983 100644 --- a/src/z80/mappings.i +++ b/src/z80/mappings.i @@ -9,7 +9,7 @@ static const ASM_MAPPING _asxxxx_gb_mapping[] = { { "enter", "push bc" }, { "enterx", "push bc\n" - "lda sp,-%d(sp)" }, + "\tlda sp,-%d(sp)" }, { "leave", "pop bc\n" "\tret" -- 2.47.2