#2120 [pic14] Bad code generated for "+ 0x102"


As reported by feqin fan on sdcc-devel on 2012-12-31 (found a magic number 0x102----sdcc PIC14 PORT) and confirmed by Gál Zsolt, the following code lacks code for the "+ 0x102" part when compiled with the current svn head:


void main()
int i, temp = 0x100;
for (i=0 ;i<10; i++)
temp = temp + 0x102; // this will be disappear magically.
// I mean the number 0x102 will NOT be added to the temp.
// if the number is other besides 0x102, everything is all right
PORTA = temp; // I konwn only the low 8 bit will be used.


  • Raphael Neider

    Raphael Neider - 2012-12-31
    • milestone: --> fixed
    • status: open --> closed-fixed
  • Raphael Neider

    Raphael Neider - 2012-12-31

    Fixed in #8321.
    The function src/pic14/genarith.c(genAddLit) for generating code to add literals to 16-bit integers is still 340 lines of special cases and likely to contain further bugs. It should probably be rewritten...


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks