X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fhc08%2Fgen.c;h=9c94f3559b73891c3037ce99b0dc5e295720476e;hb=0694926e60ec83b31f87590e601f7e0d8f86c512;hp=1a71fd2e4e99551f334da00258a41017c20321a4;hpb=feddd68be35917362867a364ba8c51b7986cd67b;p=fw%2Fsdcc diff --git a/src/hc08/gen.c b/src/hc08/gen.c index 1a71fd2e..9c94f355 100644 --- a/src/hc08/gen.c +++ b/src/hc08/gen.c @@ -1352,7 +1352,7 @@ static asmop * aopForRemat (symbol * sym) { iCode *ic = sym->rematiCode; - asmop *aop = newAsmop (AOP_IMMD); + asmop *aop = NULL; int ptr_type=0; int val = 0; @@ -1377,22 +1377,40 @@ aopForRemat (symbol * sym) ic = OP_SYMBOL (IC_LEFT (ic))->rematiCode; } - if (val) - sprintf (buffer, "(%s %c 0x%04x)", - OP_SYMBOL (IC_LEFT (ic))->rname, - val >= 0 ? '+' : '-', - abs (val) & 0xffff); - else - strcpy (buffer, OP_SYMBOL (IC_LEFT (ic))->rname); + if (ic->op == ADDRESS_OF) + { + if (val) + sprintf (buffer, "(%s %c 0x%04x)", + OP_SYMBOL (IC_LEFT (ic))->rname, + val >= 0 ? '+' : '-', + abs (val) & 0xffff); + else + strcpy (buffer, OP_SYMBOL (IC_LEFT (ic))->rname); - aop->aopu.aop_immd.aop_immd1 = Safe_calloc (1, strlen (buffer) + 1); - strcpy (aop->aopu.aop_immd.aop_immd1, buffer); - /* set immd2 field if required */ - if (aop->aopu.aop_immd.from_cast_remat) { + aop = newAsmop (AOP_IMMD); + aop->aopu.aop_immd.aop_immd1 = Safe_calloc (1, strlen (buffer) + 1); + strcpy (aop->aopu.aop_immd.aop_immd1, buffer); + /* set immd2 field if required */ + if (aop->aopu.aop_immd.from_cast_remat) + { sprintf(buffer,"#0x%02x",ptr_type); aop->aopu.aop_immd.aop_immd2 = Safe_calloc (1, strlen (buffer) + 1); strcpy (aop->aopu.aop_immd.aop_immd2, buffer); - } + } + } + else if (ic->op == '=') + { + val += (int) operandLitValue (IC_RIGHT (ic)); + val &= 0xffff; + sprintf (buffer, "0x%04x", val); + aop = newAsmop (AOP_LIT); + aop->aopu.aop_lit = constVal (buffer); + } + else + werror (E_INTERNAL_ERROR, __FILE__, __LINE__, + "unexpected rematerialization"); + + return aop; } @@ -1902,7 +1920,7 @@ aopAdrStr (asmop * aop, int loffset, bool bit16) case AOP_LIT: if (bit16) - return aopLiteralLong (aop->aopu.aop_lit, loffset, 2); + return aopLiteralLong (aop->aopu.aop_lit, /*loffset*/ 0, 2); else return aopLiteral (aop->aopu.aop_lit, loffset); @@ -5356,7 +5374,7 @@ XAccRsh (int shCount, bool sign) ** rola 1 1 bcde fgh0 0000 000a 0 ** lslx 1 1 cdef gh00 0000 000a b ** rola 1 1 cdef gh00 0000 00ab 0 - ** clrx 1 1 0000 0000 0000 000a 0 + ** clrx 1 1 0000 0000 0000 00ab 0 ** total: 6 cycles, 6 bytes */ loadRegFromConst (hc08_reg_x, zero); @@ -5412,12 +5430,12 @@ XAccRsh (int shCount, bool sign) ; } - /* lslx/rola is only 2 cycles and bytes, so an unrolled loop is often */ + /* lsrx/rora is only 2 cycles and bytes, so an unrolled loop is often */ /* the fastest and shortest. */ for (i=0;iremat && + if (p_type == GPOINTER && IS_SYMOP(left) && OP_SYMBOL(left)->remat && IS_CAST_ICODE(OP_SYMBOL(left)->rematiCode)) { left = IC_RIGHT(OP_SYMBOL(left)->rematiCode); type = operandType (left); @@ -6633,6 +6651,7 @@ genPackBits (sym_link * etype, emitcode ("and", "#0x%02x", mask); emitcode ("ora", "1,s"); emitcode ("sta", ",x"); + pullReg (hc08_reg_a); } hc08_freeReg (hc08_reg_a); @@ -7220,6 +7239,10 @@ genDjnz (iCode * ic, iCode * ifx) if (operandLitValue (IC_RIGHT (ic)) != 1) return 0; + /* dbnz doesn't support extended mode */ + if (isOperandInFarSpace (IC_RESULT (ic))) + return 0; + /* if the size of this greater than one then no saving */ // if (getSize (operandType (IC_RESULT (ic))) > 1)