The SDCC (Small Devices C Compiler) is a free C compiler developed for 8-bit microcontrollers. This applicationnote demonstrates how to use the SDCC to develop firmware for the DS89C420/430/440/450 family of ultra-high-speed 8051-compatible microcontrollers. Installing the SDCC free C compiler is also explained.

Introduction

The SDCC (Small Devices C Compiler) is a free C compiler developed for 8-bit microcontrollers. Although
compatible with many different architectures, the SDCC compiler has extended support for devices based on the
8051-core. This application note will focus on using the SDCC to develop firmware for the DS89C420/430/440/450
family of ultra-high-speed 8051-compatible microcontrollers from Maxim/Dallas Semiconductor.

The SDCC is a command line, firmware development tool that includes a preprocessor, a compiler, an assembler,
a linker, and an optimizer. Also bundled with the install file is the SDCDB, a source level debugger similar to gdb
(GNU Debugger). When an error-free program is compiled and linked with the SDCC, a Load Module in Intel hex
format is created. This file can then be loaded into the DS89C420/430/440/450 microcontroller's flash memory
using a Serial Loader. (See DS89C420/430/440/450 documentation and application notes for details on
downloading firmware to device).

For the most up-to-date information about the SDCC, visithttp://sdcc.sourceforge.net or read the SDCC manual,sdccman.pdf (copied to your hard drive during installation). Questions can also be submitted to the online SDCCmessage forum or mailing list which can be found in the "Support" section of the SDCC webpage.

Installing the SDCC Free C Compiler

To install the SDCC, download the latest version from the "Download" section of the SDCC website athttp://sdcc.

sourceforge.net. Although nightly builds of the software are available, it is usually safest to download the latest fully

tested release version (currently v2.4.0).

On the "Download" page, builds of the SDCC are available for several different operating systems. If you are
working on a PC running Microsoft Windows, download the win32 self-executing SDCC install file (sdcc-2.4.0-setup.
exe) and run the executable.

When installing the program, a prompt will appear asking to add the directory containing the program binaries to

your path. This is recommended, and the remainder of this application note will assume that the user has done so.

Using the Free SDCC C Compiler to Develop Firmware for the DS89C420/430/440/450 Family of Microcontrollers

To ensure that the SDCC installed correctly on your hard drive, open a Command Prompt and type sdcc --version.Press [Enter], and the text displayed in Figure 1 should appear in the window (actual text will depend on the SDCCversion that you downloaded):

Figure 1. Verifying the Correct Installation of the SDCC by Performing a Version Check

To test the include path, create a file called sdcctest.c and copy the following source code into the file.

Using the Free SDCC C Compiler to Develop Firmware for the DS89C420/430/440/450 Family of Microcontrollers

Figure 2. Compiling a Simple SDCC Program

Many files are created by the SDCC when you compile your source code successfully. In the directory to which you

compiled, you will find the following files:

qsdcctest.asm: the assembler file for your program
qsdcctest.lst: the listing file for your program
qsdcctest.rst: the listing file for your program updated by the linker
qsdcctest.map: the final memory map updated by the linker
qsdcctest.ihx: the Load Module in Intel hex format. This file must be downloaded into the microcontroller.

Other files are also created (many of them for the source level debuggers). Read the SDCC documentation for

further information.

Data Types Specific to the SDCC

The SDCC supports most ANSI-C data types such as:

qchar: 1 byte - can be signed or unsigned
qshort: 2 bytes - can be signed or unsigned
qint: 2 bytes - can be signed or unsigned
qlong: 4 bytes - can be signed or unsigned
qfloat: 4 bytes

In addition, the SDCC supports a number of extended data types (also called storage classes) to take advantage of

the 8051-architecture. They are presented in the following subsections with examples.

Unlike some commercial 8051 microcontroller development tools, the SDCC is only capable of declaring SpecialFunction Registers as both bit and byte addressable. Although supported by the 8051 assembly language, sharedbit and byte addressable RAM is not supported by the SDCC. To prove this, observe the following code sampleand compiled assembler code.