
- •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

Keil Software — C51 Compiler User’s Guide |
107 |
|
|
Siemens 80C517 and 80C537
The Siemens 80C517 and 80C537 provide high-speed 32-bit and 16-bit arithmetic operations as well as 8 data pointers which can be used for memory access. Using the high-speed arithmetic unit improves the performance of many int, long, and float operations.
The MOD517 control directive instructs the C51 compiler to generate code that utilizes the advanced features of these CPUs.
Data Pointers
The Siemens 80C517 and 80C537 provide 8 data pointers which can be used to improve memory accesses. Using multiple data pointers can improve the execution of library functions such as: memcpy, memmove, memcmp, strcpy, and strcmp. The 8 data pointers of the 80C517 and 80C537 can also reduce the stack load of interrupt functions.
C51 uses only 2 of the 8 data pointers of the 80C517 at a time. In order to keep the stack load in the interrupt routines low, C51 switches to 2 unused data
pointers when switching the register bank. In this case, the contents of the 5 register DPSEL are saved on the stack, and a new pair of data pointers is
selected. Saving the data pointers on the stack is no longer required.
If an interrupt routine does not switch to another register bank (for example, the function is declared without the using attribute), the data pointers must be saved on the stack (using 4 bytes of stack space). To keep the size of the stack as small as possible, use the MOD517(NODP8) directive to compile the interrupt routine and the functions called from within the interrupt. This generates code for the interrupt that uses only one data pointer and, therefore, only 2 bytes of stack space.
108 |
Chapter 5. 8051 Derivatives |
|
|
High-speed Arithmetic
C51 uses the 32-bit and 16-bit arithmetic operations of the 80C517 to improve performance of a number of math-intensive operations. C language programs execute considerably faster when using either of these CPUs.
The following tables show execution times for various arithmetic operations and compare the performance of the standard 8051 to that of the 80C517 CPU.
16-bit Binary Integer Operations
|
|
Operation |
CPU |
Routine |
Min. |
Avg. |
Max. |
|
|
|
|
|
|
|
|
|
|
Signed/unsigned multiplication |
8051 |
IMUL |
29 |
29 |
29 |
|
|
|
80517 |
intrinsic |
17 |
17 |
17 |
|
|
Unsigned division |
8051 |
UIDIV |
16 |
128 |
153 |
|
|
|
80517 |
UIDIV517 |
22 |
22 |
22 |
|
|
Signed division |
8051 |
SIDIV |
53 |
141 |
181 |
|
|
|
80517 |
SIDIV517 |
35 |
52 |
60 |
|
|
Times are shown in CPU cycles. |
|
|
|
||
|
|
32-bit Binary Integer Operations |
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
Operation |
CPU |
Routine |
Min. |
Avg. |
Max. |
|
|
|
|
|
|
|
|
|
Signed/unsigned multiplication |
8051 |
LMUL |
106 |
106 |
106 |
|
|
|
80517 |
LMUL517 |
62 |
62 |
62 |
|
|
|
Unsigned division |
8051 |
ULDIV |
227 |
497 |
650 |
|
|
|
80517 |
ULDIV517 |
36 |
52 |
101 |
|
|
Signed division |
8051 |
SLDIV |
267 |
564 |
709 |
|
|
|
80517 |
SLDIV517 |
49 |
75 |
141 |
|
|
Left shift |
8051 |
LSHL |
5 |
237 |
470 |
|
|
|
80517 |
LSHL517 |
5 |
28 |
29 |
|
|
Unsigned right shift |
8051 |
ULSHR |
5 |
237 |
470 |
|
|
|
80517 |
ULSHR517 |
5 |
29 |
30 |
|
|
Signed right shift |
8051 |
SLSHR |
5 |
237 |
470 |
|
|
|
80517 |
— |
— |
— |
— |
|
|
|
|
|
|
|
|
Times are shown in CPU cycles.
Keil Software — C51 Compiler User’s Guide |
109 |
|
|
Floating-point Operations
Operation |
CPU |
Routine |
Min. |
Avg. |
Max. |
|
|
|
|
|
|
|
|
|
|
Addition |
8051 |
FPADD |
8 |
107 |
202 |
|
|
|
80517 |
FPADD517 |
8 |
107 |
202 |
|
|
Subtraction |
8051 |
FPSUB |
11 |
113 |
214 |
|
|
|
80517 |
FPSUB517 |
11 |
113 |
214 |
|
|
Multiplication |
8051 |
FPMUL |
13 |
114 |
198 |
|
|
|
80517 |
FPMUL517 |
13 |
86 |
141 |
|
|
Division |
8051 |
FPDIV |
48 |
687 |
999 |
|
|
|
80517 |
FPDIV517 |
48 |
165 |
209 |
|
|
Comparison |
8051 |
FPCMP |
42 |
54 |
59 |
|
|
|
80517 |
FPCMP517 |
42 |
54 |
59 |
|
|
Square root |
8051 |
SQRT |
12 |
1936 |
2360 |
|
|
|
80517 |
SQRT517 |
12 |
755 |
882 |
|
|
Sine |
8051 |
SIN |
1565 |
2928 |
3476 |
|
|
|
80517 |
SIN517 |
1422 |
2519 |
3048 |
|
|
Cosine |
8051 |
COS |
1601 |
2921 |
3665 |
|
|
|
80517 |
COS517 |
1458 |
2514 |
3180 |
|
|
Tangent |
8051 |
TAN |
1982 |
4966 |
5699 |
|
|
|
80517 |
TAN517 |
1839 |
3753 |
4329 |
|
|
Arcsine |
8051 |
ASIN |
912 |
6991 |
8554 |
|
|
|
80517 |
ASIN517 |
912 |
3984 |
4717 |
|
|
Arccosine |
8051 |
ACOS |
796 |
7578 |
8579 |
|
|
|
|||||||
|
80517 |
ACOS517 |
796 |
4255 |
4871 |
|
5 |
Arctangent |
8051 |
ATAN |
1069 |
3320 |
3712 |
|
|
|
|
||||||
|
80517 |
ATAN517 |
1037 |
2444 |
2737 |
|
|
Exponential |
8051 |
EXP |
233 |
3314 |
5308 |
|
|
|
80517 |
EXP517 |
176 |
2879 |
4724 |
|
|
|
|
||||||
Natural Logarithm |
8051 |
LOG |
32 |
3432 |
4128 |
|
|
|
80517 |
LOG517 |
32 |
2405 |
2926 |
|
|
Common Logarithm |
8051 |
LOG10 |
34 |
3607 |
4328 |
|
|
|
80517 |
LOG10517 |
34 |
2530 |
3069 |
|
|
ASCII to float conversion |
8051 |
FPATOF |
960 |
3006 |
5611 |
|
|
|
80517 |
FPATOF517 |
722 |
2202 |
4144 |
|
|
|
|
|
|
|
|
|
|
Times are shown in CPU cycles.

110 |
Chapter 5. 8051 Derivatives |
|
|
NOTES
The execution times specified in the preceding tables do not take access times for variables or stack operations into consideration. Actual processing times may consume up to 100 additional cycles depending on the stack load and address space used.
When using the arithmetic features of the 80C517 and 80C537, note that operations involving the arithmetic processor are exclusive and may not be interrupted. Do not use the arithmetic extensions in both the main program and an interrupt service routine.
Use the following suggestions to help guarantee that only one thread of execution uses the arithmetic processor:
!Use the MOD517 directive to compile functions which are guaranteed to execute only in the main program or functions used by one interrupt service routine, but not both.
!Compile all remaining functions with the MOD517(NOAU) directive.
Library Routines
5 |
The extra features of the 80C517 and 80C537 are used in several library routines |
||
|
to enhance performance. These routines are listed below and are described in |
||
|
detail in “Chapter 8. Library Reference” on page 175. |
|
|
|
acos517 |
exp517 |
sin517 |
|
asin517 |
log10517 |
sprintf517 |
|
atan517 |
log517 |
sqrt517 |
|
atof517 |
printf517 |
sscanf517 |
|
cos517 |
scanf517 |
tan517 |