For gbdk-2.94. Seems to work.
authormichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 5 Apr 2000 03:45:42 +0000 (03:45 +0000)
committermichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 5 Apr 2000 03:45:42 +0000 (03:45 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@220 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/asm.c
src/z80/gen.c
src/z80/main.c
src/z80/mappings.i

index 998e8f76f78a5ed6dd8657490b07aa5fe75b9dbd..0b9545127f1e16c698bebaf4ced6ee6220d192f5 100644 (file)
--- 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", "" },
index e86cc75befd3b8d282d90519c0062091ff76b950..b0e206a98aa5287e96c0bbdf3f31fab6fc5f77fa 100644 (file)
@@ -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));
                }
             }
         }
index 17e5bc230ebbcacd56ec3433bdd6e119e23b7094..6ad0e012200d8a44746dfd872d99b17770f3950c 100644 (file)
@@ -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
index c27552119837203bfef240e2558afb2ac6393c2b..649f79832ec6a2d6e4d29f1ea812ff76e4abc1f5 100644 (file)
@@ -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"