SDCC, the Small Device C Compiler
SDCC is a multi-platform, multi-target C cross compiler that was originally written by Sandeep Dutta and has been further improved by a number of other people:
- ASXXXX and ASLINK, a Freeware, retargetable assembler and linker.
- 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) and float (4 byte IEEE).
- 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.
The SDCC package components include the sdcc compiler, the sdcpp C preprocessor, assemblers and linkers for the supported target processors, a simulator for the 8051 processor, the sdcdb source debugger and the packihx Intel hex file packing tool.
Version 2.8.0 of SDCC was announced on March 30, 2008, it includes the following changes:
added predefined preprocessor macro SDCC_REVISION holding SDCC's subversion revision number added preprocessor macros SDCC_PARMS_IN_BANK1, SDCC_FLOAT_REENT and SDCC_INT_LONG_REENT sdcpp synchronized with GNU cpp 4.2.3 multiple infiles for sdcclib added option --acall-ajmp: replaces lcall/ljmp with acall/ajmp added support for many PIC devices sdcc executables on Mac OS X are built as universal binaries, so that they can run on both ppc and i386 Mac OS X added --Werror command line option Windows installer enhancements generation of cdb debug info for as-z80 and link-z80 generation of cdb debug info for variables in pdata for mcs51 Tail call optimization for functions that take no parameters on Z80 Improved multiplication of unsigned chars on Z80 ISO/IEC 9899 standard compliant integer promotion of integer function arguments if --std-cXX is defined in command line Numerous feature requests and bug fixes are included as well.
Your author downloaded SDCC 2.8.0 as a .tar.bz2 file onto a machine running Ubuntu 7.04 "Feisty Fawn". The file was uncompressed, and untared. The configure script was run and one package dependency issue was resolved by installing flex. The second run of configure worked, as did the make and make install steps. Running sdcc -v produced the expected result: SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 2.8.0 #5117 (Apr 1 2008) (UNIX).
A few test cases were compiled and assembled using the default MCS51 target, then using the -mz80 switch to produce output for a Z80 processor. All of the tests seemed to work, and produced readable Intel Hex files that appear to be suitable for movement to a development platform. Your author recognized the hex C30001 at the beginning of the code as a Z80 jump instruction, activate the wayback machine. This may be a long way from developing a working embedded application on real hardware using SDCC, it does show that the system builds and is stable enough to consider using as a development platform.
The Z80 and mcs51 microprocessors have been around since the late 1970s, newer versions are still being produced. The Microchip PIC microcontroller family and the Atmel AVR family are currently very popular microcontroller platforms. The AVR is the processor used in the recently featured Arduino open hardware microprocessor design, although that uses a different development system.
SDCC allows microprocessor applications to be written in C, and that greatly expands the range of problems that can be solved by small embedded machines. The field of C cross-compilers has traditionally been dominated by proprietary Windows-based software. SDCC allows one to develop embedded microprocessor designs using open-source software under Linux.
Posted Apr 3, 2008 7:44 UTC (Thu)
by ikm (guest, #493)
[Link]
Posted Apr 3, 2008 18:40 UTC (Thu)
by mgross (guest, #38112)
[Link] (1 responses)
Posted Apr 4, 2008 19:42 UTC (Fri)
by rvfh (guest, #31018)
[Link]
Posted Apr 4, 2008 0:40 UTC (Fri)
by rgilton (subscriber, #31330)
[Link]
Posted Apr 4, 2008 22:02 UTC (Fri)
by Quazatron (guest, #4368)
[Link]
Posted Apr 5, 2008 1:30 UTC (Sat)
by i3839 (guest, #31386)
[Link] (2 responses)
Posted Apr 11, 2008 18:07 UTC (Fri)
by olecom (guest, #42886)
[Link]
SDCC, the Small Device C Compiler
Well, it definitely works. I've got the impression that it's mostly for 51's in fact, I used
it exactly for that architecture with very positive results; while I was getting some feeling
of insecurity due to less clear and verbose error reporting, the produced code worked with no
problems whatsoever. Sdcc shines in that it fully supports 51's crazy address spaces, that's
it's main perk I think. The only thing I was kinda missing is C++ support (yuck! that is,
sic). Right now I have a project involving pic24 architecture and the custom port of gcc for
that architecture made by Microchip is one of the nicest things I've ever experienced while
working with microcontrollers while it's a bit raw compared to e.g. avr-gcc, mostly due to
not being officially supported for linux, it fully supports all mcu-specific features like
data in program space and so on. And it works, of course. Sdcc and gcc are truly different
beasts, though their targets are quite not like each other. Sdcc supports small and crazy
mcus, while gcc targets larger and saner things.
SDCC, the Small Device C Compiler
I'm going to try out my Pic18 UBW project with the new compiler tonight!
SDCC, the Small Device C Compiler
Please report rate of success!
mspgcc: C Compiler for MSP430s
mspgcc (http://mspgcc.sf.net) is also worth a mention here.
SDCC, the Small Device C Compiler
I see our dear editor also has some Z80 opcodes burned into the brain. That happened to me
when I was a kid, playing with my ZX Spectrum, didn't have an assembler or compiler, and had
to POKE the raw bytes into memory.
I still can remember all the values for building a loop that clears the screen. How sad is
that?
SDCC, the Small Device C Compiler
Quoting the mainpage:
> AVR and gbz80 targets are no longer maintained.
Good to hear they added support for many PIC devices though, as for those there isn't much
alternative.
The Macroassembler AS
http://john.ccac.rwth-aachen.de:8000/as/index.html
More basic assembler, than C, but really an interesting one from features and historic points
of view.
_____