📄 c5113.txt
字号:
发信人: reflection (似水流年), 信区: EEtechnology
标 题: C51 Primer (12) Library Functions
发信站: 南京大学小百合站 (Wed Nov 24 12:04:43 1999), 转信
12 C51 Library Functions
One of the main characteristics of C is its ability to allow complex functio
ns to be constructed from the basic commands. To save programmer effort many
common mathematical and string functions are supplied ready compiled in the
form of library files.
12.1 Library Function Calling
Library functions are called as per user-defined functions, i.e
#include ctype.h
{
char test_byte ;
result = isdigit(test_byte) ;
}
where "isdigit()" is a function that returns value 1 (true) if the test_byte
is an ASCII character in the range 0 to 9.
The declarations of the library functions are held in files with a ".h" exte
nsion - see the above code fragment.
Examples are:
ctype.h,
stdio.h,
string.h etc..
These are included at the top of the module which uses a library function.
Many common mathematical functions are available such as ln, log, exp, 10x,
sin, cos, tan (and the hyperbolic equivalents). These all operate on floatin
g point numbers and should therefore be used sparingly! The include file con
taining the mathematical function prototypes is "math.h".
Library files contain many discrete functions, each of which can be used by
a C program. They are actually retrieved by the linker utility covered in se
ction 8. These files are treated as libraries by virtue of their structure r
ather than their extension. The insertion or removal of functions from such
a file is performed by a library manager called LIB51.
12.2 Memory-Model Specific Libraries
Each of the possible memory models requires a different run-time library fil
e. Obviously if the LARGE model is used the code required will be different
for a SMALL model program.
Thus with C51, 6 different library files are provided:
C51S.LIB - SMALL model
C51C.LIB - COMPACT model
C51L.LIB - LARGE model
plus three additional files containing floating point routines as well as th
e integer variety.
C51 library functions are registerbank independent. This means that library
functions can be used freely without regard to the current REGISTERBANK() or
USING status. This is a major advantage as it means that library functions
can be used freely within interrupt routines and background functions withou
t regard to the current register bank.
----------------------------------------------------------------------------
----
--
Ours is essentially a tragic age, so we refuse to take it tragically.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -