4 COMPILER USE

This chapter contains the following sections:

cc51 Invocation
Detailed description of the C-51 options
Include Files
Pragmas
Alias
Compiler Limits

4.1 cc51 Invocation

The invocation syntax of the C-51 compiler is:

The input file must have the extension .c or .i. Options are preceded by a '-' (minus sign). Options cannot be combined after a single '-'. After you have successfully compiled your C sources, the compiler has generated assembly files, with the extension .src (the default for asm51).

When you use a UNIX shell (Bourne shell, C-shell), arguments containing special characters (such as '( )' and '?') must be enclosed with "" or escaped. The -? option (in the C-shell) becomes: "-?" or -\?.

A summary of the options is given below. A more detailed description is given in the next section.

Option Description
-? Display invocation syntax
-A[flag...] Enable/disable specific language extensions
-Ccpu Use special function register definitions for cpu
-Dmacro[=def] Define preprocessor macro
-E[m] Preprocess only or emit dependencies
-Hfile Include file before starting compilation
-Idirectory Look in directory for include files
-M{s|a|l|r } Select memory model: small, auxpage, large or reentrant
-Oflag... Control optimization
-Rmem[=name] Change segment name
-S Put strings in ROM only
-Umacro Remove preprocessor macro
-V Display version header only
-asize Change allocated space for variable argument list
-bnumber Specify default register bank number
-bpnumber Enable chip errata bypass
-csize Extend amount of internal RAM to be used as CSE space
-e Remove output file if compiler errors occur
-err Send diagnostics to error list file (.err)
-f file Read options from file
-g[e|f|l|r ]... Enable symbolic debug information
-ivo=value 16-bit base address for the interrupt vector table
-l[i] Generate list file; optionally with include files
-mmem=size Specify memory size
-misracn,n,... Enable individual MISRA C checks
-n Send output to standard output
-nofastparm Switch off use of fast parameter area
-noregaddr Get register bank independent code generation
-o file Specify name of output file
-pa Use dual data pointer (Atmel AT8x53, AT89S53, AT89S4D12, AT89S8252)
-pd Use dual data pointer (Dallas 80C320/520/530, AMD 80C521)
-pp Use dual data pointer (Philips 51 family)
-ps Use multiple data pointer (Infineon Technologies C500/C800 series)
-r{s | m | l} Select rom model: small, medium or large
-s Merge C-source code with assembly output
-se Treat small enumerated types as 'char' instead of 'int'
-t Display module summary
-u Treat all 'char' variables as unsigned
-v Do not generate interrupt vectors
-vf Do not generate frame for interrupt handler
-vo Generate old style interrupt frame
-w[num] Suppress one or all warning messages
-wstrict Suppress warning messages 183, 196
-xsize Extend amount of internal RAM for automatics
-zpragma Identical to '#pragma pragma' in the C source

Table 4-1: Compiler options (alphabetical)

Description Option
Include options
Read options from file -f file
Include file before starting compilation -Hfile
Look in directory for include files -Idirectory
Preprocess options
Preprocess only or emit dependencies -E[m]
Define preprocessor macro -Dmacro[=def]
Remove preprocessor macro -Umacro
Allocation control options
Change segment name -Rmem[=name]
Put strings in ROM only -S
Change allocated space for variable argument list -asize
Specify memory size -mmem=size
Code generation options
Use special function register definitions for cpu -Ccpu
Select memory model: small, auxpage, large or reentrant -M{s|a|l|r }
Control optimization -Oflag...
Specify default register bank number -bnumber
Enable chip errata bypass -bpnumber
Extend amount of internal RAM to be used as CSE space -csize
16-bit base address for the interrupt vector table -ivo=value
Switch off use of fast parameter area -nofastparm
Get register bank independent code generation -noregaddr
Use dual data pointer (Atmel AT8x53, AT89S53, AT89S4D12, AT89S8252) -pa
Use dual data pointer (Dallas 80C320/520/530, AMD 80C521) -pd
Use dual data pointer (Philips 51 family) -pp
Use multiple data pointer (Infineon Technologies C500/C800 series) -ps
Select rom model: small, medium or large -r{s | m | l}
Do not generate interrupt vectors -v
Do not generate frame for interrupt handler -vf
Generate old style interrupt frame -vo
Extend amount of internal RAM for automatics -xsize
Identical to '#pragma pragma' in the C source -zpragma
Language control options
Enable/disable specific language extensions -A[flag...]
Treat small enumerated types as 'char' instead of 'int' -se
Treat all 'char' variables as unsigned -u
Output file options
Remove output file if compiler errors occur -e
Send output to standard output -n
Specify name of output file -o file
Merge C-source code with assembly output -s
Diagnostic options
Display invocation syntax -?
Display version header only -V
Send diagnostics to error list file (.err) -err
Enable symbolic debug information -g[e|f|l|r ]...
Generate list file; optionally with include files -l[i]
Enable individual MISRA C checks -misracn,n,...
Display module summary -t
Suppress one or all warning messages -w[num]
Suppress warning messages 183, 196 -wstrict

Table 4-2: Compiler options (functional)

4.2 Detailed description of the C-51 options

Option letters are listed below. Each option (except -o; see description of the -o option ) is applied to every source file. If the same option is used more than once, the first (most left) occurrence is used. The placement of command line options is of no importance except for the -I and -o options. For those options having a file argument (-o and -f), the filename may not start immediately after the option. There must be a tab or space in between. All other option arguments must start immediately after the option. Source files are processed in the same order as they appear on the command line (left-to-right).

Some options have an equivalent pragma.

With options that can be set from within EDE, you will find a mouse icon that describes the corresponding action.

-?

Option:

-?

Description:

Display an explanation of options at stdout.

Example:

cc51  -?

-A

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Language Extensions. Set or disable language extensions.

-A[flags]

Arguments:

Optionally one or more language extension flags.

Default:

-A1

Description:

Enable/disable language extensions. -A without any flags, specifies strict ANSI mode; all language extensions are disabled. This is equivalent with -ACKLNPSTUVX and -A0.

Flags which are controlled by a letter, can be switched on with the lower case letter and switched off with the uppercase letter. Note that the usage of these options might have effect on code density and code execution performance. The following flags are allowed:

c Default. Perform character arithmetic. cc51 generates code using 8-bit character arithmetic as long as the result of the expression is exactly the same as if it was evaluated using integer arithmetic. See also section 3.3.3, Character Arithmetic.

C Disable character arithmetic.

