DOKK / manpages / debian 12 / sdcc / sdcc.1.en
SDCC(1) General Commands Manual SDCC(1)

sdcc - Small Device C Compiler

sdcc [options] filename

The information in this man page is an extract from the full documentation of SDCC, and is limited to the meaning of the options.

For complete and current documentation, refer to the SDCC Compiler User Guide.

SDCC is free open source, retargettable, optimizing ANSI-C compiler designed for 8 bit Microprocessors. The current version targets Intel MCS51 based Microprocessors (8031, 8032, 8051, 8052, etc.), Dallas DS80C390 variants, Freescale (formerly Motorola) HC08 and Zilog Z80 based MCUs (z80, z180, gbz80, Rabbit 2000/3000). It can be retargeted for other microprocessors, support for Microchip PIC is under development.

SDCC uses a modified version of ASXXXX & ASLINK, free open source retargetable assembler & linker.

SDCC has extensive language extensions suitable for utilizing various microcontrollers and underlying hardware effectively.

SDCC uses ASXXXX & ASLINK, a Freeware, retargettable assembler & linker. SDCC has extensive language extensions suitable for utilizing various microcontrollers and underlying hardware effectively.

The compiler also allows inline assembler code to be embedded anywhere in a function. In addition, routines developed in assembly can also be called.

Generate code for the MCS51 (8051) family of processors. This is the default processor target.
Generate code for the DS80C390 processor.
Generate code for the DS80C400 processor.
Generate code for the Z80 family of processors.
Generate code for the GameBoy Z80 processor.
Generate code for the Zilog Z80 family of processors.
Generate code for the Zilog Z180 family of processors.
Generate code for the Rabbit 2000 / Rabbit 3000 family of processors."
Generate code for the Rabbit 2000 / Rabbit 3000 family of processors. Check XXXXX"
Generate code for the GameBoy Z80 processor (Not actively maintained).
Generate code for the Microchip PIC 14-bit processors (p16f84 and variants. In development, not complete).
Generate code for the Microchip PIC 16-bit processors (p18f452 and variants. In development, not complete).
Generate code for the Toshiba TLCS-900H processor (Not maintained, not complete).
Generate code for the Phillips XA51 processor (Not maintained, not complete).
Generate code for the STM8 processor.

The additional location where the pre processor will look for `<..h>' or `..h' files.
Command line definition of macros. Passed to the pre processor.
Tell the preprocessor to output a rule suitable for make describing the dependencies of each object file. For each source file, the preprocessor outputs one make-rule whose target is the object file name for that source file and whose dependencies are all the files `#include'd in it. This rule may be a single line or may be continued with `\'-newline if it is long. The list of rules is printed on standard output instead of the preprocessed C program. `-M' implies `-E'.
Tell the preprocessor not to discard comments. Used with the `-E' option.
Like `-M' but the output mentions only the user header files included with `#include "file"'. System header files included with `#include <file>' are omitted.
Assert the answer answer for question, in case it is tested with a preprocessor conditional such as `#if #question(answer)'. `-A-' disables the standard assertions that normally describe the target machine.
(answer) Assert the answer answer for question, in case it is tested with a preprocessor conditional such as `#if #question(answer)'. `-A-' disables the standard assertions that normally describe the target machine.
Undefine macro macro. `-U' options are evaluated after all `-D' options, but before any `-include' and `-imacros' options.
Tell the preprocessor to output only a list of the macro definitions that are in effect at the end of preprocessing. Used with the '-E' option.
Tell the preprocessor to pass all macro definitions into the output, in their proper sequence in the rest of the output.
Like `-dD'except that the macro arguments and contents are omitted. Only `#define name' is included in the output.

This option is passed to the linkage editor's additional libraries search path. The path name must be absolute. Additional library files may be specified in the command line. See section Compiling programs for more details.
The start location of the external ram, default value is 0. The value entered can be in Hexadecimal or Decimal format, e.g.: --xram-loc 0x8000 or --xram-loc 32768.
The start location of the code segment, default value 0. Note when this option is used the interrupt vector table is also relocated to the given address. The value entered can be in Hexadecimal or Decimal format, e.g.: --code-loc 0x8000 or --code-loc 32768.
The initial value of the stack pointer. The default value of the stack pointer is 0x07 if only register bank 0 is used, if other register banks are used then the stack pointer is initialized to the location above the highest register bank used. eg. if register banks 1 & 2 are used the stack pointer will default to location 0x18. The value entered can be in Hexadecimal or Decimal format, eg. --stack-loc 0x20 or --stack-loc 32. If all four register banks are used the stack will be placed after the data segment (equivalent to --stack-after-data)
This option will cause the stack to be located in the internal ram after the data segment.
The start location of the internal ram data segment, the default value is 0x30. The value entered can be in Hexadecimal or Decimal format, eg. --data-loc 0x20 or --data-loc 32.
The start location of the indirectly addressable internal ram, default value is 0x80. The value entered can be in Hexadecimal or Decimal format, eg. --idata-loc 0x88 or --idata-loc 136.
The linker output (final object code) is in Intel Hex format. (This is the default option).
The linker output (final object code) is in Motorola S19 format.

Generate code for Large model programs see section Memory Models for more details. If this option is used all source files in the project should be compiled with this option. In addition the standard library routines are compiled with small model, they will need to be recompiled.
Generate code for Small Model programs see section Memory Models for more details. This is the default model.

