From: michaelh Date: Wed, 23 Feb 2000 03:05:46 +0000 (+0000) Subject: Hacked bug re: pointer get. X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=a408f6fc31450c42a558611971841af32c4edff4;p=fw%2Fsdcc Hacked bug re: pointer get. git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@119 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/doc/choices.txt b/doc/choices.txt new file mode 100644 index 00000000..080b0cf2 --- /dev/null +++ b/doc/choices.txt @@ -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 diff --git a/src/SDCCglue.c b/src/SDCCglue.c index 31d54db5..28997cc2 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -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); diff --git a/src/z80/gen.c b/src/z80/gen.c index a46c959d..da152c0b 100644 --- a/src/z80/gen.c +++ b/src/z80/gen.c @@ -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)); diff --git a/src/z80/ralloc.c b/src/z80/ralloc.c index 2a758fde..330de6b4 100644 --- a/src/z80/ralloc.c +++ b/src/z80/ralloc.c @@ -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 } }