
- •Chapter 1. Introduction
- •Books About the C Language
- •Chapter 2. Compiling with C51
- •Environment Settings
- •Running C51
- •DOS ERRORLEVEL
- •C51 Output Files
- •Control Directives
- •Directive Categories
- •Reference
- •Chapter 3. Language Extensions
- •Keywords
- •8051 Memory Areas
- •Program Memory
- •Internal Data Memory
- •External Data 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
- •Dallas 80C320, 80C520, and 80C530
- •Siemens 80C517 and 80C537
- •Data Pointers
- •Library Routines
- •Philips/Signetics 8xC750, 8xC751, and 8xC752
- •Customization Files
- •STARTUP.A51
- •START751.A51
- •INIT.A51
- •INIT751.A51
- •PUTCHAR.C
- •GETKEY.C
- •CALLOC.C
- •FREE.C
- •INIT_MEM.C
- •MALLOC.C
- •REALLOC.C
- •Optimizer
- •General Optimizations
- •8051 Specific 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 Pointers
- •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
- •PBYTE
- •PWORD
- •XBYTE
- •XWORD
- •Routines by Category
- •Buffer Manipulation
- •Character Conversion and Classification
- •Data Conversion
- •Math
- •Memory Allocation
- •Stream Input and Output
- •String Manipulation
- •Miscellaneous
- •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
- •Appendix A. Differences from ANSI C
- •Compiler-related Differences
- •Library-related Differences
- •Appendix B. Version 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
- •Trouble with the bdata Memory Type
- •Using Monitor-51
- •Function Pointers
- •Glossary
- •Index

4 Chapter 2. Compiling with C51
Running C51
To invoke the C51 compiler, type C51 at the DOS prompt. On this command line, you must include the name of the C source file to be compiled, as well as any other necessary control directives required to compile your source file. The format for the C51 command line is:
2 |
C51 sourcefile |
!directives…" |
|
||
|
where: |
|
|
sourcefile |
is the name of the source program you want to compile. |
|
directives |
are the directives you want to use to control the function of |
|
|
the compiler. Refer to “Control Directives” on page 6 for a |
|
|
detailed list of the available directives. |
The following command line example invokes C51, specifies the source file and uses the controls DEBUG, CODE, and PREPRINT.
C51 SAMPLE.C DEBUG CODE PREPRINT
The C51 compiler displays the following information upon successful invocation and compilation.
MS-DOS C51 COMPILER V5.0
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)

Keil Software — C51 Compiler User’s Guide |
5 |
|
|
DOS ERRORLEVEL
After compilation, the number of errors and warnings detected is output to the screen. C51 then sets the DOS ERRORLEVEL to indicate the status of the compilation. Values are listed in the following table:
ERRORLEVEL |
Meaning |
2 |
|
|
|
||
0 |
No errors or warnings |
||
|
1Warnings only
2Errors and possibly warnings
3Fatal errors
You can access the ERRORLEVEL variable in DOS batch files. Refer to your DOS user’s guide for more information on ERRORLEVEL or batch files.
C51 Output Files
C51 generates a number of output files during compilation. By default, each of these output files shares the same basename as the source file. However, each has a different file extension. The following table lists the files and gives a brief description of each.
File Extension |
Description |
|
|
basename.LST |
Files with this extension are listing files that contain the formatted source |
|
text along with any errors detected by the compiler. Listing files may |
|
optionally contain the used symbols and the generated assembly code. |
|
See the PRINT directive in the following sections for more information. |
basename.OBJ |
Files with this extension are object modules that contain relocatable object |
|
code. Object modules may be linked to an absolute object module by the |
|
BL51 Linker/Locator. |
basename.I |
Files with this extension contain the source text as expanded by the |
|
preprocessor. All macros are expanded and all comments are deleted in |
|
this listing. See the PREPRINT directive in the following sections for more |
|
information. |
basename.SRC |
Files with this extension are assembly source files generated from your C |
|
source code. These files can be assembled with the A51 assembler. See |
|
the SRC directive in the following sections for more information. |
|
|