Description News Downloads Differences Summary of Changes To Do Links


SDCC is a freeware, retargettable, optimizing ANSI C compiler based on gcc. It supports a number of microcontrollers, including the 14-bit core PIC microcontroller series. The SDCC project page can be found here.

I am using PIC microcontrollers for various electonics and robotics projects. Up to now, I have mostly used the PIC16F876 and PIC16F877 microcontrollers. In spring 2002, Microchip released a new series of flash PICs based on a 16-bit core. Since the new series is pin compatible with the 16F series, supports mostly the same feature set, but provides increased code space and CPU speed, I decided I should use the new series for my future projects. Unfortunately, I required new development tools, since my compiler didn't support the 18F series and it was pretty difficult to get a decent bootloader for the new chips (I ended up writing my own bootloader - see my PIC18F Bootloader page).

I had seen SDCC a while back, but it didn't seem to support the PIC very well. I found out to my surprise (thanks Aaron) that the latest source had good support for PIC16F series. Unfortunately, there was no support for 18F series.

I talked to Scott Dattalo who had added the 14-bit core PIC support to SDCC. He gave me directions on how I could procede with a port for the 18F series. The task seemed overwhelming at first, but fortunately, I could use a solid base (the 14-bit PIC core) as a reference point.

The 16-bit core assembler is actually more straightforward than the 14-bit core. Microchip has streamlined different areas of the microcontroller, such as memory management, stack handling, branching, multiply instructions, etc. This has made it easier to come up with the port.

I plan to use this page to keep track of progress of the PIC18F port. The first stab at the port is completed. SDCC now has basic support for the PIC18Fxx2 microcontrollers.

I can be reached at mdubuc at domain.

Happy PICing!


November 4, 2002: Added download section.

September 19, 2002: Added banking support.

September 18, 2002: Fixed problem with destination operand.

September 15, 2002: First PIC18F program compiled and successfully running out of flash.


In this section, I provide a list of patches that can be applied to the sdcc 2.3.2 and gputils distributions to support the PIC18Fxx2 family. I will keep these files around until these patches are submitted to the official SDCC distributions. Note that during the course of my test, I was not able to get gpasm to produce a proper hex file. I instead have used sdcc to generate the assembly file and then MPASM to generate the .hex file. There doesn't seem to be much missing to get .hex file out of gpasm. I just ran out of time.

sdcc patch

Look at the sample Makefile to learn how to build programs using sdcc.

PIC High Performance Microcontroller Differences

Here is a list of differences that affect the port from 16F to 18F:

Other differences which make the PIC18F attractive:

PIC High Performance SDCC Port Summary of Changes

PIC High Performance SDCC Port To Do List


Last updated: July 12, 2005