Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

[PIC16F84] SDCC : hex size

Help
M Z
2008-05-23
2013-03-12
  • 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
    #include"pic/pic16f84.h"

    // 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)...

    :020000040000FA
    :0400000000000528CF
    :06000A00D6309A00003020
    :100010009B00803000000000AC2000000000831234
    :1000200000009D001B089C00D8309E0000309F00FF
    :10003000831200001C08A0001D08A100FF309C07CF
    :10004000031C9D03200821040319952804301E0772
    :10005000A000A101A10D1F08A10720089A002108F6
    :100060009B00803000000000AC20000000008312E4
    :100070000000A3001B08A2001E089A001F089B0096
    :10008000803000000000AC2000000000831200005F
    :10009000A500A1001B08A400A00002301E07A000BC
    :1000A000A101A10D1F08A10720089A0021089B00AB
    :1000B000803000000000AC2000000000831200002F
    :1000C000A100A7001B08A000A600831200002208C0
    :1000D000A6002308A700FF30A207031CA3032608DD
    :1000E000270403198E2824089A0025089B008030D5
    :1000F0000000000099200000000083120000A6000C
    :100100002008840083132118831726088000A40A7E
    :100110000319A50AA00A0319A10A6528063083124B
    :1001200000009E0703189F0A182800000000CD2831
    :100130000800003A0319A028803A0319A7280034C0
    :100140001A08840083131B188317000808001B0873
    :100150008A001A0882000800003A0319B428803A7D
    :100160000319BE289B0100341A08840083131B184E
    :10017000831700089B00840A0008080000000000A4
    :10018000A72099009A0F9B039B0A00000000A7205C
    :10019000980019089B001808080083168501A8011B
    :1001A000280883128500A80AD028080001340034EA
    :0E01B000DE34003429340034013400340034CD
    :02400E00723FFF
    :00000001FF

    ...but original file size have: 156 b

    :020000040000FA
    :0400000000000428D0
    :0800080005288316031385018E
    :1000100083128C010C0883120313850083128C0A4F
    :040020000A280800A2
    :02400E00723FFF
    :00000001FF

    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) {
          __asm
          pagesel _main
          goto _main
          __endasm;
      }

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

      :020000040000FA
      :0400000000000E28C6
      :06000A00831685019C0134
      :100010001C08831285009C0A08280800052808008F
      :02400E00723FFF
      :00000001FF

      HTH,
      Raphael