k Default. Allow keyword language extensions without underscores. For example, both _xdat and xdat are allowed.

K Only keyword extensions that start with an underscore, such as _xdat, are allowed.

l Default. 120 significant characters are allowed in an identifier instead of the minimum ANSI-C translation limit of 31 significant characters. Note: more significant characters are truncated without any notice.

L Conform to the minimum ANSI-C translation limit of 31 significant characters. This makes it possible to translate your code with any ANSI-C conforming C-compiler. Note: more significant characters are truncated without any notice.

n Default. Do not clear non-initialized global variables.

N Non-initialized global variables are cleared at startup.

p Default. Allow C++ style comments in C source code. For example:

P Do not allow C++ style comments in C source code, to conform to strict ANSI-C.

s Default. __STDC__ is defined as '0'. The decimal constant '0', intended to indicate a non-conforming implementation. When one of the language extensions are enabled __STDC__ should be defined as '0'.

S __STDC__ is defined as '1'. In strict ANSI-C mode (-A) __STDC__ is defined as '1'.

t Default. Do not promote old-style function parameters when prototype checking.

T Perform default argument promotions on old-style function parameters for a strict ANSI-C implementation. char type arguments are promoted to int type and float type arguments are then promoted to double type.

u Default. Use type unsigned char for 0x80-0xff. The type of an unsuffixed octal or hexadecimal constant is the first of the corresponding list in which its value can be represented:

Character arithmetic enabled -Ac:

Character arithmetic disabled -AC (strict ANSI-C):

U Do not use type unsigned char for 0x80-0xff. The type of an unsuffixed octal or hexadecimal constant is the first of the corresponding list in which its value can be represented:

Character arithmetic enabled -Ac:

Character arithmetic disabled -AC (strict ANSI-C):

v Allow type cast of an lvalue object with incomplete type void and lvalue cast which does not change the type and memory of an lvalue object.

Example:

V Default. A cast may not yield an lvalue, to conform strict ANSI-C mode.

x Default. Do not check for assignments of a constant string to a non-constant string pointer. With this option the following example produces no warning:

X Conform to ANSI-C by checking for assignments of a constant string to a non-constant string pointer. The example above produces warning W130: "operands of '=' are pointers to different types".

0 - same as -ACKLNPSTUVX (disable all)

1 - same as -Acklnpstuvx (default)

Example:

To disable character arithmetic and C++ comments enter:

-a

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Allocation. Enter a size in the Size (in bytes) of the parameter area for non-reentrant functions with a Variable Argument list field.

-asize

Pragma:

#pragma arglist size

Arguments:

A number of bytes.

Default:

-a20

Description:

Use size for number of bytes to be allocated for function definitions having a variable argument list. The default is 20. This option is applied to the non-reentrant functions only, because reentrant functions use the stack for parameter passing.

Example:

cc51 -a10 test.c

Pragma arglist in the section 4.4 , Pragmas.

-b

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Allocation. Enter a register bank number in the Register bank number (0-3) field.

-bnumber

Arguments:

A register bank number in the range of 0 to 3.

Default:

-b0

Description:

Select the default register bank value for all functions of the module. Notice no code is generated to switch to this register bank. The default register bank is 0.

Example:

cc51 -b1 test.c

Section 3.16 , Interrupt and Using

-bp

Option:

From the Project menu, select Project Options... Expand the Processor entry and select Bypasses. Enable the option Bypass DS80C390 erratum #6 (DIV AB preceded by ACC access).

-bpnumber

Arguments:

TASKING chip erratum bypass number.

Description:

Enable bypass for certain CPU functional problems.

Bypass number 1 bypasses DS80C390 erratum #6, and inserts an extra NOP before any DIV AB instruction.

Example:

To bypass DS80C390 erratum #6, enter:

See Appendix F , CPU Functional Problems for more details.

-C

Option:

From the Project menu, select Project Options... Expand the Processor entry and select Processor Selection. Choose a processor from the list of derivatives or select User specified and enter your own processor type.

-Ccpu

Arguments:

The CPU name which identifies your 8051 derivative.

Description:

Use special function register definitions for cpu. The filename looked for is "regcpu.sfr" in the same way include files whose names are enclosed in "" are searched.

Example:

To specify to the compiler to look for a file named regp8xc52.sfr, and to use this file as a special function register definition file, enter:

Section 3.3.6 , Special Function Registers, in the previous chapter.

-c

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Allocation. Enter a size in the Amount of DATA for optimization (overlayable) field.

-csize

Pragma:

cse size

Arguments:

A number of bytes.

Default:

-c0

Description:

With this option you can specify the maximum amount of CSE space which may be used by a function. When no CSEs are found within a function, no space will be allocated for it. CSE space is overlayable. The default size is 0. Increase the size value to enable the compiler to allocate some data space for other possible CSE values. When the size is kept '0', the compiler will check for CSE values and tries to place them in register only.

Example:

cc51 -c10 test.c

Pragma cse in the section 4.4, Pragmas.

-D

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Preprocessing. Define a macro (syntax: macro[=def]) in the Define user macros field. You can specify and define more macros by separating them with commas.

-Dmacro[=def]

Arguments:

The macro you want to define and optionally its definition.

Description:

Define macro to the preprocessor, as in #define. If def is not given ('=' is absent), '1' is assumed. Any number of symbols can be defined. The definition can be tested by the preprocessor with #if, #ifdef and #ifndef, for conditional compilations. If the command line is getting longer than the limit of the operating system used, the -f option is needed.

Example:

The following command defines the symbol NORAM as 1 and defines the symbol PI as 3.1416.

Option -U

-E / -Em

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Preprocessing. Enable the opton Preprocess only and capture output.

-E[m]

Description:

Run the preprocessor of cc51 only and send the output to stdout. When you use the -E option, use the -o option to separate the output from the header produced by the compiler. When you use the -Em option, the compiler generates dependency rules which can be used by a 'make' utility.

Examples:

The following command preprocesses the file test.c and sends the output to the file preout.

The following command generates dependency rules for the file test.c which can be used by mk51 (the 8051 'make' utility).

-e

Option:

EDE always removes the output file on errors.

-e

Description:

Remove the output file when an error has occurred. With this option the 'make' utility always does the proper productions.

Example:

cc51 -e test.c

-err

Option:

In EDE this option is not so useful. If you would use this option you would not see the error messages in the Build tab.

-err

Description:

Write errors to the file source.err instead of stderr.

Example:

To write errors to the file test.err instead of stderr, enter:

