Menu

#2058 #pragma config and certain string constants

closed-fixed
5
2017-12-27
2012-07-03
No

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.

Discussion

1 2 3 > >> (Page 1 of 3)
  • Herbert Pötzl

    Herbert Pötzl - 2012-07-03

    example code exposing the issue

     
  • Herbert Pötzl

    Herbert Pötzl - 2012-07-03

    ugly hack to paper over the issue

     
  • Herbert Pötzl

    Herbert Pötzl - 2012-07-03

    a slightly better hack to work around

     
  • Herbert Pötzl

    Herbert Pötzl - 2012-07-03

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

     
  • Borut Ražem

    Borut Ražem - 2012-07-06
    • assigned_to: nobody --> borutr
    • status: open --> open-fixed
     
  • Borut Ražem

    Borut Ražem - 2012-07-06

    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

     
  • Diego Herranz

    Diego Herranz - 2012-07-10

    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)

     
  • Borut Ražem

    Borut Ražem - 2012-07-10

    > 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

     
  • Borut Ražem

    Borut Ražem - 2012-07-10
    • status: open-fixed --> open
     
  • Borut Ražem

    Borut Ražem - 2012-07-10

    Sorry Diego, you are right, the bug "Status" was still "Open", but "Resolution" was "Fixed". Now I changed the "Resolution" back to "None".

    Borut

     
1 2 3 > >> (Page 1 of 3)

Log in to post a comment.