#50 Optimizing PIC code using SDCC

Richard Latter

Hello All,

I have an application which I am writiing for the
PIC14 range of processors. I have written the
application in SDCC C. I use the following line:

sdcc -mpic14 -p16f628.c myproc.c

The compiled .asm output seems to be quite bloated and
the .hex file is about 1200 bytes in length.

I have tried to optimize the code as much as possible,
but I can only get this down to 820 bytes.

The code is not that complicated <30loc and just seems
to be a bit big for my application. If I write anymore
code, I will blow the 1K limit on this!

I have asked a friend to try and compile my application
using CCS C compiler and the resultant code is only 175
bytes (optimized version). There seems to be a massive
difference size of the generated outputs.

I have tried the options --opt-code-size and
--opt-code-speed, but this seems to make no difference.

Is there any way I can optimize this to be even smaller?

Is there an FAQ on the subject, in particular using the
PIC range of chips.

Many thanks in advance,



  • Maarten Brock
    Maarten Brock

    Logged In: YES
    Originator: NO

    Almost two years have passed and noone answered. I doubt this is still relevant to the O/P.
    And since the pic14 has not seen as much updates as the pic16 which isn't even stable yet, I doubt this has changed much. I think the conclusion must be that SDCC is just far worse at optimizing code than CCS.
    If anyone wants to keep this open reply now, as I have set this Pending.

  • Maarten Brock
    Maarten Brock

    • status: open --> pending
  • Logged In: YES
    Originator: NO

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 14 days (the time period specified by
    the administrator of this Tracker).

    • status: pending --> closed