Initialization of __code variables in PIC port

  • Brutte

    Brutte - 2013-04-18

    Initialization of such __code variables crashes a compiler with:

    "Assertion failed: 0, file coff.c, line 100
    This application has requested the Runtime to terminate it in an unusual way."

    But all __data variables initializations work as expected.
    Exemples (commented lines crash when uncommented):

    __data char SramDataString[] = "Ala ma kota.";      //string stored in ram, initiazlied from flash at init (like .data section)
    __data char SramBssString[4];                  //stored in ram but initialized with zeros if linked against crt0iz.
    //__code char FlashString[]= "Kot nie ucieknie.";   //string stored in flash. Crashes with SDCC 3.2
    __data char* __data pInSramToStringInSram = &SramDataString;  //Located in ram points to ram space
    //__data char* __code pInFlashToStringInSram = &SramDataString; //Located in flash space points to data space No good for SDCC
    __code char** __data pInSramToPointerterInFlash;// = &pInFlashToStringInSram;
    __code uint16_t (* __data myfun[])(uint8_t) = {     funA,   //located in ram points to flash(3-byte address)

    I use SDCC 3.2.0 #8008 MinGW
    "C:\Program Files\SDCC\bin\sdcc.exe" --debug-ralloc --use-non-free --pstack-model=small --pcode-verbose --std-sdcc99 --debug -DNO_REG_OPT -I "D:\Documents\Projects\Common" -DDEBUG -L"C:\Program Files\SDCC\lib\pic16" libio18f4455.lib libc18f.lib -c -mpic16 -p18f4455 main.c -obuild/Debug/debug/main.o

    This is my first post in here (well, second as the first vanished). I have searched the sdccman, mailing lists and Discussion archives but no hints about __code were found.
    Am I doing something wrong or is it a bug and I should report it somewhere?

  • Brutte

    Brutte - 2013-05-17

    I have downloaded SDCC 3.3.0 RC3 #8604 and the above __code variables work as expected now!

    __data char* __data pInSramToStringInSram = &SramDataString;  //Located in sram points to sram 
    __data char* __code pInFlashToStringInSram = &SramDataString;   //Located in flash points to sram 
    __code char* __data pInSramToStringInFlash = &FlashString;    //located in sram points to flash
    __code char* __code pInFlashToStringInFlash = &FlashString;    //located in flash points to flash

    Even function pointers located in flash that point to flash work fine:

    __code uint16_t (* __code myfun[])(uint8_t)=...



Log in to post a comment.

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

Sign up for the SourceForge newsletter:

No, thanks