-f

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Miscellaneous. Add the option to the Additional C compiler options field.

-f file

Arguments:

A filename for command line processing. The filename "-" may be used to denote standard input.

Description:

Use file for command line processing. To get around the limits on the size of the command line, it is possible to use command files. These command files contain the options that could not be part of the real command line. Command files can also be generated on the fly, for example by the make utility.

More than one -f option is allowed.

Some simple rules apply to the format of the command file:

1. It is possible to have multiple arguments on the same line in the command file.

2. To include whitespace in the argument, surround the argument with either single or double quotes.

3. If single or double quotes are to be used inside a quoted argument, we have to go by the following rules:

a. If the embedded quotes are only single or double quotes, use the opposite quote around the argument. Thus, if a argument should contain a double quote, surround the argument with single quotes.

b. If both types of quotes are used, we have to split the argument in such a way that each embedded quote is surrounded by the opposite type of quote.

Example:

     "This has a single quote ' embedded"

or

     'This has a double quote " embedded'

or

     'This has a double quote " and \
     a single quote '"' embedded"

4. Some operating systems impose limits on the length of lines within a text file. To circumvent this limitation it is possible to use continuation lines. These lines end with a backslash and newline. In a quoted argument, continuation lines will be appended without stripping any whitespace on the next line. For non-quoted arguments, all whitespace on the next line will be stripped.

Example:

     "This is a continuation \
     line"
          -> "This is a continuation line"

     control(file1(mode,type),\
          file2(type))
          -> 
     control(file1(mode,type),file2(type))

5. It is possible to nest command line files up to 25 levels.

Example:

Suppose the file mycmds contains the following line:

The command line can now be:

-g

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Debug. Enable the option Generate symbolic debug information. Optionally enable one or more of the other options.

-g[f|e|r|l]...

Description:

Add directives to the output files, incorporating symbolic information to facilitate high level debugging.

If -gf is used, high level language type information is also emitted for types which are not referenced by variables. Therefore, this sub-option is not recommended.

If -ge is used, a NOP instruction is emitted at the start of every C-line. This option can be useful in combination with skidding emulators, executing the instruction which is having a code breakpoint.

If -gr is used, two NOP instructions are emitted at the start of every C-line. This option can be useful in combination with a ROM monitor based execution environment, allowing a software breakpoint (3 byte JMP MONITOR) on every C-line. Note that CrossView51 ROM checks and refuses overlapping breakpoints.

If -gl is used, the compiler no longer suppresses debugging information for (compiler generated) local assembler labels. This option is useful in combination with the CrossView51 ROM debugger, which does not allow a software breakpoint (3 byte JMP MONITOR) to be overlapped with a label. So, when -gl is used, CrossView51 can do a better job, allowing software breakpoints on safe places only. Please note that the amount of debug information in the absolute output file will be increased, which might increase the loading time of the debugger.

When you use a ROM monitor based execution environment (e.g., CrossView51 ROM), we recommend using -grl. When you use a skidding emulator we recommend using -ge.

The -ge and -gr options are the only sub-options of -g that really affect the code generated for a debugging session, inserting NOP(s) for every C-line.

Examples:

To add symbolic debug information to the output files, enter:

To add symbolic debug information to the output files for a skidding emulator, enter:

-H

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Preprocessing. Enter a filename in the Include this file before source field.

-Hfile

Arguments:

The name of an include file.

Description:

Include file before compiling the C-source. This is the same as specifying #include "file" at the first line of your C-source.

Example:

cc51 -Hstdio.h test.c

-I

-I

Option:

From the Project menu, select Directories... Add one or more directory paths to the Include Files Path field.

-Idirectory

Arguments:

The directory of the include file.

Description:

Change the algorithm for searching #include files whose names do not have an absolute pathname to look in directory. Thus, #include files whose names are enclosed in "" are searched for first in the directory of the file containing the #include line, then in directories named in -I options in left-to-right order. If the include file is still not found, the compiler searches in a directory specified with the environment variable CC51INC. CC51INC may contain more than one directory. Finally, the directory ../include relative to the directory where the compiler binary is located is searched. This is the standard include directory supplied with the compiler package.

For #include files whose names are in <>, the directory of the file containing the #include line is not searched. However, the directories named in -I options (and the one in CC51INC and the relative path) are still searched.

Example:

cc51 -I/proj/include test.c

Section 4.3 , Include Files

-ivo

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Code Generation. Enable the option Generate code for interrupt vector and enter a vector offset value in the Reset/interrupt vector offset (0-0xFFFF) field.

-ivo=value

Arguments:

A 16-bit base address for the interrupt vector table.

Description:

This option specifies a 16-bit base address for the interrupt vector table. This option is useful when running the application on an evaluation board using the RISM ROM monitor. RISM claims non-used interrupts to user RAM.

Example:

To specify 0x4000 as the base address of the interrupt vector table, enter:

-v

-l / -li

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Miscellaneous. Add the option to the Additional C compiler options field.

-l[i]

Pragma:

#pragma listinc

Description:

Generate a list file with the name of the module and .lst suffix. The list file is only generated for use with debuggers using a list file instead of the C source file (e.g. an ICE5100 debugger). It is not meant as a listing generator, because other tools (e.g. pr) are available for this purpose.

Note that if the -l option is used all line number references (used in error messages, source merging (-s), __LINE__, __FILE__, object line records, etc.) are now referring to the list file.

If -li is used, include files are expanded in the list file. This is only useful with include files containing executable statements.

Example:

To generate the list file test.lst, in which include files are expanded, enter:

Pragmas listinc and nolistinc in the section 4.4, Pragmas.

-M

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Memory Model. Choose a Data Model.

-Mmodel

Arguments:

The memory model to be used, where model is one of:

s small (static in data)
a auxpage (static in pdat)
l large (static in xdat)
r reentrant (in xdat)

Default:

-Ms

Description:

Select memory model to be used. The default memory model is small.

Example:

cc51 -Ml test.c

Section 3.2.2 , Memory Models

-m

Option:

From the Project menu, select Project Options... Expand the Processor entry and select Memory. Select a size in the On-chip data RAM size (0-256) field.

-mmem=size

Arguments:

A memory space with a memory size. mem can be one of:

mem Description Default size
(bytes)
bi _bit 128 (bits)
da _data 128
id _idat 128
pd _pdat 256
xd _xdat 65536
co constant (_rom) 65536
ba bitaddressable (_bdat) 16
pr program (_rom) 65536

Table 4-3: Memory spaces

