[PIC16F84] SDCC : hex size

  • M Z

    M Z - 2008-05-23

    Hi, im using lastest SDCC(2.8.0), pic16f84, Windown XP :D...

    i using this "tutorial" :http://eis.comp.lancs.ac.uk/~martyn/sdcc_linux/

    when i compile this source code with this command:
    sdcc -mpic14 -p16f84 test.c

    //test.c size:293 b
    #define __16f84

    // Set the __CONFIG word:
    typedef unsigned int word;
    word at 0x2007  __CONFIG = 0x3f72;

    unsigned char count;

    void main(void) {

            TRISA = 0;
            count = 0;
            while(1) {
                    PORTA = count;
                    count ++;

    i get hex file of size: 1,27 kB (1 304 b)...


    ...but original file size have: 156 b


    please where i have wrong? my generated hex file is too large...
    please help :| thx

    • Raphael Neider

      Raphael Neider - 2008-05-25

      The overhead is caused by the initialization code, which is linked in by default to allow the use of initialized global and/or static variables (copies values from code memory to RAM). You can avoid this by defining your own init routine (called once from the RESET vector) as follows:

      /* This function *must* be named "_sdcc_gsinit_startup"! */
      void _sdcc_gsinit_startup(void) {
          pagesel _main
          goto _main

      Adding the above lines brings down the size of the .hex file to 132 bytes in my setup.




Log in to post a comment.

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

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks