From 14da40833876a10a8e4b4a581e790a6586d35d5f Mon Sep 17 00:00:00 2001 From: MaartenBrock Date: Thu, 6 Jul 2006 21:24:36 +0000 Subject: [PATCH] * src/hc08/gen.c (genAddrOf): fixed bug when offset on stack is >127 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4273 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 4 ++++ src/hc08/gen.c | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 58ba8339..88260213 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2006-07-06 Maarten Brock + + * src/hc08/gen.c (genAddrOf): fixed bug when offset on stack is >127 + 2006-07-06 Borut Razem * support/regression/tests/bitfields.c: diff --git a/src/hc08/gen.c b/src/hc08/gen.c index 7b6009ed..d1fdc98d 100644 --- a/src/hc08/gen.c +++ b/src/hc08/gen.c @@ -7786,11 +7786,21 @@ genAddrOf (iCode * ic) variable */ if (sym->onStack) { - /* if it has an offset then we need to compute - it */ + /* if it has an offset then we need to compute it */ + offset = _G.stackOfs + _G.stackPushes + sym->stack; hc08_useReg (hc08_reg_hx); emitcode ("tsx", ""); - emitcode ("aix", "#%d", _G.stackOfs + _G.stackPushes +sym->stack); + while (offset > 127) + { + emitcode ("aix", "#127"); + offset -= 127; + } + while (offset < -128) + { + emitcode ("aix", "#-128"); + offset += 128; + } + emitcode ("aix", "#%d", offset); storeRegToFullAop (hc08_reg_hx, AOP (IC_RESULT (ic)), FALSE); hc08_freeReg (hc08_reg_hx); -- 2.30.2