Description:

Specify the memory size (limits) to be used by the compiler for checking static memory allocations of the file being processed. The limits used and the space allocated by the module are reported when cc51 completes compilation (unless -t option is used).

-misrac

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select MISRA C. Select a MISRA C configuration. In the MISRA C Rules entry you can specify individual rules.

-misracn,n,....

Arguments:

The MISRA C rules to be checked.

Description:

With this option, the MISRA C rules to be checked can be specified. Refer to Appendix B, MISRA C, for a list of supported and unsupported MISRA C rules.

Example:

cc51 -misrac9 test.c

Will generate an error in case 'test.c' contains nested comments.

-n

Option:

-n

Description:

Do not create output files; instead, the output is sent to stdout.

Example:

cc51 -n test.c

-nofastparm

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Allocation. Disable the option Use fast internal RAM area for parameters. This option is only available if you selected the auxiliary or large memory model.

-nofastparm

Description:

Switch off the use of the fast parameter area. This will shorten the interrupt frame and therefor speedup the execution speed of interrupts.

Example:

cc51 -nofastparm test.c

You can use this feature for individual interrupt functions with #pragma intsave NOPARMregbank. Use this pragma only if you know that the fast parameter area is not used within the function.

Section 7.7 , Interrupt Functions
Pragma intsave in the section 4.4, Pragmas.

-noregaddr

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Code Generation. Disable the option Allow absolute register addresses (AR0-AR7) in generated code.

-noregaddr

Description:

Get register bank independent code generation. With this option it is possible to generate functions that can be called from any function independent of its register bank.

Example:

cc51 -noregaddr test.c

Section 3.17 , Register Bank Independent Code

-O

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Optimization.

-Oflags

Pragma:

#pragma optimize flags

Arguments:

One or more optimization flags.

Default:

-O1

Description:

Control optimization. If you do not use this option, the default optimization of cc51 is -O1, which is a compromise of code size and compilation speed.

Flags which are controlled by a letter, can be switched on with the lower case letter and switched off with the uppercase letter. These options are described together.

All optimization flags can also be given in the source file after a #pragma optimize. For example, specifying -Oc on the command line, is the same as specifying #pragma optimize c in the source file.

An overview of the flags is given below.

a - relax alias checking
c - common subexpression elimination
d - data flow, constant/copy propagation
f - optimize for speed (increases code size)
h - peephole optimization
i - move invariant code outside loop (needs -Oc)
k - optimize into compound assignments
l - fast loops (increases code size)
m - allow code movement
p - control flow optimization
r - use register parameter passing
s - optimize initialization loops
t - turn tentative into defining occurrence
v - loop variable optimization
w - allow register variables
0 - same as -OACDFHIKLMNPRSTVW (no optim)
1 - same as -OAcdFhikLmnprstVw (default)
2 - same as -OacdFhikLmnprstvw (size)
3 - same as -Oacdfhiklmnprstvw (speed)

Example:

cc51 -OAcdFhikLmprstVw test.c

Pragma optimize in the section 4.4 , Pragmas.

-Onumber

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Optimization. Choose an Optimization level.

-Onumber

Arguments:

A number in the range 0 - 3.

Default:

-O1

Description:

Control optimization. You can specify a single number in the range 0 - 3, to enable or disable optimization. The options are a combination of the other optimization flags:

-O0 - same as -OACDFHIKLMNPRSTVW (no optimization)
-O1 - same as -OAcdFhikLmnprstVw (default)
-O2 - same as -OacdFhikLmnprstvw (size)
-O3 - same as -Oacdfhiklmnprstvw (speed)

The flags 0 to 3 cannot be concatenated with other flags. For example, -Oa2c is not allowd, -OacF is allowed.

Example:

To optimize for code size, enter:

-Oa / -OA

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Optimization. Select the Custom optimization level. Enable or disable the option Relax alias checking.

-Oa / -OA

Pragma:

#pragma noalias
#pragma alias

#pragma optimize a
#pragma optimize A

Default:

-OA

Description:

With -Oa you relax alias checking. If you specify this option, cc51 will not erase remembered register contents of user variables if a write operation is done via an indirect (calculated) address. You must be sure this is not done in your C-code (check pointers!) before turning on this option.

With -OA you specify strict alias checking. If you specify this option, cc51 erases all register contents of user variables when a write operation is done via an indirect (calculated) address.

Example:

An example is given in section 4.5 Alias in this chapter.

Pragmas noalias, alias and optimize in the section 4.4, Pragmas.

-Oc / -OC

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Optimization. Select the Custom optimization level. Enable or disable the option Common subexpression elimination (CSE).

-Oc / -OC

Pragma:

#pragma optimize c
#pragma optimize C

Default:

-Oc

Description:

With -Oc you enable CSE (common subexpression elimination). With this option specified, the compiler tries to detect common subexpressions within the C code. The common expressions are evaluated only once, and their result is temporarily held in registers or in data. The size of the maximum used data area can be specified with the -csize option (default 0).

The -Oc option must be on to enable moving invariant code outside a loop (-Oi).

With -OC you disable CSE (common subexpression elimination). With this option specified, the compiler will not try to search for common expressions. Also moving invariant code outside a loop will be disabled.

Example:

/*
 * Compile with -OC -O0,
 * Compile with -Oc -O0, common subexpressions are found
 *    and temporarily saved.
 */

char x, y, a, b, c, d;

void
main( void )
{
      x = (a * b) - (c * d);

      y = (a * b) + (c * d); /*(a*b) and (c*d) are common */
}

-c
Pragma optimize in section 4.4, Pragmas.

-Od / -OD

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Optimization. Select the Custom optimization level. Enable or disable the option Constant and copy propagation (data flow).

-Od / -OD

Pragma:

#pragma optimize d
#pragma optimize D

Default:

-Od

Description:

With -Od you enable constant and copy propagation. With this option, the compiler tries to find assignments of constant values to a variable, a subsequent assignment of the variable to another variable can be replaced by the constant value.

With -OD you disable constant and copy propagation.

Example:

/*
 * Compile with -OD -O0, 'i' is actually assigned to 'j'
 * Compile with -Od -O0, 15 is assigned to 'j', 'i' was
 * propagated
 */

int i;
int j;

void
main( void )
{
      i = 10;
      j = i + 5;
}

Pragma optimize in section 4.4 , Pragmas.

-Of / -OF

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Optimization. Select the Custom optimization level. Enable or disable the option Produce small code (favor code size above execution speed).

