Am 23.06.2012 15:47, schrieb Borut Ražem:

thanks, I knew who I have to ask for help ;-)

There were many changes since the RC1 release, so I plan to make the RC2 release earlier: 2012-06-24 and make the RC3 at the date RC2 was originally planned: 2012-07-01.

I will apply Raphael's patch immediately since the currently generated code is wrong and it can't be worse with the patch applied. If nobody finds a mistake in the patch, then the RC2 will be made from tomorrow's snapshot builds, if not we will have to decide how to proceed (probably delay the new RC2 date I proposed by few days).

In the mean time: pic14 users please do test!

Works in my case. Thank you all very much.



On Sat, Jun 23, 2012 at 3:10 PM, Raphael Neider <> wrote:

The  cinit_t structure members are read from the program memory, they are
never written. I still think that __code qualifier is ok.

Yep, we just need the symbol to find the cinit-structure in ROM.

Has anybody investigated in which svn revision the bug appeared? If it
was really in rev. 7080, then it is an ugly side effect of optralloc
branch merge :-(

Nope, I did not (yet) search for the first bad revision.

I think this should be fixed ASAP, before the RC2 release, so any help is welcome. Raphael, can you please take a look to this problem?

Done. Please find a patch against r7955 attached.

;       .line   76; "../idata.c"        cptr = &cinit.entry[0];
      MOVLW   high (_cinit + 2)
      MOVWF   r0x1002
      MOVLW   (_cinit + 2)
      MOVWF   r0x1003
      MOVLW   0x80
      MOVWF   r0x1004

Similar code is generated once the above patch is applied.
The code gerenator is/was confusing address calculations and data manipulations: Do we want to read the byte at _cinit and add 2 to the value found there *xor* do we want to read the byte at address (_cinit + 2)?

If anyone with a sufficiently large PIC14 program could confirm that this (a) actually does fix the problem and (b) does not break other stuff, that would be great.
I can confirm that the fix is executed only twice in the PIC14 library code: only in libsdcc/{regular,enhanced}/idata.c. But due to the limited code base, this does not tell us too much.
You can compile your projects with --debug-xtra to see messages like

idata.c:76: CHECK: using address of '_cinit' instead of contents

whenever the fix is used during code generation.