- •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
228 |
Chapter 8. Library Reference |
|
|
Include Files
The include files that are provided with the Cx51 standard library are found in the INC subdirectory. These files contain constant and macro definitions, type definitions, and function prototypes. The following sections describe the use and contents of each include file. Macros and functions included in the file are listed as well.
8051 Special Function Register Include Files
The Cx51 compiler package provides you with a number of include files that define manifest constants for the special function registers found on many 8051 derivatives. These files can be found in the folder KEIL\C51\INC and the sub-folders. For example, the Special Function Registers (SFR) of the Philips 80C554 device are defined in the file KEIL\C51\INC\PHILIPS\REG554.H.
Within the µVision2 editor context menu that opens on a right mouse click in an editor window, you can insert the SFR defintion that matches the selected device.
SFR definition files for all 8051 variants can be downloaded from www.keil.com. The device database available on this web page contains the header file for the Special Function Registers file of almost all 8051 devices.
80C517.H
The 80C517.H include file contains routines that use the enhanced operational features of the 80C517 CPU and its derivatives. These routines are:
|
acos517 |
log10517 |
sqrt517 |
|
|
asin517 |
log517 |
sscanf517 |
|
|
atan517 |
printf517 |
strtod517 |
|
|
atof517 |
scanf517 |
tan517 |
|
8 |
||||
cos517 |
sin517 |
|
||
|
|
|||
|
exp517 |
sprintf517 |
|
|
|
|
|
|
C51 Compiler |
229 |
|
|
ABSACC.H
The ABSACC.H include file contains definitions for macros that allow you to directly access the different memory areas of the 8051.
CBYTE |
FARRAY |
PBYTE |
CWORD |
FCARRAY |
PWORD |
DBYTE |
FCVAR |
XBYTE |
DWORD |
FVAR |
XWORD |
ASSERT.H
The ASSERT.H include file defines the assert macro you can use to create test conditions in your programs.
CTYPE.H
The CTYPE.H include file contains definitions and prototypes for routines which classify ASCII characters and routines which perform character conversions. The following is a list of these routines:
isalnum |
isprint |
toint |
isalpha |
ispunct |
tolower |
iscntrl |
isspace |
_tolower |
isdigit |
isupper |
toupper |
isgraph |
isxdigit |
_toupper |
islower |
toascii |
|
INTRINS.H
The INTRINS.H include file contains prototypes for routines that instruct the compiler to generate in-line intrinsic code.
_chkfloat_ |
_irol_ |
_crol_ |
_iror_ |
_cror_ |
_lrol_ |
_lror_ |
|
|
|
||
_nop_ |
8 |
|
_testbit_ |
||
|
||
|
|
230 |
Chapter 8. Library Reference |
|
|
MATH.H
The MATH.H include file contains prototypes and definitions for all routines that perform floating-point math calculations. Other math functions are also included in this file. All of the math function routines are listed below:
abs |
exp |
modf |
acos |
fabs |
pow |
asin |
floor |
sin |
atan |
fmod |
sinh |
atan2 |
fprestore |
sqrt |
cabs |
fpsave |
tan |
ceil |
labs |
tanh |
cos |
log |
|
cosh |
log10 |
|
SETJMP.H
The SETJMP.H include file defines the jmp_buf type and prototypes the setjmp and longjmp routines which use it.
STDARG.H
The STDARG.H include file defines macros that allow you to access arguments in functions with variable-length argument lists. The macros include:
va_arg |
va_end |
va_start |
In addition, the va_list type is defined in this file.
STDDEF.H
The STDDEF.H include file defines the offsetof macro you can use to determine
the offset of members of a structure.
8
C51 Compiler |
231 |
|
|
STDIO.H
The STDIO.H include file contains prototypes and definitions for stream I/O routines. They are:
getchar |
putchar |
sscanf |
_getkey |
puts |
ungetchar |
gets |
scanf |
vprintf |
printf |
sprintf |
vsprintf |
The STDIO.H include file also defines the EOF manifest constant.
STDLIB.H
The STDLIB.H include file contains prototypes and definitions for the type conversion and memory allocation routines listed below:
atof |
init_mempool |
strtod |
atoi |
malloc |
strtol |
atol |
rand |
strtoul |
calloc |
realloc |
|
free |
srand |
|
The STDLIB.H include file also defines the NULL manifest constant.
STRING.H
The STRING.H include file contains prototypes for the following string and buffer manipulation routines:
memccpy |
strchr |
strncpy |
|
memchr |
strcmp |
strpbrk |
|
memcmp |
strcpy |
strpos |
|
memcpy |
strcspn |
strrchr |
8 |
memmove |
strlen |
strrpbrk |
|
memset |
strncat |
strrpos |
|
strcat |
strncmp |
strspn |
|
|
|
|
|
The STRING.H include file also defines the NULL manifest constant.