-Of / -OF

Pragma:

#pragma optimize f
#pragma optimize F

Pragma:

speed / size

Default:

-OF

Description:

With -Of you produce fast code. Favour execution speed above code density. Note that this option may increase code size. If -Of is specified, cc51 uses inline code for a number of integer operations and index calculations of external RAM objects instead of emitting code which calls a run time library routine. This option is recommended for those modules which contain code which must be executed fast (e.g. interrupt functions).

With -OF you produce small code. Favour code density above execution speed. If -OF is specified, cc51 calls a run time library routine for a number of integer operations and index calculations of external RAM objects.

Example:

/*
 * Compile with -OF -O0, produce small code, call
 *                       run time library routine
 * Compile with -Of -O0, produce fast code
 */

extern _xdat char arr[];

void
main( void )
{
      unsigned char c;

      arr[c] = 'x';
}

Pragmas speed, size and optimize in the section 4.4, Pragmas.

-Oh / -OH

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Optimization. Select the Custom optimization level. Enable or disable the option Peephole optimizer (remove redundant code).

-Oh / -OH

Pragma:

#pragma optimize h
#pragma optimize H

Default:

-Oh

Description:

With -Oh you enable peephole optimization. Remove redundant code.

With -OH you disable peephole optimization.

Example:

/*
 * Compile with -OH, unnecessary instructions found
 * Compile with -Oh, unnecessary instructions removed by
 *  peephole optimizer
 *
 * Peephole optimizer searches for patterns in the generated
 * code. E.g.
 *    MOVX @DPTR,A
 *    MOV A, ACC
 *   does not need the MOV, while the value is still in A.
 */

_xdat int i;
void
main( void )
{
      i = 0x202;
}

Pragma optimize in section 4.4 , Pragmas.

-Oi / -OI

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Optimization. Select the Custom optimization level. Enable or disable the option Move invariant code outside loop.

-Oi / -OI

Pragma:

#pragma optimize i
#pragma optimize I

Default:

-Oi

Description:

With -Oi you move invariant code outside a loop. Note that the option -Oc must be on to use this option.

With -OI you disable moving invariant code outside a loop.

Example:

/*
 * Compile with -OI -Oc -O0, normal cse is done
 * Compile with -Oi -Oc -O0, invariant code is found in
 *    the loop, code is moved outside the loop.
 */
void
main( void )
{
      char x, y, a, b;
      int i;

      for( i=0; i<20; i++ )
      {
            x = a + b;
            y = a + b;
      }
}

-Oc
Pragma optimize in section 4.4, Pragmas.

-Ok / -OK

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Optimization. Select the Custom optimization level. Enable or disable the option Optimize into compound assignments.

-Ok / -OK

Pragma:

#pragma optimize k
#pragma optimize K

Default:

-Ok

Description:

With -Ok you optimize into compound assignments.

With -OK you do not optimize into compound assignments.

Example:

/*
 * Compile with -OK -O0, only second statement is compound
 *                 assignment
 * Compile with -Ok -O0, first statement is optimized in
 *                 compound assignment
 */

unsigned _pdat int i;

void
main( void )
{
      i = i + 1;
      i += 1;            /* compound assignment */
}

Pragma optimize in section 4.4 , Pragmas.

-Ol / -OL

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Optimization. Select the Custom optimization level. Enable or disable the option Fast loops (more code size).

-Ol / -OL

Pragma:

#pragma optimize l
#pragma optimize L

Default:

-OL

Description:

With -Ol you enable fast loops. Duplicate the loop condition. Evaluate the loop condition one time outside the loop, just before entering the loop, and at the bottom of the loop. This saves one unconditional jump and gives less code inside a loop.

With -OL you disable fast loops.

Example:

/*
 * Compile with -OL -O0
 * Compile with -Ol -O0, compiler duplicates the loop
 * condition, the unconditional jump is removed.
 */
int i;

void
main( void )
{
      for( ; i<10; i++ )
      {
            do_something();
      }
}

Pragma optimize in section 4.4 , Pragmas.

-Om / -OM

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Optimization. Select the Custom optimization level. Enable or disable the option Code order rearranging in flow optimization.

-Om / -OM

Pragma:

#pragma optimize m
#pragma optimize M

Default:

-Om

Description:

With -Om you enable code rearranging. Try to move (sub)expressions to get faster code. Some debuggers may have difficulties with such options.

With -OM you disable code rearranging.

Example:

/*
 * Compile with -OM -O0, code as written sequential
 * Compile with -Om -O0, code is rearranged
 *
 * Code rearranging enables other optimizations to
 * optimize better, e.g. CSE
 */

int   i;
extern      void  dummy( void );

void main ()
{
      do
      {
            if    ( i )
            {
                  i--;
            }
            else
            {
                  i++;
                  break;
            }
            dummy();
      } while ( i );
}

Pragma optimize in section 4.4 , Pragmas.

-Op / -OP

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Optimization. Select the Custom optimization level. Enable or disable the option Extra flow optimization pass.

-Op / -OP

Pragma:

#pragma optimize p
#pragma optimize P

Default:

-Op

Description:

With -Op you enable control flow optimizations on the intermediate code representation, such as jump chaining and conditional jump reversal.

With -OP you disable control flow optimizations.

Example:

/*
 * Compile with -OP -O0
 * Compile with -Op -O0, compiler finds first time 'i' is
 * always < 10, the unconditional jump is removed.
 */
int i;

void
main( void )
{
      for( i=0; i<10; i++ )
      {
            do_something();
      }
}

Pragma optimize in section 4.4 , Pragmas.

-Or / -OR

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Optimization. Select the Custom optimization level. Enable or disable the option Use register parameter passing (R2-R7).

-Or / -OR

Pragma:

#pragma optimize r
#pragma optimize R

Default:

-Or

Description:

With -Or you specify to use real register parameter passing. cc51 will treat all function prototypes and function declarations which are not explicitly programmed _regparm or _cdecl as _regparm functions.

With -OR cc51 will treat all function prototypes and function declarations which are not explicitly programmed _regparm or _cdecl as _cdecl functions.

Example:

/* Compile with -OR -O0, parameters are passed in fixed memory areas
 * Compile with -Or -O0, compiler uses register parameter passing
 */
extern int func( char, int );

void
main( void )
{
      char c;
      int x, y;

      x = func( c, y );
}

Section Function Parameters for details on parameter passing.
Pragma optimize in section 4.4, Pragmas.

