The Crossware 8051 C compiler is an ANSI standard compiler
that generates code for the 8051 family of
microcontrollers. It provides numerous extensions that
allow access to 8051 specific features so that you can
write your code completely in the C language without the
need to resort to assembler code. It supports both small
and large memory models so you can create code for all
8051 variants whether or not they have external ram.
- The ANSI C compiler protects your investment by
ensuring future portability of your C source.
- 8051 specific extensions enable you to access all
of the resources of the 8051 and its variants
- Smart pointers which can work out for themselves
which memory area they are pointing to. This
enables you to avoid inefficient 3 byte pointers
yet still write ANSI C compatible code.
- Generates fast in-line code with a minimum of
library calls for high speed performance on your
target board or optionally uses library routines
to minimize code size for those parts of your
program where speed is less important.
- Full type checking across modules traps
programming errors and ensures that your C
variables, function arguments, structure members,
etc are consistent across your source files and
with the appropriate libraries.
- Source level debug output in IEEE695 format.
- Pre-written library routines, including high
speed 32 bit and 64 bit floating point
- Register bank independent code.
- Easy to use C interrupt support with optional
register bank switching.
- Small and large memory models.
- Place variables in any memory area.
- Supports all 8051 variants.
- Wide range of output formats.
- Integrated relocatable assembler.
- Data output for Embedded Development Studio
The compiler conforms to the ANSI C
specification and in addition provides a number of
general enhancements including:
- variables can be any length with all characters
- the C++ commenting convention "//" is
- the_interrupt keyword declares a C function as an
- the _persist keyword declares that a variable
will retain its contents (eg. in battery backed
up ram) during power down and should therefore
not be initialized.
The support libraries are a subset of the ANSI
standard libraries. The supported functions are listed
8051 specific language extensions are described below.
The compiler uses the following sizes for the various C
|char and unsigned char:
|short int and unsigned short int:
|int and unsigned int:
|long and unsigned long:
||4 bytes (32 bits)
||8 bytes (64 bits)
||8 bytes (64 bits)
||up to 4 bytes (minimum size to
||up to 32 bits
- constant folding
- dead code elimination
- strength reduction
- algebraic simplification
- jump/branch optimization
- suppression of integral promotion
- global register allocation
- common code merging
- removal of unreferenced local data
8051 Language Extensions
In addition to the general extensions described above,
the compiler supports numerous 8051 specific extensions
which enable you to maximise your use of the internal
resources of the 8051 and its variants. These include:
- Qualifiers to enable you to place variables in
bit, data, idata, bdata and xdata memory areas
irrespective of the memory model being used
(variables declared as const are automatically in
- Direct access to the bits of variables located in
the bdata memory area.
- Direct access to 8 bit sfr's, 16 bit sfr's and
sfr bits to which you can allocate any C variable
- Additional interrupt qualifiers to allow you to
specify the interrupt vector that a function will
use (the compiler optionally generates all
vectoring code) and an optional register bank for
register bank switching.
The compiler supports pointers that point to any specific
memory area and generic 3 byte pointers that can point to
all memory areas. Some 8051 C compilers default to
generic 3 byte pointers unless you declare a memory
specific pointer using a qualifying keyword. It is then
necessary to decorate your source code with non-ANSI
keywords in order to avoid program inefficiency. This
decoration may be memory model specific and so if you
switch memory models you have to change your source code
too. The Crossware 8051 ANSI C compiler avoids this
problem. Although it supports these pointer qualifiers,
in most cases it is not necessary to use them. Instead
any pointer that is not qualified is a smart pointer. It
will then work out for itself from the way it is used
what type of pointer it should be. This leaves you free
to write memory model independent source code without any
unnecessary loss of efficiency. For further information
see Memory models, pointer types and
The Crossware 8051 ANSI C compiler supports
both 32 bit and 64 bit floating point objects.
32 bit floating point objects contain only 23 bits of
precision (the rest is used by the exponent and sign) and
are therefore less precise than 32 bit long integers.
They are however ideal for the application where low
precision floating point arithmetic is all that is
required. 64 bit floating point objects contain 53 bits
of precision and are therefore ideal where arithmetic
accuracy is an important issue.
All floating point arithmetic and normalisation
routines are hand-coded in 8051 assembler to provide fast
and compact library code.
The compiler supports a small memory model for use with
chips that do not have any external ram and a large
memory model for chips with external ram. Functions can
be either reentrant or non-reentrant
A non-reentrant function is faster and smaller but cannot
be called either directly or indirectly from within
The compiler supports all 8051 variants including those
that require the use of the ACALL and AJMP instructions.
The compiler generates full IEEE695 debug records. These
records provide full information to the simulator and
debugger allowing you
to single step through your C source code and watch all
of your C variables.
The compiler provides numerous features that allow you to
access the 8051 features at the C source level.
Nevertheless you can still embed assembler in your C code
if you wish using the #asm/#endasm directives.
C Library Support Routines
The linker combines object modules created with the
compiler and/or the assembler to create the final code
that will run on your target system. It carries out the
- scans each module to collect segment and variable
- arranges and positions segments at appropriate
memory locations to suit the memory organisation
of the target system and any specific location
information supplied by the user
- finalises the values of all variables and
calculates the results of any incomplete
- extracts and relocates the code from each module
to produce the final target program
- optionally updates the listing files produced by
the compiler and/or assembler adding the final
absolute address information
- carries out a complete type check across all
modules examining global variables, functions
(return type, parameter types and numbers,
reentrant attributes, interrupt attributes, and
memory model type) and structure and union member
types to ensure total program integrity
The linker will also construct a call tree of your C
functions. It will use this to perform an overlay
analysis of the local data areas of any non-reentrant
functions, sharing memory wherever possible. It will
report potential recursion of non-reentrant functions. At
the same time, the parameter space for non-reentrant
functions with variable numbers of arguments will be
sized to the maximum required by any of the calls to that
The target program can be produced in a number of
different formats including Intel hex, Intel OMF51,
Motorola 'S' record, HP/Microtec IEEE695 format or as a
binary rom image. No conversion utility has to be used -
the linker directly outputs the program in the specified
An optional link map will show the final location and
sizes of all segments and the values of all global
Instead of being used to create a final target
program, the object modules produced by the compiler and
assembler can be integrated into a library. The library
manager performs the tasks of:
- combining object modules into a library
- adding modules to an existing library
- removing or extracting modules from an existing
- listing the contents of a library
The MAKE utility simplifies the task of keeping object
files, libraries and target programs up-to-date. It
detects if any source or dependency files have changed
since the last build and runs the appropriate tools
(compiler, assembler, linker or library manager) to
rebuild out-of-date files. It supports many advanced
features including macros, inference rules, conditional
inclusion and other preprocessing directives and in-line
files with automatic temporary file creation.
Although the Embedded Development Studio uses its own
integrated routines to keep projects up-to-date, this
stand-alone MAKE utility can be used to build projects
from the command-line or from within another application.
The Embedded Development Studio will automatically create
a makefile which is fully compatible with this
stand-alone MAKE utility.
Relocatable Macro Cross Assembler
- High speed assembly to create relocatable object
- Intel standard segment directives allow segments
to be aligned to page and block boundaries,
contained within a page or block, positioned at
the highest in memory location or positioned
above all other segments.
- Intel standard assembler mnemonics
- Nestable macros with full argument passing
- Nestable conditional assembly
- Comprehensive range of assembler directives and
- Complex expression evaluation with Intel standard
- Intel standard 8051 and 8052 predefined symbols
- Upper and lower case labels with up to 255
- Upper and lower case opcode mnemonics
- Upper and lower case macro names with up to 255
- Comprehensive error checking with descriptive
- Debug output of symbolic information
- User definable listing format
- Run from the command line or from within the