From 0659e7e1fdcce8778173cef767fc0e086e9fae0a Mon Sep 17 00:00:00 2001 From: tecodev Date: Fri, 8 Aug 2008 18:00:57 +0000 Subject: [PATCH] * src/pic16/genarith.c (genAddLit): fix structure access (#1888004) git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5208 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 4 ++++ src/pic16/genarith.c | 17 ++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index a1ee78da..78943f9b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2008-08-08 Raphael Neider + + * src/pic16/genarith.c (genAddLit): fix structure access (#1888004) + 2008-08-08 Raphael Neider * src/pic/pcoderegs.c, diff --git a/src/pic16/genarith.c b/src/pic16/genarith.c index fbb240bf..1e06e7b9 100644 --- a/src/pic16/genarith.c +++ b/src/pic16/genarith.c @@ -424,19 +424,30 @@ static void genAddLit (iCode *ic, int lit) { int size,same; - int lo; + int lo, offset; operand *result; operand *left; - FENTRY; - + FENTRY; left = IC_LEFT(ic); result = IC_RESULT(ic); same = pic16_sameRegs(AOP(left), AOP(result)); size = pic16_getDataSize(result); + if ((AOP_PCODE == AOP_TYPE(left)) + && (PO_IMMEDIATE == AOP(left)->aopu.pcop->type)) + { + /* see #1888004 for an example case for this */ + for (offset = 0; offset < size; offset++) { + pic16_emitpcode(POC_MOVLW, pic16_newpCodeOpImmd(AOP(left)->aopu.pcop->name, + offset, PCOI(AOP(left)->aopu.pcop)->index + lit, 0)); + pic16_emitpcode(POC_MOVWF, pic16_popGet(AOP(result), offset)); + } // for + return; + } // if + if(same) { /* Handle special cases first */ -- 2.30.2