when combining (implicit?) string constants and #pragma config, the strings end up right after the CONFIG directives which leads to the following error and warning:
$ sdcc --use-non-free -mpic16 -p18f26j50 config_bug.c
config_bug.asm:485:Error[152] Executable code and data must be defined in an appropriate section.
config_bug.asm:485:Warning[220] Address exceeds maximum range for this processor.
...
$ sdcc -v
SDCC : mcs51/gbz80/z80/z180/r2k/r3ka/ds390/pic16/pic14/TININative/ds400/hc08/s08 3.2.0 #7999 (Jul 3 2012) (Linux)
$ gpasm -v
gpasm-0.14.2 #711 (Jul 3 2012)
from config_bug.asm:
; ; Starting pCode block
CONFIG WDTEN=OFF
; ; Starting pCode block
__str_0:
DB 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x00
note: it might as well be a gputils issue but I presume that 'CONFIG' simply advances to the defined addresses and thus the following string ends up _after_ the config space which of course is bogus.
example code exposing the issue
ugly hack to paper over the issue
a slightly better hack to work around
IMHO the best approach would be to move all the CONFIG directives to the beginning before any actual code is generated (tried that with a new 'config' Map but that didn't work and I'm lost in the sdcc source code :)
Patch sdcc-3.2.0-config_fix.diff applied in svn revision #8008, since it is pic16 specific, it doesn't affect other targets and it is low risk.
The more appropriate 'config' Map approach can be implemented after the SDCC 3.2.0 release, so I'm leaving this bug opened.
Borut
IMHO, I think this bug isn't fixed.
If you modify config_bug.c adding another pragma config like:
#pragma config WDTPS = 1
You see this error again:
$ sdcc --use-non-free -mpic16 -p18f26j50 config_bug.c
config_bug.asm:487:Error[152] Executable code and data must be defined in an appropriate section.
[...]
Useful data:
$ sdcc -v
SDCC : mcs51/gbz80/z80/z180/r2k/r3ka/ds390/pic16/pic14/TININative/ds400/hc08/s08 3.2.0 #8008 (Jul 6 2012) (Linux)
$ gpasm -v
gpasm-0.14.2 #711 (Jul 9 2012)
> IMHO, I think this bug isn't fixed.
Unfortunately this is true. But it was never stated as fixed in an appropriate way, only a temporary patch was applied to make pic18 usable and the bug was not closed.
Workaround for the problem with several #pragma configs is to use a single "all in one" #pragma config.
For example instead using:
#pragma config EBTRB=OFF
#pragma config EBTR3=OFF
#pragma config EBTR2=OFF
#pragma config EBTR1=OFF
you can use:
#pragma config EBTRB=OFF, EBTR3=OFF, EBTR2=OFF, EBTR1=OFF
Borut
Sorry Diego, you are right, the bug "Status" was still "Open", but "Resolution" was "Fixed". Now I changed the "Resolution" back to "None".
Borut