- •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
Keil Software — Cx51 Compiler User’s Guide |
353 |
|
|
Appendix A. Differences from ANSI C
The Cx51 compiler differs in only a few aspects from the ANSI C Standard. |
A |
These differences can be grouped into compiler-related differences and |
|
library-related differences. |
|
Compiler-related Differences
Wide Characters
Wide 16-bit characters are not supported by Cx51. ANSI provides wide characters for future support of an international character set.
Recursive Function Calls
Recursive function calls are not supported by default. Functions that are recursive must be declared using the reentrant function attribute. Reentrant functions can be called recursively because the local data and parameters are stored in a reentrant stack. In comparison, functions which are not declared using the reentrant attribute use static memory segments for the local data of the function. A recursive call to these functions overwrites the local data of the prior function call instance.
Library-related Differences
The ANSI C Standard Library includes a vast number of routines, most of which are included in Cx51. Many, however, are not applicable to an embedded application and are excluded from the Cx51 library.
The following ANSI Standard library routines are included in the Cx51 library:
abs |
cosh |
isdigit |
acos |
exp |
isgraph |
asin |
fabs |
islower |
atan |
floor |
isprint |
atan2 |
fmod |
ispunct |
atof |
free |
isspace |
atoi |
getchar |
isupper |
atol |
gets |
isxdigit |
calloc |
isalnum |
labs |
ceil |
isalpha |
log |
cos |
iscntrl |
log10 |
|
|
354 |
|
Appendix A. Differences from ANSI C |
|
|
|
|
|
|
|
longjmp |
sin |
strrchr |
|
|
malloc |
sinh |
strspn |
A |
|
|||
|
memchr |
sprintf |
strstr |
|
|
memcmp |
sqrt |
strtod |
|
|
memcpy |
srand |
strtol |
|
|
|
memmove |
sscanf |
strtoul |
|
|
|||
|
|
memset |
strcat |
tan |
|
|
modf |
strchr |
tanh |
|
|
pow |
strcmp |
tolower |
|
|
printf |
strcpy |
toupper |
|
|
putchar |
strcspn |
va_arg |
|
|
puts |
strlen |
va_end |
|
|
rand |
strncat |
va_start |
|
|
realloc |
strncmp |
vprintf |
|
|
scanf |
strncpy |
vsprintf |
|
|
setjmp |
strpbrk |
|
|
|
The following ANSI Standard library routines are not included in the Cx51 |
||
|
|
library: |
|
|
|
|
abort |
freopen |
remove |
|
|
asctime |
frexp |
rename |
|
|
atexit |
fscanf |
rewind |
|
|
bsearch |
fseek |
setbuf |
|
|
clearerr |
fsetpos |
setlocale |
|
|
clock |
ftell |
setvbuf |
|
|
ctime |
fwrite |
signal |
|
|
difftime |
getc |
strcoll |
|
|
div |
getenv |
strerror |
|
|
exit |
gmtime |
strftime |
|
|
fclose |
ldexp |
strtok |
|
|
feof |
ldiv |
strxfrm |
|
|
ferror |
localeconv |
system |
|
|
fflush |
localtime |
time |
|
|
fgetc |
mblen |
tmpfile |
|
|
fgetpos |
mbstowcs |
tmpnam |
|
|
fgets |
mbtowc |
ungetc |
|
|
fopen |
mktime |
vfprintf |
|
|
fprintf |
perror |
wcstombs |
|
|
fputc |
putc |
wctomb |
|
|
fputs |
qsort |
|
|
|
fread |
raise |
|
Keil Software — Cx51 Compiler User’s Guide |
355 |
|
|
The following routines are not found in the ANSI Standard Library but are included in the Cx51 library:
acos517 |
_iror_ |
strpos |
asin517 |
log10517 |
strrpbrk |
atan517 |
log517 |
strrpos |
atof517 |
_lrol_ |
strtod517 |
cabs |
_lror_ |
tan517 |
_chkfloat_ |
memccpy |
_testbit_ |
cos517 |
_nop_ |
toascii |
_crol_ |
printf517 |
toint |
_cror_ |
scanf517 |
_tolower |
exp517 |
sin517 |
_toupper |
_getkey |
sprintf517 |
ungetchar |
init_mempool |
sqrt517 |
|
_irol_ |
sscanf517 |
|
A
356 |
Appendix A. Differences from ANSI C |
|
|
A