- •Chapter 1. Introduction
- •Support for all 8051 Variants
- •Books About the C Language
- •Chapter 2. Compiling with the Cx51 Compiler
- •Environment Variables
- •Running Cx51 from the Command Prompt
- •ERRORLEVEL
- •Cx51 Output Files
- •Control Directives
- •Directive Categories
- •Reference
- •Chapter 3. Language Extensions
- •Keywords
- •Memory Areas
- •Program Memory
- •Internal Data Memory
- •External Data Memory
- •Far Memory
- •Special Function Register Memory
- •Memory Models
- •Small Model
- •Compact Model
- •Large Model
- •Memory Types
- •Explicitly Declared Memory Types
- •Implicit Memory Types
- •Data Types
- •Bit Types
- •Special Function Registers
- •sbit
- •Absolute Variable Location
- •Pointers
- •Generic Pointers
- •Pointer Conversions
- •Abstract Pointers
- •Function Declarations
- •Function Parameters and the Stack
- •Passing Parameters in Registers
- •Function Return Values
- •Specifying the Memory Model for a Function
- •Specifying the Register Bank for a Function
- •Register Bank Access
- •Interrupt Functions
- •Reentrant Functions
- •Chapter 4. Preprocessor
- •Directives
- •Stringize Operator
- •Predefined Macro Constants
- •Chapter 5. 8051 Derivatives
- •Analog Devices MicroConverter B2 Series
- •Atmel 89x8252 and Variants
- •Dallas 80C320, 420, 520, and 530
- •Arithmetic Accelerator
- •Data Pointers
- •Library Routines
- •Philips 8xC750, 8xC751, and 8xC752
- •Philips 80C51MX Architecture
- •Philips and Atmel WM Dual DPTR
- •Customization Files
- •STARTUP.A51
- •INIT.A51
- •XBANKING.A51
- •Basic I/O Functions
- •Memory Allocation Functions
- •Optimizer
- •General Optimizations
- •Options for Code Generation
- •Segment Naming Conventions
- •Data Objects
- •Program Objects
- •Interfacing C Programs to Assembler
- •Function Parameters
- •Parameter Passing in Registers
- •Parameter Passing in Fixed Memory Locations
- •Function Return Values
- •Using the SRC Directive
- •Register Usage
- •Overlaying Segments
- •Example Routines
- •Small Model Example
- •Compact Model Example
- •Large Model Example
- •Data Storage Formats
- •Bit Variables
- •Signed and Unsigned Long Integers
- •Generic and Far Pointers
- •Floating-point Numbers
- •Accessing Absolute Memory Locations
- •Absolute Memory Access Macros
- •Linker Location Controls
- •The _at_ Keyword
- •Debugging
- •Chapter 7. Error Messages
- •Fatal Errors
- •Actions
- •Errors
- •Syntax and Semantic Errors
- •Warnings
- •Chapter 8. Library Reference
- •Intrinsic Routines
- •Library Files
- •Standard Types
- •va_list
- •Absolute Memory Access Macros
- •CBYTE
- •CWORD
- •DBYTE
- •DWORD
- •FARRAY, FCARRAY
- •FVAR, FCVAR,
- •PBYTE
- •PWORD
- •XBYTE
- •XWORD
- •Routines by Category
- •Buffer Manipulation
- •Character Conversion and Classification
- •Data Conversion
- •Math Routines
- •Memory Allocation Routines
- •Stream Input and Output Routines
- •String Manipulation Routines
- •Miscellaneous Routines
- •Include Files
- •8051 Special Function Register Include Files
- •ABSACC.H
- •ASSERT.H
- •CTYPE.H
- •INTRINS.H
- •MATH.H
- •SETJMP.H
- •STDARG.H
- •STDDEF.H
- •STDIO.H
- •STDLIB.H
- •STRING.H
- •Reference
- •Compiler-related Differences
- •Library-related Differences
- •Appendix B. Version Differences
- •Version 6.0 Differences
- •Version 5 Differences
- •Version 4 Differences
- •Version 3.4 Differences
- •Version 3.2 Differences
- •Version 3.0 Differences
- •Version 2 Differences
- •Appendix C. Writing Optimum Code
- •Memory Model
- •Variable Location
- •Variable Size
- •Unsigned Types
- •Local Variables
- •Other Sources
- •Appendix D. Compiler Limits
- •Appendix E. Byte Ordering
- •Recursive Code Reference Error
- •Problems Using the printf Routines
- •Uncalled Functions
- •Using Monitor-51
- •Trouble with the bdata Memory Type
- •Function Pointers
- •Glossary
- •Index
20 |
Chapter 2. Compiling with the Cx51 Compiler |
|
|
Control Directives
The Cx51 compiler offers a number of control directives that you may use to control compilation. Directives are composed of one or more letters or digits and, unless otherwise specified, can be specified after the filename on the command line or within a source file using the #pragma directive. For example:
2 |
C51 testfile.c SYMBOLS |
CODE |
DEBUG |
#pragma SYMBOLS CODE DEBUG |
|
||
|
In the above examples, SYMBOLS, |
CODE, and DEBUG are all control directives. |
|
|
testfile.c is the source file to be compiled. |
||
|
|
|
|
|
NOTE |
|
|
|
The syntax is the same for the command line and the #pragma directive. |
||
|
Multiple options, however, |
may be specified on the #pragma line. |
|
Typically, each control directive may be specified only once at the beginning of a source file. If a directive is specified more than once, the compiler generates a fatal error and aborts compilation. Directives that may be specified more than once are so noted in the following sections.
Directive Categories
Control directives can be divided into three groups: source controls, object controls, and listing controls.
Source controls define macros on the command line and determine the name of the file to be compiled.
Object controls affect the form and content of the generated object module (*.OBJ). These directives allow you to specify the optimizing level or include debugging information in the object file.
Listing controls govern various aspects of the listing file (*.LST), in particular its format and specific content.
Keil Software — Cx51 Compiler User’s Guide |
21 |
|
|
The following table is an alphabetical list of the control directives. The underlined characters denote the abbreviation of the directive.
Directive |
Class |
|
Description |
|
|
|
AREGS, |
Object |
|
Enable or disable absolute register (ARn) addressing. |
|
|
|
NOAREGS |
Source |
|
Marks the beginning and the end of an inline assembly block. |
|
|
|
ASM, ENDASM |
|
|
|
2 |
||
BROWSE † |
Object |
|
Enable generation of browser information. |
|
|
|
CODE † |
Listing |
|
Add an assembly listing to the listing file. |
|
|
|
COMPACT † |
Object |
|
Select COMPACT memory model. |
|
|
|
COND, |
Listing |
|
Include or exclude source lines skipped by the preprocessor. |
|
|
|
NOCOND † |
|
|
|
|
|
|
DEBUG † |
Object |
|
Include debugging information in the object file. |
|
|
|
DEFINE |
Source |
|
Define preprocessor names in the Cx51 invocation line. |
|
|
|
DISABLE |
Object |
|
Disables interrupts for the duration of a function. |
|
|
|
EJECT |
Listing |
|
Inserts a form feed character into the listing file. |
|
|
|
FLOATFUZZY |
Object |
|
Specify number of bits rounded during floating compare. |
|
|
|
INCDIR † |
Source |
|
Specify additional path names for include files. |
|
|
|
INTERVAL † |
Object |
|
Specify the interval for interrupt vectors for SIECO chips. |
|
|
|
INTPROMOTE, |
Object |
|
Enable or disable ANSI integer promotion. |
|
|
|
NOINTPROMOTE † |
|
|
|
|
|
|
INTVECTOR, |
Object |
|
Specify base address for interrupt vectors or disable vectors. |
|
|
|
NOINTVECTOR † |
|
|
|
|
|
|
LARGE † |
Object |
|
Select LARGE memory model. |
|
|
|
LISTINCLUDE |
Listing |
|
Display contents of include files in the listing file. |
|
|
|
MAXARGS † |
Object |
|
Specify size of variable argument lists. |
|
|
|
MOD517, |
Object |
|
Enable or disable code to support the additional hardware |
|
|
|
NOMOD517 |
|
|
features of the 80C517 and derivatives. |
|
|
|
MODA2, |
Object |
|
Enable or disable dual DPTR register support for Atmel 82x8252 |
|
|
|
NOMODA2 |
|
|
and variants. |
|
|
|
MODAB2, |
Object |
|
Enable or disable dual DPTR register support for Analog Device |
|
|
|
NOMODAB2 |
|
|
MicroConverter ADuC B2 series. |
|
|
|
MODDA, |
Object |
|
Enable or disable code to support the arithmetic accelerator |
|
|
|
NOMODDA |
|
|
available in Dallas 80C390, 80C400, and 5240. |
|
|
|
MODDP2, |
Object |
|
Enable or disable dual DPTR register support for Dallas |
|
|
|
NOMODDP2 |
|
|
Semiconductor 320, 520, 530, 550 and variants. |
|
|
|
MODP2, |
Object |
|
Enable or disable dual DPTR register support for Philips and |
|
|
|
NOMODP2 |
|
|
AtmelWM derivatives. |
|
|
|
NOAMAKE † |
Object |
|
Disable information records for Vision2 Update function. |
|
|
|
NOEXTEND † |
Source |
|
Disable Cx51 extensions to ANSI C. |
|
|
|
OBJECT, |
Object |
|
Specify a name for the object file or suppress the object file. |
|
|
|
NOOBJECT † |
|
|
|
|
|
|
OBJECTEXTEND † |
Object |
|
Include additional variable type information in the object file. |
|
|
|
ONEREGBANK |
Object |
|
Assume that only registerbank 0 is used in interrupt code. |
|
|
|
|
|
22 |
|
|
Chapter 2. Compiling with the Cx51 Compiler |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Directive |
Class |
Description |
|
|
|
|
OMF2 † |
Object |
Generate OMF2 output file format. |
|
|
|
|
OPTIMIZE |
Object |
Specify the level of optimization performed by the compiler. |
|
|
|
|
ORDER † |
Object |
Allocate variables in the order of their appearance in the source |
|
|
|
|
|
|
file. |
|
|
|
|
PAGELENGTH † |
Listing |
Specify the number of rows on the page. |
|
2 |
|
|
PAGEWIDTH † |
Listing |
Specify the number of columns on the page. |
|
|
|
PREPRINT † |
Listing |
Produce a preprocessor listing file where all macros are |
|
|
|
|
|
|
|
expanded. |
|
|
|
|
PRINT, NOPRINT † |
Listing |
Specify a name for the listing file or disable the listing file. |
|
|
|
|
REGFILE † |
Object |
Specify a register definition file for global register optimization. |
|
|
|
|
REGISTERBANK |
Object |
Select the register bank to use for absolute register accesses. |
|
|
|
|
REGPARMS, |
Object |
Enable or disable register parameter passing. |
|
|
|
|
NOREGPARMS |
|
|
|
|
|
|
RET_PSTK †, |
Object |
Use reentrant stack for saving return addresses. |
|
|
|
|
RET_XSTK † |
|
|
|
|
|
|
ROM † |
Object |
Control generation of AJMP/ACALL instructions. |
|
|
|
|
SAVE, |
Object |
Saves and restores settings for AREGS, REGPARMS and |
|
|
|
|
RESTORE |
|
OPTIMIZE directives. |
|
|
|
|
SMALL † |
Object |
Select SMALL memory model. (Default.) |
|
|
|
|
SRC † |
Object |
Create an assembler source file instead of an object module. |
|
|
|
|
STRING † |
Object |
Locate implicit string constants to xdata or far memory. |
|
|
|
|
SYMBOLS † |
Listing |
Include a list of all symbols used within the module in the listing |
|
|
|
|
|
|
file. |
|
|
|
|
USERCLASS † |
Object |
Renames memory class names for flexible variable location. |
|
|
|
|
VARBANKING † |
Object |
Enable far memory type variables. |
|
|
|
|
WARNINGLEVEL † |
Listing |
Select the level of Warning detection. |
|
|
|
|
XCROM † |
Object |
Assume ROM space for const xdata variables. |
|
† These directives may be specified only once on the command line or at the beginning of a source file using in the #pragma statement. They may not be used more than once in a source file.
Control directives and their arguments, with the exception of arguments specified with the DEFINE directive, are not case sensitive.
