I have an impression that __code acts oposite as intendend: if __code is defined, then _cinit is assumed to be in data memory - see the generated asm with BANKSELs, which is wrong.

Omitting "__code" in line 71 is just a (ugly) workaround since "__code cinit_t *cptr" seems to be correct: cptr IS a pointer to cinit_t structure in code section.

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 :-(

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?


On Sat, Jun 23, 2012 at 12:57 AM, Gl Zsolt <tralitoverin@freemail.hu> wrote:
Here is a copy from idata.c:

70 unsigned num, size;
71 __code cinit_t *cptr;
72 __code char *src;
73 __data char *dst;

I think *cptr is not takes place in code memory rather in data memory.
So the __code modifier shouldn't be in line 71. I tried it, and it is
working for me. The generated code is more beautiful:

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