-Os / -OS

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Optimization. Select the Custom optimization level. Enable or disable the option Optimize initialization loops.

-Os / -OS

Pragma:

#pragma optimize s
#pragma optimize S

Default:

-Os

Description:

With -Os you optimize initialization loops. Replace an initialization loop by a _memset() routine.

With -OS you do not optimize initialization loops.

Example:

/*
 * Compile with -OS, loop code is found
 * Compile with -Os, loop is found to be an initialization
 * loop, code is generated as for the inline '_memset' function
 */

char arr[20];

void
main( void )
{
      unsigned char c;

      for( c=0; c<20; c++ )
            arr[c] = 0;

      _memset( arr, 0, 20 );
}

Pragma optimize in section 4.4 , Pragmas.

-Ot / -OT

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Optimization. Select the Custom optimization level. Enable or disable the option Keep variables in the order of declaration.

-Ot / -OT

Pragma:

#pragma optimize t
#pragma optimize T

Default:

-Ot

Description:

With -Ot you allocate a tentative object at the point of programming. Normally all tentative object allocations are delayed by the compiler until the end of the module. With this option set, the allocation is done immediately. This enables the compiler to optimize access to the objects. Objects are forced to remain in the same order.

With -OT you keep a tentative declaration tentative until the end of the module. The compiler cannot optimize access to these objects.

Example:

/*
 * Compile with -OT -O0, space for 'a' and 'b' is
 *    allocated at end of module
 * Compile with -Od -O0, space for 'a' and 'b' is
 *    allocated at point of programming. compiler knows
 *    that 'b' is located after 'a', so DPTR can be
 *    incremented
 */
_xdat char a;
_xdat char b;

void
main( void )
{
      char c;

      c = a + 5;
      b = 10;
}

Pragma optimize in section 4.4 , Pragmas.

-Ov / -OV

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Optimization. Select the Custom optimization level. Enable or disable the option Loop variable optimization.

-Ov / -OV

Pragma:

#pragma optimize v
#pragma optimize V

Default:

-OV

Description:

With -Ov you enable loop variable detection. With this option specified, the compiler tries to detect within a loop which variable is the loop variable. When possible, this variable is temporarily moved into registers.

With -OV you disable loop variable detection.

Example:

/*
 * Compile with -OV -O0, loop variable 'i' is an automatic
 * Compile with -Ov -O0, loop variable 'i' is temporarily
 *                       moved into registers.
 */
int j;

void
main( void )
{
      int i;
      for( i=0; i<10; i++ )
      {
            j = 2 * i;
      }
}

-Oc
Pragma optimize in section 4.4, Pragmas.

-Ow / -OW

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Optimization. Select the Custom optimization level. Enable or disable the option Allow register automatic variables (R0-R7).

-Ow / -OW

Pragma:

#pragma optimize w
#pragma optimize W

Default:

-Ow

Description:

With -Ow you allow cc51 to use register variables. Of course this cannot be done when all registers are in use.

With -OW you do not allow cc51 to use register variables.

Example:

/*
 * Compile with -OW -O0, variables are not allowed in registers
 * Compile with -Ow -O0, variables are allowed in registers.
 *  'k' is still an automatic, because all registers are in use
 */

void
main( void )
{
      int i, j, k;

      k = i * j;
}

Pragma optimize in section 4.4 , Pragmas.

-o

Option:

EDE determines the name of the output file with the same basename as the source file and extension .src.

-o file

Arguments:

An output filename. The filename may not start immediately after the option. There must be a tab or space in between.

Default:

Module name with .src suffix.

Description:

Use name as output file name, instead of the module name with .src suffix. Special care must be taken when using this option, the first -o option found acts on the first file to compile, the second -o option acts on the second file to compile, etc.

Example:

When specified:

two files will be created, file3.src for the compiled file file1.c and file2.src for the compiled file file2.c.

-pa / -pd / -pp / -ps

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Code Generation. Select one of the Data Pointer options.

-p{a|d|p|s}

Description:

The standard 8051 architecture provides just one 16-bit pointer for indirect addressing of external memory (DPTR). At this moment there are several architectures supporting more than just one data pointer. The Infineon Technologies C500/C800 family has support for 8 16-bit data pointers (-ps). The following derivatives have support for 2 16-bit data pointers: the Atmel AT8x53/AT89S53/AT89S4D12/AT89S8252 (-pa), the Dallas 80C320/520/530 and AMD 80C521 (-pd), and the Philips 51 family (-pp).

Example:

To specify to use 8 16-bit data pointers, enter:

Section Multiple Data Pointer Support in chapter Run-time Environment.

-R

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Miscellaneous. Add the option to the Additional C Compiler options field.

-Rmem[=name]

Arguments:

A memory space, optionally followed by a segment name. mem can be one of:

mem Description
bi _bit
da _data
id _idat
pd _pdat
xd _xdat
co constant (_rom)
ba bitaddressable (_bdat)
pr program (_rom)

Table 4-4: Memory spaces

Description:

The compiler defaults to a segment naming convention, using 'C51_' and a two letter memory type abbreviation: C51_PR for executable code, C51_XD for static external RAM etc. In case a module must be loaded at a fixed address or a data segment needs a special place in memory, the -R option enables the user to generate a unique segment name. In this way the order LINK51 allocates these segments can be specified in a linker command file.

If mem is specified without a name, the module name is used instead of C51_, otherwise name_ is used.

Notice, that when rom size medium is used, the compiler implies a -Rpr, which means a (unique) code segment name is emitted using the module name and having the INBLOCK attribute.

mem is the same as specified with the -m option.

Example:

To create a new segment name (NEW_DA) for DATA segments, enter:

-r

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Memory Model. Choose a Code size limits (ROM model) option.

-rromsize

Arguments:

A single character specifying the rom size. romsize can be one of:

s (small: 2K program)
m (medium: 2K modules, 64K program)
l (large: 64K modules, 64K program)

Default:

-rl

Description:

Select the way function calls and non short jumps are generated. cc51 always tries to use the sjmp instruction. If the distance is larger than 127 bytes, either an ajmp, generic jmp or ljmp is emitted. For function calls (including library calls) the same decision is made: acall, generic call or lcall. Code generated for small model is more efficient than medium model, which in turn is more efficient than large model:

s The complete application (C run time library included) is assumed to fit into one 2K byte block. The compiler emits acall for calls and ajmp for non short jumps.