Generate 24-bit flat mode code. This is the one and only that the ds390 code generator supports right now and is default when using -mds390.
Disable interrupts during ESP:SP updates.
_--stack-10bit
Generate code for the 10 bit stack mode of the Dallas DS80C390 part. This is the one and only that the ds390 code generator supports right now and is default when using -mds390. In this mode, the stack is located in the lower 1K of the internal RAM, which is mapped to 0x400000 . Note that the support is incomplete, since it still uses a single byte as the stack pointer. This means that only the lower 256 bytes of the potential 1K stack space will actually be used. However, this does allow you to reclaim the precious 256 bytes of low RAM for use for the DATA and IDATA segments. The compiler will not generate any code to put the processor into 10 bit stack mode. It is important to ensure that the processor is in this mode before calling any re-entrant functions compiled with this option. In principle, this should work with the --stack-auto option, but that has not been tested. It is incompatible with the --xstack option. It also only makes sense if the processor is in 24 bit contiguous addressing mode (see the --model-flat24 option).

Force a called function to always save BC.
When linking, skip the standard crt0.o object file. You must provide your own crt0.o for your system when linking.

Will not do global subexpression elimination, this option may be used when the compiler creates undesirably large stack/data spaces to store compiler temporaries. A warning message will be generated when this happens and the compiler will indicate the number of extra bytes it allocated. It recommended that this option NOT be used, #pragma NOGCSE can be used to turn off global subexpression elimination for a given function only.
Will not do loop invariant optimizations, this may be turned off for reasons explained for the previous option. For more details of loop optimizations performed see section Loop Invariants.It recommended that this option NOT be used, #pragma NOINVARIANT can be used to turn off invariant optimizations for a given function only.
Will not do loop induction optimizations, see section strength reduction for more details. It is recommended that this option is NOT used, #pragma NOINDUCTION can be used to turn off induction optimizations for a given function only.
Will not generate boundary condition check when switch statements are implemented using jump-tables. It is recommended that this option is NOT used, #pragma NOJTBOUND can be used to turn off boundary checking for jump tables for a given function only.
Will not do loop reversal optimization.

will compile and assemble the source, but will not call the linkage editor.
Run only the C preprocessor. Preprocess all the C source files specified and output the results to standard output.
All functions in the source file will be compiled as reentrant, i.e. the parameters and local variables will be allocated on the stack. If this option is used all source files in the project should be compiled with this option.
Uses a pseudo stack in the first 256 bytes in the external ram for allocating variables and passing parameters.
The compiler by default uses a caller saves convention for register saving across function calls, however this can cause unnecessary register pushing & popping when calling small functions from larger functions. This option can be used to switch the register saving convention for the function names specified. The compiler will not save registers when calling these functions, no extra code will be generated at the entry & exit for these functions to save & restore the registers used by these functions, this can SUBSTANTIALLY reduce code & improve run time performance of the generated code. In the future the compiler (with interprocedural analysis) will be able to determine the appropriate scheme to use for each function call. DO NOT use this option for built-in functions such as _muluint..., if this option is used for a library function the appropriate library function needs to be recompiled with the same option. If the project consists of multiple source files then all the source file should be compiled with the same --callee-saves option string.
When this option is used the compiler will generate debug information, that can be used with the SDCDB. The debug information is collected in a file with .cdb extension.
This option is obsolete and isn't supported anymore.
This option is obsolete and isn't supported anymore.
This option can be used to use additional rules to be used by the peep hole optimizer.
Stop after the stage of compilation proper; do not assemble. The output is an assembler code file for the input file specified.
Pass the asmOption to the assembler.
Pass the linkOption to the linker.
Integer (16 bit) and long (32 bit) libraries have been compiled as reentrant. Note by default these libraries are compiled as non-reentrant.
This option will cause the compiler to generate an information message for each function in the source file. The message contains some important information about the function. The number of edges and nodes the compiler detected in the control flow graph of the function, and most importantly the cyclomatic complexity.
Floating point library is compiled as reentrant.
The compiler will not overlay parameters and local variables of any function, see section Parameters and local variables for more details.
This option can be used when the code generated is called by a monitor program. The compiler will generate a 'ret' upon return from the 'main' function. The default option is to lock up i.e. generate a 'ljmp '.
Disable peep-hole optimization.
Pass the inline assembler code through the peep hole optimizer. This can cause unexpected changes to inline assembler code, please go through the peephole optimizer rules defined in the source file tree '<target>/peeph.def' before using this option.
Causes the linker to check if the internal ram usage is within limits of the given value.
This will prevent the compiler from passing on the default include path to the preprocessor.
This will prevent the compiler from passing on the default library path to the linker.
Shows the various actions the compiler is performing.
Shows the actual commands the compiler is executing.

The following options are provided for the purpose of retargetting and debugging the compiler. These provided a means to dump the intermediate code (iCode) generated by the compiler in human readable form at various stages of the compilation process.

This option will cause the compiler to dump the intermediate code into a file of named <source filename>. dumpraw just after the intermediate code has been generated for a function, i.e. before any optimizations are done. The basic blocks at this stage ordered in the depth first number, so they may not be in sequence of execution.
Will create a dump of iCode's, after global subexpression elimination, into a file named <source filename>.dumpgcse.
Will create a dump of iCode's, after deadcode elimination, into a file named <source filename>.dumpdeadcode.
Will create a dump of iCode's, after loop optimizations, into a file named <source filename>.dumploop.
Will create a dump of iCode's, after live range analysis, into a file named <source filename>.dumprange.
Will dump the life ranges for all symbols.
Will create a dump of iCode's, after register assignment, into a file named <source filename>.dumprassgn.
Will create a dump of the live ranges of iTemp's
Will cause all the above mentioned dumps to be created.

The entire source code for the compiler is distributed under GNU General Public License.

sdcpp(1), asxxxx(1), aslink(1).

This manual page was written by Aurelien Jarno <aurel32@debian.org>, for the Debian GNU/Linux system (but may be used by others).