From: epetrich Date: Sun, 28 Mar 2004 01:44:31 +0000 (+0000) Subject: * src/hc08/gen.c (genPointerGetSetOfs): correctly handle 1 byte array X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=6a66f4dc1432cba80cf14749ab6351db5de58d47;p=fw%2Fsdcc * src/hc08/gen.c (genPointerGetSetOfs): correctly handle 1 byte array offsets (fixes bug #923936) git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3279 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index cac9f928..54f042f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-03-28 Erik Petrich + + * src/hc08/gen.c (genPointerGetSetOfs): correctly handle 1 byte array + offsets (fixes bug #923936) + 2004-03-26 Bernhard Held * device/lib/small/Makefile: fixed parallel execution by diff --git a/src/hc08/gen.c b/src/hc08/gen.c index b515ed79..c02688b5 100644 --- a/src/hc08/gen.c +++ b/src/hc08/gen.c @@ -4239,6 +4239,7 @@ genPointerGetSetOfs (iCode *ic) if (!sym->remat) return FALSE; + if (pget) { D(emitcode ("; genPointerGetOfs","")); @@ -4248,9 +4249,27 @@ genPointerGetSetOfs (iCode *ic) aopOp (IC_RIGHT(ic), ic, FALSE); aopOp (IC_RESULT(lic), lic, FALSE); - - loadRegFromAop (hc08_reg_hx, AOP (IC_RIGHT (ic)), 0); + if (AOP_SIZE (IC_RIGHT (ic)) == 1) + { + if (SPEC_USIGN (getSpec (operandType (IC_RIGHT (ic))))) + { + loadRegFromAop (hc08_reg_x, AOP (IC_RIGHT (ic)), 0); + loadRegFromConst (hc08_reg_h, zero); + } + else + { + loadRegFromAop (hc08_reg_a, AOP (IC_RIGHT (ic)), 0); + transferRegReg (hc08_reg_a, hc08_reg_x, FALSE); + emitcode ("rola",""); + emitcode ("clra",""); + emitcode ("sbc", "#0"); + hc08_useReg (hc08_reg_a); + transferRegReg (hc08_reg_a, hc08_reg_h, FALSE); + } + } + else + loadRegFromAop (hc08_reg_hx, AOP (IC_RIGHT (ic)), 0); size = AOP_SIZE (IC_RESULT(lic)); derefaop->size = size; offset=0; @@ -4284,8 +4303,26 @@ genPointerGetSetOfs (iCode *ic) aopOp (IC_RIGHT(ic), ic, FALSE); aopOp (IC_RIGHT(lic), lic, FALSE); - - loadRegFromAop (hc08_reg_hx, AOP (IC_RIGHT (ic)), 0); + if (AOP_SIZE (IC_RIGHT (ic)) == 1) + { + if (SPEC_USIGN (getSpec (operandType (IC_RIGHT (ic))))) + { + loadRegFromAop (hc08_reg_x, AOP (IC_RIGHT (ic)), 0); + loadRegFromConst (hc08_reg_h, zero); + } + else + { + loadRegFromAop (hc08_reg_a, AOP (IC_RIGHT (ic)), 0); + transferRegReg (hc08_reg_a, hc08_reg_x, FALSE); + emitcode ("rola",""); + emitcode ("clra",""); + emitcode ("sbc", "#0"); + hc08_useReg (hc08_reg_a); + transferRegReg (hc08_reg_a, hc08_reg_h, FALSE); + } + } + else + loadRegFromAop (hc08_reg_hx, AOP (IC_RIGHT (ic)), 0); size = AOP_SIZE (IC_RIGHT(lic)); derefaop->size = size; offset=0;