m This option implies a -Rpr, which means cc51 uses the module name for the declaration of the CODE segment and assigns this segment the INBLOCK attribute. This means link51 allocates this segment within a 2K bank. The size of the C module may of course not exceed 2048 bytes. cc51 emits generic call and jmp instructions, which are translated by asm51 into acall/ajmp for calls and jumps within the module (read within the same segment), and to lcall/ljmp for external calls and jumps. This approach is only useful with a large number of 'small' (approx. 400 bytes) C modules, because link51 must allocate each of these segments within a 2K bank. If larger modules are used, a gap may be introduced. When using rom size medium, cc51 reports code size with a 'high estimate' (worst case) remark, because it does not know how the generic call/jmp instructions are going to be translated by the assembler.

l The C module will be larger than 2K bytes. The compiler emits lcall and ljmp instructions.

The -rm option is ignored for all static models.

Example:

cc51 -rm -Mr test.c

-S

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Allocation. Select the Keep strings in ROM (use _rom keyword for a pointer to a string) radio button.

-S

Pragma:

#pragma romstring

Description:

Put strings in ROM only.

By default, strings are allocated in both ROM and RAM. Strings are copied from ROM to RAM by the C startup code.

Example:

cc51 -S test.c

Pragmas romstring and ramstring in the section 4.4, Pragmas.
Section Strings

-s

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Miscellaneous. Enable the option Merge C source code with assembly in output file (.src).

-s

Pragma:

#pragma source

Description:

Merge C source code with generated assembly code in output file.

Example:

cc51 -s test.c
; test.c      3 int    i;
        PUBLIC  _i
