]> git.gag.com Git - fw/sdcc/commitdiff
Hacked bug re: pointer get.
authormichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 23 Feb 2000 03:05:46 +0000 (03:05 +0000)
committermichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 23 Feb 2000 03:05:46 +0000 (03:05 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@119 4a8a32a2-be11-0410-ad9d-d568d2c75423

doc/choices.txt [new file with mode: 0644]
src/SDCCglue.c
src/z80/gen.c
src/z80/ralloc.c

diff --git a/doc/choices.txt b/doc/choices.txt
new file mode 100644 (file)
index 0000000..080b0cf
--- /dev/null
@@ -0,0 +1,38 @@
+Some of the implementation choices
+----------------------------------
+
+gbz80:
+
+Load from direct space:
+  Alternatives:
+  1.  Via HL
+       ld hl,#dir
+       ld x,(hl)
+       inc hl
+       ld y,(hl)
+  2.  Via a
+       ld a,(dir)
+       ld x,a
+       ld a,(dir+1)
+       ld x,a
+  1 is bad when x or y involve HL (1b)
+                                       8       16      32
+     1 = 12 + n*(8+8) - 8              20      36      68
+     1b = n*(12+12+8)                  32      64      128
+     2 = n*(16+4)                      20      40      80
+  So choose 2.
+
+  Hmm.  (2) is too hard to support in the current model.
+
+On stack word push
+   1.   lda  hl,x(sp)
+        ld   a,(hl+)
+        ld   h,(hl)
+        ld   l,a
+        push hl
+   2.   lda  hl,x(sp)
+        ld   e,(hl)
+        inc  hl
+        ld   d,(hl)
+   1 = d + 8 + 8 + 4
+   2 = d + 8 + 8 + 8
\ No newline at end of file
index 31d54db58d89ac1ea92648a81e7a6718be0e6639..28997cc2b2f641946abac7dced56f36db5eaead4 100644 (file)
@@ -1044,7 +1044,8 @@ void glue ()
        
     }
     copyFile (asmFile, statsg->oFile);
-    fprintf (asmFile,"\tljmp\t__sdcc_program_startup\n");
+    if (port->general.glue_up_main)
+       fprintf (asmFile,"\tljmp\t__sdcc_program_startup\n");
 
     /* copy over code */
     fprintf (asmFile, "%s", iComments2);
index a46c959d975a03c6b3332235feb6aacfeaacefcc..da152c0b2aab2135ddc0eb402cb5bbc67a061370 100644 (file)
@@ -632,6 +632,7 @@ static char *aopGet (asmop *aop, int offset, bool bit16)
     char *rs;
 
     /* offset is greater than size then zero */
+    /* PENDING: this seems a bit screwed in some pointer cases. */
     if (offset > (aop->size - 1) &&
         aop->type != AOP_LIT)
         return zero;
@@ -1361,6 +1362,7 @@ static void genFunction (iCode *ic)
     emitcode(";","-----------------------------------------");
 
     emitcode("","%s:",sym->rname);
+    emitcode("", "__%s_start:", sym->rname);
     fetype = getSpec(operandType(IC_LEFT(ic)));
 
     /* if critical function then turn interrupts off */
@@ -1443,6 +1445,7 @@ static void genEndFunction (iCode *ic)
        }
        emitcode("pop", "bc");
        emitcode("ret", "");
+       emitcode("", "__%s_end:", sym->rname);
     }
     _pushed = 0;
     _spoffset = 0;
@@ -2027,15 +2030,16 @@ static void genCmp (operand *left,operand *right,
            }
             while (size--) {
                /* Do a long subtract */
-               if (!sign || size
+               if (!sign || size ) {
                    MOVA(aopGet(AOP(left),offset,FALSE));
+               }
                 if (sign && size == 0) {
                    emitcode("ld", "a,%s", _fTmp[0]);
                    emitcode("sbc", "a,%s", _fTmp[1]);
                }
                else {
                    /* Subtract through, propagating the carry */
-                   emitcode("sbc","a,%s",aopGet(AOP(right),offset++,FALSE));
+                   emitcode("sbc","a,%s ; 2",aopGet(AOP(right),offset++,FALSE));
                }
             }
         }
@@ -2648,10 +2652,12 @@ static void genOr (iCode *ic, iCode *ifx)
             if(AOP_TYPE(right) == AOP_LIT){
                 if(((lit >> (offset*8)) & 0x0FFL) == 0x00L)
                     continue;
-                else 
-                   emitcode("or","%s,%s; 5",
-                            aopGet(AOP(left),offset,FALSE),
-                            aopGet(AOP(right),offset,FALSE));
+                else {
+                   MOVA(aopGet(AOP(right),offset,FALSE));
+                   emitcode("or","a,%s; 5",
+                            aopGet(AOP(left),offset,FALSE));
+                   aopPut(AOP(result),"a ; 8", offset);
+               }
             } else {
                if (AOP_TYPE(left) == AOP_ACC) 
                    emitcode("or","a,%s ; 6",aopGet(AOP(right),offset,FALSE));
@@ -3394,8 +3400,16 @@ static void genGenPointerGet (operand *left,
        emitcode("ld","%s,%s", ptr, aopGet(AOP(left),0,TRUE));
     else { /* we need to get it byte by byte */
        if (IS_GB) {
-           emitcode("ld", "e,%s", aopGet(AOP(left), 0, FALSE));
-           emitcode("ld", "d,%s", aopGet(AOP(left), 1, FALSE));
+           bool hack = 0;
+           /* PENDING: hack */
+           if (AOP_SIZE(left) == 1) {
+               hack = 1;
+               AOP_SIZE(left) = 2;
+           }
+           emitcode("ld", "e,%s ; 1", aopGet(AOP(left), 0, FALSE));
+           emitcode("ld", "d,%s ; 2", aopGet(AOP(left), 1, FALSE));
+           if (hack)
+               AOP_SIZE(left) = 1;
        }
        else
            fetchHL(AOP(left));
index 2a758fde3128f85b4fa1222fd1e910ce34c30656..330de6b4c1a24116aa9fa0afb18f19f660d91d3e 100644 (file)
@@ -2076,15 +2076,17 @@ static void packRegisters (eBBlock *ebp)
            getSize(operandType(IC_RESULT(ic))) <= 2)
            packRegsForAccUse (ic);
 #else
-       if ((POINTER_GET(ic) ||
-            IS_ARITHMETIC_OP(ic) ||
-            IS_BITWISE_OP(ic) ||
-            ic->op == LEFT_OP ||
-            ic->op == RIGHT_OP
-            ) &&
-           IS_ITEMP(IC_RESULT(ic)) &&
-           getSize(operandType(IC_RESULT(ic))) == 1)
-           packRegsForAccUse2(ic);
+       if (!IS_GB) {
+           if ((POINTER_GET(ic) ||
+                IS_ARITHMETIC_OP(ic) ||
+                IS_BITWISE_OP(ic) ||
+                ic->op == LEFT_OP ||
+                ic->op == RIGHT_OP
+                ) &&
+               IS_ITEMP(IC_RESULT(ic)) &&
+               getSize(operandType(IC_RESULT(ic))) == 1)
+               packRegsForAccUse2(ic);
+       }
 #endif
     }
 }