SDCC - Small Device C Compiler

What is SDCC?

SDCC is a retargettable, optimizing Standard C (ANSI C89, ISO C99, ISO C11) compiler suite that targets the Intel MCS51 based microprocessors (8031, 8032, 8051, 8052, etc.), Maxim (formerly Dallas) DS80C390 variants, Freescale (formerly Motorola) HC08 based (hc08, s08), Zilog Z80 based MCUs (z80, z180, gbz80, Rabbit 2000/3000, Rabbit 3000A, TLCS-90) and STMicroelectronics STM8. Work is in progress on supporting the Microchip PIC16 and PIC18 targets. It can be retargeted for other microprocessors.

SDCC suite is a collection of several components derived from different sources with different FOSS licenses. SDCC compiler suite include:

  • sdas and sdld, a retargettable assembler and linker, based on ASXXXX, written by Alan Baldwin; (GPL).
  • sdcpp preprocessor, based on GCC cpp; (GPL).
  • ucsim simulators, originally written by Daniel Drotos; (GPL).
  • sdcdb source level debugger, originally written by Sandeep Dutta; (GPL).
  • sdbinutils library archive utilities, including sdar, sdranlib and sdnm, derived from GNU Binutils; (GPL)
  • SDCC run-time libraries; (GPL+LE). Pic device libraries and header files are derived from Microchip header (.inc) and linker script (.lkr) files. Microchip requires that "The header files should state that they are only to be used with authentic Microchip devices" which makes them incompatible with the GPL.
  • gcc-test regression tests, derived from gcc-testsuite; (no license explicitely specified, but since it is a part of GCC is probably GPL licensed)
  • packihx; (public domain)
  • makebin; (zlib/libpng License)
  • sdcc C compiler, originally written by Sandeep Dutta; (GPL). Some of the features include:
    • extensive MCU specific language extensions, allowing effective use of the underlying hardware.
    • a host of standard optimizations such as global sub expression elimination, loop optimizations (loop invariant, strength reduction of induction variables and loop reversing), constant folding and propagation, copy propagation, dead code elimination and jump tables for 'switch' statements.
    • MCU specific optimizations, including a global register allocator.
    • adaptable MCU specific backend that should be well suited for other 8 bit MCUs
    • independent rule based peep hole optimizer.
    • a full range of data types: char (8 bits, 1 byte), short (16 bits, 2 bytes), int (16 bits, 2 bytes), long (32 bit, 4 bytes), long long (64 bit, 8 bytes), float (4 byte IEEE) and _Bool/bool.
    • the ability to add inline assembler code anywhere in a function.
    • the ability to report on the complexity of a function to help decide what should be re-written in assembler.
    • a good selection of automated regression tests.

SDCC was originally written by Sandeep Dutta and released under a GPL license. Since its initial release there have been numerous bug fixes and improvements. As of December 1999, the code was moved to SourceForge where all the "users turned developers" can access the same source tree. SDCC is constantly being updated with all the users' and developers' input.