_i:     DS      2
; test.c      4
; test.c      5 main ()
; test.c      6 {
        PUBLIC  _?main
TEST_MAIN_PR    SEGMENT CODE
        RSEG    TEST_MAIN_PR
_?main:

Pragmas source and nosource in the section 4.4, Pragmas.

-se

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Language Extensions. Enable the option Allow enum objects of type 'char'.

-se

Description:

Treat small enumerated types as char instead of int.

Example:

cc51 -se test.c

-t

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Miscellaneous. Enable the option Display module summary.

-t

Description:

Produce totals (module summary).

Example:

cc51 -t test.c
8051 C compiler vx.y rz      SN00000000-015 (c) year TASKING, Inc.
                        
MODULE SUMMARY          STATIC      OVERLAYABLE (LIMIT)

Code size   =     49          (65536)
Constant size     =     0           (65536)
Direct variable size    =     4     0     (  128)
Indirect variable size  =     0     0     (  128)
Paged auxiliary size    =     0     0     (  256)
Bit size    =     1     0     (  128)
Bit addressable size    =     2     0     (   16)
Auxiliary variable size =     0     0     (65536)
Interrupts used:
Register banks used:          0

processed 25 lines at 7075 lines/min

-U

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Preprocessing. Undefine one or more of the predefined symbols _MODEL or _CC51 by disabling the corresponding option.

-Uname

Arguments:

The name macro you want to undefine.

Description:

Remove any initial definition of identifier name as in #undef, unless it is a predefined ANSI standard macro. ANSI specifies the following predefined symbols to exist, which cannot be removed:

__FILE__ "current source filename"

__LINE__ current source line number (int type)

__TIME__ "hh:mm:ss"

__DATE__ "Mmm dd yyyy"

__STDC__ level of ANSI standard (because cc51 has a number of language extensions and 8051 specific implementations, this value is set to 0)

When cc51 is invoked, also the following predefined symbols exist:

_CC51 value represents version of TASKING C 8051 compiler.

_MODEL memory model used (see Memory Models for details)

These symbols can be turned off with the -U option.

Example:

cc51 -UNORAM test.c

-D

-u

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Language Extensions. Enable the option Treat 'char' variables as unsigned.

-u

Description:

Treat 'character' type variables as 'unsigned character' variables. By default char is the same as specifying signed char. With -u char is the same as unsigned char.

Example:

With the following command char is treated as unsigned char:

-V

Option:

-V

Description:

Display version information.

Example:

cc51 -V
TASKING 8051 C compiler     vx.yrz Build nnn
Copyright years Altium BV   Serial# 00000000

-v

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Code Generation. Disable the option Generate code for interrupt vector.

-v

Pragma:

#pragma novector

Description:

Do not generate code for interrupt vector and reference to interrupt handler in the run-time library.

This option also disables option -ivo.

Example:

cc51 -v test.c

Options -ivo and -vf

Pragmas vector and novector in the section 4.4, Pragmas.

Section 7.7, Interrupt Functions in chapter Run-time Environment.

-vf

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Code Generation. Disable the option Generate frame for interrupt handler.

-vf

Description:

Do not generate interrupt frame for interrupt handler.

Example:

cc51 -vf test.c

Section 7.7 , Interrupt Functions in chapter Run-time Environment.

-vo

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Miscellaneous. Add the option to the Additional C Compiler options field.

-vo

Description:

Generate old style interrupt frame. This option is available for backwards compatibility only.

Example:

cc51 -vo test.c

Section 7.7 , Interrupt Functions in chapter Run-time Environment.

-w / -wstrict

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Warnings. Select the Suppress specific warnings option and optionally fill in specific message numbers to suppress.

-w[num]
-wstrict

Arguments:

Optionally the warning number to suppress.

Description:

-w suppress all warning messages. -wnum only suppresses the given warning. -wstrict suppresses all "strict" warning messages (183, 196).

Example:

To suppress warning 135, enter:

-x

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Allocation. Enter a size in the Amount of DATA for automatics (overlayable) field.

-xsize

Pragma:

#pragma extend size

Arguments:

A number of bytes.

Default:

-x4

Description:

Extend amount of internal RAM for automatics.

Example:

To reserve 10 bytes of internal RAM for automatics, enter:

Pragma extend in the section 4.4 , Pragmas.

Option -c

-z

Option:

From the Project menu, select Project Options... Expand the C Compiler entry and select Miscellaneous. Add the option to the Additional C Compiler options field.

-zpragma

Arguments:

A pragma as listed in section 4.4, Pragmas.

Description:

With this option you can give a pragma on the command line. This is the same as specifying '#pragma pragma' in the C source. Dashes ('-') on the command line in the pragma are converted to spaces. A dash prefixed by another dash or space is never translated, so it is still possible to specify a dash for negative numbers as pragma argument.

Example:

To issue a '#pragma intsave R0' using the command line, enter:

The '-' between insave and R0 is converted to a space.

Section 4.4 , Pragmas.

4.3 Include Files

You may specify include files in two ways: enclosed in <> or enclosed in "". When an #include directive is seen, cc51 uses the following algorithm trying to open the include file:

1. If the filename is enclosed in "", and it is not an absolute pathname (does not begin with a '\' for PC, or a '/' for UNIX), the include file is searched for in the directory of the file containing the #include line. For example, in:

PC:

UNIX:

cc51 first searches in the directory ..\..\source (../../source for UNIX) for include files.

If you compile a source file in the directory where the file is located (cc51 test.c), the compiler searches for include files in the current directory.

This first step is not done for include files enclosed in <>.

2. Use the directories specified with the -I options, in a left-to-right order. For example:

Select the Project | Directories... menu item. Add one or more directory paths to the Include Files Path field.

PC:

UNIX:

3. Check if the environment variable CC51INC exists. If it does, use the contents as a directory specifier for include files. You can specify more than one directory in the environment variable CC51INC by using a separator character. Instead of using -I as in the example above, you can specify the same directory using CC51INC:

PC:

UNIX:

     CC51INC=../../include
     export CC51INC
     cc51 message.c
     setenv CC51INC ../../include
     cc51 message.c

4. When an include file is not found with the rules mentioned above, the compiler tries the subdirectory include, one directory higher than the directory containing the cc51 binary. For example:

PC:

UNIX:

The compiler determines run-time which directory the binary is executed from to find this include directory.

A directory name specified with the -I option or in CC51INC may or may not be terminated with a directory separator, because cc51 inserts this separator, if omitted.

When you specify more than one directory to the environment variable CC51INC, you have to use one of the following separator characters:

PC:

UNIX:

4.4 Pragmas

According to ANSI (3.8.6) a preprocessing directive of the form:

causes the compiler to behave in an implementation-defined manner. The compiler ignores pragmas which are not mentioned in the list below. Pragmas give directions to the code generator of the compiler. Besides the pragmas there are two other possibilities to steer the code generator: command line options and keywords. The compiler acknowledges these three groups using the following rule:

Command line options can be overruled by keywords and pragmas. Keywords can be overruled by pragmas. So, pragmas have the highest priority.

This approach makes it possible to set a default optimization level for a source module, which can be overridden temporarily within the source by a pragma. For example, on the command line you have given option -O1 (default optimizations). You can, for example, disable CSE checking in (part of) a source module by specifying #pragma optimize C in the source.

cc51 supports the following pragmas:

alias

Default. Same as -OA option. Perform strict alias checking. See also section 4.5 Alias .

noalias

Same as -Oa option. Relax alias checking.

arglist size

Same as -a option. Change the allocation size for variable argument lists. Only useful in the static models.

asm

Insert the following (non preprocessor lines) as assembly language source code into the output file. The inserted lines are not checked for their syntax.

asm_noflush

Same as asm, except that the peephole optimizer does not flush the code buffer and assumes register contents remain valid.

endasm

Switch back to the C language.

cse size

Same as -coption. Change the maximum allocation size to store CSE values in.

extend size

Same as -x option. Specify the maximum size of internal RAM to be used for 'automatic variables' to be made 'register variables'. See also section 3.6, Automatic Variables.

intsave registers

When using assembly in an interrupt function you can save registers that are not automatically saved by the compiler. See also section 7.7 Interrupt Functions in chapter Run-time Environment.

listinc

Same as -li option. Expand include files in generated list file. Only useful with -l option and include files containing executable statements.

nolistinc

Default. Do not expand include files in list file.

linear_switch

Force the compiler to generate linear jump code for switch statements. See also section 3.21, Switch Statement.

jump_switch

Force the compiler to generate jump tables for switch statements. See also section 3.21, Switch Statement.

binary_switch

Force the compiler to generate binary search tables for switch statements. See also section 3.21, Switch Statement.

smart_switch

Default. The compiler decides what code to generate on a switch statement. In general, the compiler chooses the smallest method. See also section 3.21, Switch Statement.

optimize flags

Controls the amount of optimization. The remainder of the source line is scanned for option characters, which are processed like the flags of the -O command line option. Please refer to the -O option for a list of available flags.

For example, specifying -Oc on the command line, is the same as specifying #pragma optimize c at the beginning of a source file.

ramstring

Default. Allocate strings in ROM and RAM. The strings are copied to RAM at startup.

romstring

Same as -S option. Allocate strings in ROM only.

size

Default. Same as -OF option. Favour code density above execution speed.

speed

Same as -Of option. Favour execution speed above code density.

source

Same as -s option. Enable mixing C source with assembly code.

nosource

Default. Disable generation of C source within assembly code.

vector [value]

Default. Restore generation of interrupt vector after a novector pragma. With the value this pragma is the same as the -ivo option

novector

Same as -v option. Do not emit interrupt vector and reference to interrupt handler in run-time library.

4.5 Alias

By default the compiler assumes that each pointer may point to any object created in the program, so when any pointer is dereferenced, all register contents are assumed to be invalid afterwards.

When it is known that aliasing problems do not occur in the written C-source, alias checking may be relaxed ( use the -Oa option or #pragma noalias). Relaxing alias checking may reduce code size.

Example 1:

void
func( int i )
{
   char     * p;
   char     c;
   char     d;

   if( i )
      p = &c;
   else
      p = &d;

   c = 2;
   d = 3;

   *p = 4;  /* may write to 'c' or 'd'          */
            /* --> aliasing object 'c' or 'd'   */

   i = c;   /* '*p' might have changed the value of 'c',    */
            /* so 'c' may not be used from register         */
            /* contents, but MUST be read from memory       */
            /* --> alias checking MUST be ON in this case   */
}

Example 2:

void
func( int i, char *p )
{
   char     c;
   char     d;

   c = 2;
   d = 3;

   *p = 4;  /* cannot write to 'c' or 'd', but to some other object */

   i = c;   /* '*p' cannot have changed the value of 'c',   */
            /* so 'c' may be used from register contents    */
            /* --> alias checking may be OFF in this case   */
}

4.6 Compiler Limits

The ANSI C standard [1-2.2.4] defines a number of translation limits, which a C compiler must support to conform to the standard. The standard states that a compiler implementation should be able to translate and execute a program that contains at least one instance of every one of the following limits, (cc51's actual limits are given within parentheses):

As far as the compiler implementation uses fixed tables, they will be large enough to meet the standards limits. However, most of the internal structures and tables of the compiler are dynamic. Thus the actual compiler limits are determined by the amount of free memory in the system.


Copyright © 2002 Altium BV