SDCC - Small Device C Compiler

What is SDCC?

SDCC is a retargettable, optimizing Standard C (ANSI C89, ISO C99, ISO C11, ISO C23) 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, SM83, Rabbit 2000, 2000A, 3000A, TLCS-90, R800), Padauk (pdk14, pdk15), STMicroelectronics STM8, MOS 6502 and WDC 65C02. Work is in progress on supporting the Padauk pdk13 target; Microchip PIC16 and PIC18 targets are unmaintained. SDCC 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 subexpression 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), _Bool/bool and _BitInt.
    • 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.

News

January 29th, 2024: SDCC 4.4.0 released.

A new release of SDCC, the portable optimizing compiler for STM8, MCS-51, DS390, HC08, S08, Z80, Z180, Rabbit, R800, SM83, eZ80 in Z80 mode, Z80N, TLCS-90, MOS 6502, WDC 65C02, Padauk and PIC microprocessors is now available. (http://sdcc.sourceforge.net). Sources, documentation and binaries for GNU/Linux amd64, Windows x86, macOS amd64 are available.

SDCC 4.4.0 New Feature List:

  • Optimizations for rotations.
  • struct / union parameters for hc08, s08 and mos6502.
  • Many bug fixes for -ms08 --stack-auto.
  • struct / union return support for hc08 and s08 (caller side only).
  • Generalized constant propagation.
  • New command line option --syntax-only to only parse the input.
  • Added C99 header inttypes.h
  • Added library functions imaxabs, imaxdiv, llabs, strtoimax, strtoll, strtoull, strtoumax, wcsncmp, wcstoimax, wcstol, wcstoll, wcstoul, wcstoull, wcstoumax
  • New r800 port to better support the ASCII Corp R800 and Zilog Z280.
  • Changed the default calling convention for r2k, r2ka, r3ka, tlcs90, ez80-z80 from version 0 to 1 (this is an ABI break, and will require changes to user-written asm functions or their declarations).
  • Improved optimizations for code speed for stm8, pdk, z80 (and related).
  • New mos65c02 port to better support the WDC 65C02.

January 21st, 2024: SDCC 4.4.0 RC3 released.

SDCC 4.4.0 Release Candidate 3 source, doc and binary packages for amd64 GNU/Linux, amd64 Windows and amd64 macOS are available in corresponding folders at: http://sourceforge.net/projects/sdcc/files/.

What Platforms are Supported?

GNU/Linux on amd64, GNU/Linux on x86, Microsoft Windows on amd64, and macOS on amd64 are the primary, so called "officially supported" platforms.

SDCC compiles natively on GNU/Linux and macOS using gcc. Windows release and snapshot builds are made by cross compiling to mingw32 on a Linux host.

SDCC is known to also work on at least GNU/Linux on aarch64, GNU/Linux on ppc64, FreeBSD on aarch64.

Windows 9x/NT/2000/XP/Vista/7/8 users are recommended to use Cygwin (http://sources.redhat.com/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 - amd64, Microsoft Windows - x86, Microsoft Windows - amd64 and Mac OS X - ppc and amd64.

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.

In addition, SDCC should compile on any modern Unix-like OS; the following are included in automated regression testing, like the release packages:

  • Linux - x86
  • FreeBSD - aarch64

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://svn.code.sf.net/p/sdcc/code/trunk/sdcc 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 <sdcc-devel.AT.lists.sourceforge.net> - for development work on SDCC
    • Send to the user list <sdcc-user.AT.lists.sourceforge.net> - [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. Also report erroneous, missing or outdated documentation here.
  • 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 <thorsten.godau.AT.gmx.de>

Who is SDCC?

  • Sandeep Dutta <sandeep.AT.users.sourceforge.net> - original author (SDCC's version of Torvalds)
  • Jean Loius-VERN <jlvern.AT.writeme.com> - substantial improvement in the back-end code generation.
  • Daniel Drotos <drdani.AT.mazsola.iit.uni-miskolc.hu> - Freeware simulator for 8051.
  • Kevin Vigor <kevin.AT.vigor.nu> - numerous enhancements and bug fixes to the Dallas ds390 tree.
  • Johan Knol <johan.knol.AT.users.sourceforge.net> - testing and patching ds390 tree, bug stompper extrodanaire
  • Scott Dattalo <scott.AT.dattalo.com> - sdcc for Microchip PIC controller target
  • Karl Bongers <karl.AT.turbobit.com> - mcs51 support, winbin builds, and an occasional bug.
  • Bernhard Held <bernhard.AT.bernhardheld.de> - snpshot builds and general housekeeping
  • Frieder Ferlemann <Frieder.Ferlemann.AT.web.de> - contributions to the documentation and last stages of code generation
  • Jesus Calvino-Fraga <jesusc.AT.ece.ubc.ca> - math functions, AOMF51, linker improvements
  • Borut Ražem <borut.razem.AT.gmail.com> - WIN32 MSC, cygwin and mingw ports, NSIS installer, preprocessor and front end improvements, bug fixing, snapshot builds on Distibuted Compile Farm, ...
  • Vangelis Rokas <vrokas.AT.otenet.gr> - PIC16 taget development for Microchip PIC18F microcontrollers
  • Erik Petrich <epetrich.AT.users.sourceforge.net> - Bug fixes and improvements for the front end, 8051, z80 and hc08
  • Dave Helton <dave.AT.kd0yu.com> - website design
  • Paul Stoffregen <paul.AT.pjrc.com> - mcs51 optimizations and website maintenance.
  • Michael Hope <michaelh.AT.juju.net.nz> - initial Z80 target, additional coding and bug fixes.
  • Maarten Brock <sourceforge.brock.AT.dse.nl> - several bug fixes and improvements, esp. for mcs51 target
  • Raphael Neider <RNeider.AT.web.de> - bug fixes and optimizations for PIC16, completion of the PIC14 target
  • Philipp Klaus Krause <pkk.AT.spth.de> - work on the STM8,Z80,Z180,Rabbit,GBZ80,TLCS-90 backends, compiler research
  • Leland Morrison <enigmalee.AT.sourceforget.net> - Rabbit 2000 support: the target code generator, sdasrab assembler and ucsim support
  • Molnár Károly <molnarkaroly.AT.users.sf.net> - adding pic devices, developing and maintaining pic device files generation scripts
  • Ben Shi <powerstudio1st.AT.163.com> - 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 <baldwin.AT.shop-pdp.kent.edu> - Initial version of ASXXXX  and  ASLINK.
  • John Hartman <noice.AT.noicedebugger.com> - Porting ASXXXX and ASLINK for 8051.
  • Dmitry S. Obukhov <dso.AT.usa.net> - 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 <malini.AT.mediaone.net> - Sandeep's wife, for her patience and support.

Past news

January 2nd, 2024: SDCC 4.4.0 RC2 released.

SDCC 4.4.0 Release Candidate 2 source, doc and binary packages for amd64 GNU/Linux, amd64 Windows and amd64 macOS are available in corresponding folders at: http://sourceforge.net/projects/sdcc/files/.

December 21st, 2023: SDCC 4.4.0 RC1 released.

SDCC 4.4.0 Release Candidate 1 source, doc and binary packages for amd64 GNU/Linux, amd64 Windows and amd64 macOS are available in corresponding folders at: http://sourceforge.net/projects/sdcc/files/.

Jun 7th, 2023: SDCC 4.3.0 released.

A new release of SDCC, the portable optimizing compiler for STM8, MCS-51, DS390, HC08, S08, Z80, Z180, Rabbit, SM83, eZ80 in Z80 mode, Z80N, TLCS-90, MOS 6502, Padauk and PIC microprocessors is now available. (http://sdcc.sourceforge.net). Sources, documentation and binaries for GNU/Linux amd64, Windows amd64, macOS amd64 are available.

SDCC 4.3.0 New Feature List:

  • C2X bit-precise integer types and bit-fields thereof for (except for pic14, pic16).
  • Added all new general mnemonics from ASxxxx 5.40 except for .bank and enabled for all ports
  • sm83: sdasgb now can output cycles in listing and sz80 has accurate cycles for this processor except for branching
  • struct / union return (except for ds390, hc08, s08, mos6502, pic14, pic16).
  • div standard library function family.
  • struct / union parameters (except for hc08, s08, mos6502, pic14, pic16).
  • C2X nullptr.
  • Many fixes for the type system and _Generic.
  • Adopted more of GCC, QuickC and tinycc tests.
  • C2X char8_t.
  • C2X memalignment.
  • C2X unreachable.
  • C2X typeof, typeof_unqual.
  • C2X auto.
  • C2X keywords bool, true, false, alignas, alignof, static_assert.
  • C90-C17 function declarators without prototypes.
  • C99 variably modified types.
  • C2X bit and byte utilities.
  • call_once.
  • _sdcc_external_startup renamed to __sdcc_external_startup and supported for all ports.
  • makeshift support for long double as another alias for float.

Previous News


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

Webmaster

Last updated:
March 06, 2024 07:10:21.