A new release of SDCC, the portable optimizing compiler for 8051, DS390, Z80, Z180, Rabbit 2000, GBZ80, TLCS-90, HC08, STM8 and PIC microprocessors is now available ( Sources and documentation are available (for 3.8.0 we are aiming to bring back binary releases).

SDCC 3.7.0 Feature List:

  • Changed putchar() prototype from void putchar(char) to int putchar(int) to improve standard-compliance and allow error reporting.
  • Various speed improvements in stm8 backend - Dhrystone score more than doubled, resulting in SDCC achieving the highest Dhrystone scores among STM8 C implementations.
  • Various speed improvements for multiplications resulting in SDCC achieving the highest Coremark scores among STM8 C implementations.
  • Declarations in for loops (ISO C99).
  • 64-bit integers (long long) for the mcs51 and ds390 backends (now long long is fully supported in SDCC except for the pic14 and pic16 backends).
  • Full _Bool support for mcs51 and ds390 backend (now _Bool is fully supported in SDCC regardless of backend).
  • Additional wide character library functions: mbstowcs() and wcstombs(), btowc() and wctob(), wcscmp(), wcslen().
  • Changed PRNG for rand() from LCG to xorshift to improve speed and quality.
  • Support for Small-C calling convention on the callee side (i.e. function definitions with Small-C calling convention).
  • The obsolete macro SDCC (which used to contain the version number encoded as an integer) has finally been removed (except for mcs51, where it will survive a little bit longer for SiLabs IDE compability).
  • New devices supported by simulator (TLCS-90, and the 517, F380, XC88X, DS320 mcs51-variants along with dual-dptr and MDU support).
  • Timer, UART (incl. interrupt) and I/O support in STM8 simulator.
  • Simulator support for banked memory and bit banding.
  • Various simulator improvements: Conditional breakpoints, breakpoints by function name from SDCC debug output, OMF input, VCD output, simulator interface for simulated program and new operators in expressions.
  • Deprecated --nojtbound and the corresponding pragma.
  • Faster register allocator reduces compilation time by about 25% (does not apply to mcs51, ds390 which use a different register allocator).
  • Execution count guessing and use of execution count guesses in stm8 register allocation improve optimization for code speed.
  • Changed getchar() prototype from char getchar(void) to int getchar(void) to improve standard-compliance and allow error reporting.
  • Type qualifiers in array parameters (ISO C99).
  • static in array parameters (ISO C99).
  • Improved support for DWARFv2 debug info in ELF output (stm8, hc08, s08).
  • Various improvements in z80/z180/gbz80/tlcs90/r2k/r3ka code generation, in particular for mixed 16-/32-bit code.
  • __z88dk_fastcall function pointer support for --reserve-regs-iy.
  • tlcs90 is now a fully supported backend, no longer work in progress.
  • --data-seg to specify the segment for non-initialized data in the z80, z180, gbz80, tlcs90, r2k and r3ka backends.
  • New methods to obtain tree-decompositions of control-flow graphs improve compilation time / code-quality trade-off (when SDCC is built with support for the treedec library).
  • Additional general utility functions: qsort(), strtol(), strtoul().

Numerous other new features and bug fixes are included as well.

You can download the release from:

What Platforms are Supported?

Linux - x86, Microsoft Windows - x86, Microsoft Windows - x86_64 and Mac OS X are the primary, so called "officially supported" platforms.

SDCC compiles natively on Linux and Mac OS X using gcc. Windows release and snapshot builds are made by cross compiling to mingw32 on a Linux host.

Windows 9x/NT/2000/XP/Vista/7/8 users are recommended to use Cygwin ( or may try the unsupported Microsoft Visual C++ build scripts.

Downloading SDCC

See the Sourceforge download page for the last released version including source and binary packages for Linux - x86, Microsoft Windows - x86, Microsoft Windows - x86_64 and Mac OS X - ppc and i386.

Major Linux distributions take care of SDCC installation packages themselves and you will find SDCC in their repositories. Unfortunately SDCC packages included in Linux disributions are often outdated. In this case users are encouraged to compile the latest official SDCC release or a recent snapshot build by themselves or download the pre-compiled binaries from Sourceforge download page.

SDCC is known to compile from the source code also on the following platforms:

  • Linux - x86_64
  • Linux - Alpha
  • Linux - IBM Power5
  • NetBSD - i386
  • NetBSD - Sparc64
  • FreeBSD - i386
  • SUN Solaris - i386
  • SUN Solaris - Sparc
  • Rasbian (Debian for Raspberry Pi) - ARMv6
  • Debian - ARMv7-a

SDCC is always under active development. Please consider downloading one of the snapshot builds if you have run across a bug, or if the above release is more than two months old.

The latest development source code can be accessed using Subversion. The following will fetch the latest sources:

svn checkout svn:// sdcc

... will create the sdcc directory in your current directory and place all downloaded code there. You can browse the Subversion repository here.

Before reporting a bug, please check your SDCC version and build date using the -v option, and be sure to include the full version string in your bug report. For example:

sdcc/bin > sdcc -v
SDCC : mcs51/gbz80/z80/avr/ds390/pic14/TININative/xa51 2.3.8 (Feb 10 2004) (UNIX)

Support for SDCC

SDCC and the included support packages come with fair amounts of documentation and examples. When they aren't enough, you can find help in the places listed below. Here is a short check list of tips to greatly improve your chances of obtaining a helpful response.

  1. Attach the code you are compiling with SDCC. It should compile "out of the box". Snippets must compile and must include any required header files, etc. Incomplete information will hamper your chance of a timely response.
  2. Specify the exact command you use to run SDCC, or attach your Makefile.
  3. Specify the SDCC version (type "sdcc -v"), your platform and operating system.
  4. Provide an exact copy of any error message or incorrect output.

Please attempt to include these 4 important parts, as applicable, in all requests for support or when reporting any problems or bugs with SDCC. Though this will make your message lengthy, it will greatly improve your chance that SDCC users and developers will be able to help you. Some SDCC developers are frustrated by bug reports without code provided that they can use to reproduce and ultimately fix the problem, so please be sure to provide sample code if you are reporting a bug!

  • Web Page - you are (X) here.
  • Mailing list: [use "BUG REPORTING" below if you believe you have found a bug.]
    • Send to the developer list <> - for development work on SDCC
    • Send to the user list <> - [preferred] all developers and all users.
    • Subscribe to the user list
  • Bug Reporting - if you have a problem using SDCC, we need to hear about it. Please attach code to reproduce the problem, and be sure to provide your email address so a developer can contact you if they need more information to investigate and fix the bug.
  • Website/Documentation Issues - Please report erroneous, missing or outdated information
  • SDCC Message Forum - an account on Sourceforge is needed if you're going to post and reply. Short easy online fill-in the blanks.
  • Open Knowledge Web Site - Run by Thorsten Godau <>

Who is SDCC?

  • Sandeep Dutta <> - original author (SDCC's version of Torvalds)
  • Jean Loius-VERN <> - substantial improvement in the back-end code generation.
  • Daniel Drotos <> - Freeware simulator for 8051.
  • Kevin Vigor <> - numerous enhancements and bug fixes to the Dallas ds390 tree.
  • Johan Knol <> - testing and patching ds390 tree, bug stompper extrodanaire
  • Scott Dattalo <> - sdcc for Microchip PIC controller target
  • Karl Bongers <> - mcs51 support, winbin builds, and an occasional bug.
  • Bernhard Held <> - snpshot builds and general housekeeping
  • Frieder Ferlemann <> - contributions to the documentation and last stages of code generation
  • Jesus Calvino-Fraga <> - math functions, AOMF51, linker improvements
  • Borut Ražem <> - WIN32 MSC, cygwin and mingw ports, NSIS installer, preprocessor and front end improvements, bug fixing, snapshot builds on Distibuted Compile Farm, ...
  • Vangelis Rokas <> - PIC16 taget development for Microchip PIC18F microcontrollers
  • Erik Petrich <> - Bug fixes and improvements for the front end, 8051, z80 and hc08
  • Dave Helton <> - website design
  • Paul Stoffregen <> - mcs51 optimizations and website maintenance.
  • Michael Hope <> - initial Z80 target, additional coding and bug fixes.
  • Maarten Brock <> - several bug fixes and improvements, esp. for mcs51 target
  • Raphael Neider <> - bug fixes and optimizations for PIC16, completion of the PIC14 target
  • Philipp Klaus Krause <> - work on the STM8,Z80,Z180,Rabbit,GBZ80,TLCS-90 backends, compiler research
  • Leland Morrison <> - Rabbit 2000 support: the target code generator, sdasrab assembler and ucsim support
  • Molnár Károly <> - adding pic devices, developing and maintaining pic device files generation scripts
  • Ben Shi <> - the front-end, the STM8 back-end, and the MCS-51 back-end maintain

SDCC has had help from a number of external sources, including:

  • Alan Baldwin <> - Initial version of ASXXXX  and  ASLINK.
  • John Hartman <> - Porting ASXXXX and ASLINK for 8051.
  • Dmitry S. Obukhov <> - malloc and serial I/O routines.
  • Pascal Felber - Some of the Z80 related files are borrowed from the Gameboy Development Kit (GBDK).
  • The GCC development team - for GNU C preprocessor, the basis of sdcpp preprocessor and gcc test suite, partially included into the SDCC regression test suite
  • The GNU Binutils development team - for GNU Binutils, the basis of sdbinutils
  • Boost Community - for Boost C++ libraries used in sdcc compiler
  • Timo Bingmann - for STX B+ Tree C++ Template Classes used in sdcc compiler
  • Malini Dutta <> - Sandeep's wife, for her patience and support.

Past news

Feb 20th, 2018: SDCC 3.7.0 RC2 released.

SDCC 3.7.0 Release Candidate 2 source and doc in corresponding folders at:

Feb 11th, 2018: SDCC 3.7.0 RC1 released.

SDCC 3.7.0 Release Candidate 1 source and doc in corresponding folders at:

Previous News

This site is hosted by Logo Valid XHTML 1.0 Transitional
Valid CSS!


Last updated:
February 27, 2018 08:32:33.