sc51.PDF

(167 KB) Pobierz
SC51
C Compiler for 8051
User’s Manual
Edition 2.1, August 2004
SPJ Systems
101, Beaver Grandeur
Baner Road
Pune - 411045
Tel. (91) (20) 27293002
Fax. (91) (20) 27293003
http://www.spjsystems.com
Terms and Conditions for use of the software
For the purposes of this document, the term THE PRODUCT shall be used to refer to
SC51 (C compiler for 8051).
Terms and Conditions :
1) You may make a backup copy of THE PRODUCT, and you may install THE
PRODUCT on your computer systems hard disk, but only one copy of THE
PRODUCT may be in use at any one time.
2) If you make any modifications to THE PRODUCT, the modified code shall,
regardless of the extent of modification, remain the property of SPJ Systems. You
may not remove or alter any copyright notices contained in the source files,
documentation, executables or any part of THE PRODUCT.
3) You may not re-distribute any part of THE PRODUCT, or any materials which are
based on, or otherwise derived from any portion of THE PRODUCT. Any and all
copies of THE PRODUCT must be retained in your possession at all times.
4) You are granted permission to distribute any programs that you develop with THE
PRODUCT, provided that they are not based on, or otherwise derived from any
source code contained in THE PRODUCT.
5) You agree to use THE PRODUCT entirely at your own risk, and assume all
responsibility for such use. The author and distributors of THE PRODUCT do not
warrant it fit or suitable for any particular purpose.
===*===*===
SC51 User’s manual
2
http://www.spjsystems.com
CONTENTS :
1. INTRODUCTION......................................................................................................... 9
2. INSTALLATION........................................................................................................ 10
3. LANGUAGE REFERENCE...................................................................................... 11
3.1 : C
OMMENTS
: .......................................................................................................... 11
3.2 : I
DENTIFIER
:........................................................................................................... 12
3.3 : K
EYWORDS
: .......................................................................................................... 12
3.4 : D
ATA TYPES
:......................................................................................................... 13
3.5 : T
YPE
C
ONVERSIONS
:............................................................................................. 14
3.6 : C
ONSTANTS
: ......................................................................................................... 15
3.7 : O
PERATORS
:.......................................................................................................... 15
3.8 : F
UNCTION PROTOTYPES
: ....................................................................................... 16
3.9 : C
OMPILER CONTROL LINES
: .................................................................................. 17
3.10 : A
DDITIONAL FEATURES
: ..................................................................................... 18
3.10.1 : Using Special Function Registers (SFR) :................................................... 18
3.10.2 : Assembly language interface :..................................................................... 19
3.10.3 : The asm keyword :....................................................................................... 19
3.10.4 : The BIT keyword : ...................................................................................... 19
3.10.5 : Memory area specifiers (data, idata, bdata, xdata, pdata, code): .............. 20
3.10.6 : Variables in bdata (bit and byte accessing): ............................................... 22
3.10.7 : Memory specific and generic pointers: ....................................................... 23
3.10.8 : Declaring variables at specific address: ..................................................... 23
3.10.9 : interrupt functions and the using directive: ................................................ 24
3.10.10 : Absolute Register Addressing:................................................................... 26
4. SC51 LIBRARY FUNCTIONS REFERENCE........................................................ 27
L
IST OF FUNCTIONS IN ALPHABETICAL ORDER
:.............................................................. 27
abs ............................................................................................................................. 31
acos ........................................................................................................................... 31
asin............................................................................................................................ 31
atof ............................................................................................................................ 32
atoi ............................................................................................................................ 32
atol ............................................................................................................................ 32
bcd2int....................................................................................................................... 33
ceil............................................................................................................................. 33
clr_double_baud ....................................................................................................... 33
clr_ri ......................................................................................................................... 33
SC51 User’s manual
3
http://www.spjsystems.com
clr_ti.......................................................................................................................... 34
cos ............................................................................................................................. 34
cosh ........................................................................................................................... 34
delay.......................................................................................................................... 35
delay_ms ................................................................................................................... 35
disable ....................................................................................................................... 36
disable_all................................................................................................................. 36
disable_ex0 ............................................................................................................... 37
disable_ex1 ............................................................................................................... 37
disable_rx.................................................................................................................. 37
disable_ser ................................................................................................................ 38
disable_t0.................................................................................................................. 38
disable_t1.................................................................................................................. 38
disable_t2.................................................................................................................. 39
enable........................................................................................................................ 39
enable_all.................................................................................................................. 39
enable_ex0 ................................................................................................................ 40
enable_ex1 ................................................................................................................ 40
enable_rx................................................................................................................... 40
enable_ser ................................................................................................................. 41
enable_t0................................................................................................................... 41
enable_t1................................................................................................................... 41
enable_t2................................................................................................................... 42
ex0_edge ................................................................................................................... 42
ex0_level ................................................................................................................... 42
ex1_edge ................................................................................................................... 43
ex1_level ................................................................................................................... 43
exp ............................................................................................................................. 43
floor........................................................................................................................... 44
fmod........................................................................................................................... 44
frexp .......................................................................................................................... 45
getbyte ....................................................................................................................... 45
getch.......................................................................................................................... 45
getchar ...................................................................................................................... 46
getchare..................................................................................................................... 46
go_idle....................................................................................................................... 46
hi_nibb ...................................................................................................................... 47
init_ser ...................................................................................................................... 47
inportb....................................................................................................................... 47
int2bcd....................................................................................................................... 48
SC51 User’s manual
4
http://www.spjsystems.com
isalnum...................................................................................................................... 48
isalpha....................................................................................................................... 48
isascii ........................................................................................................................ 49
isdigit......................................................................................................................... 49
islower....................................................................................................................... 49
isspace....................................................................................................................... 49
isupper....................................................................................................................... 50
isxdigit....................................................................................................................... 50
itoa_c31..................................................................................................................... 50
labs............................................................................................................................ 51
ldexp.......................................................................................................................... 51
log ............................................................................................................................. 51
log10 ......................................................................................................................... 51
long2bcd.................................................................................................................... 52
lo_nibb ...................................................................................................................... 52
ltoa_c31..................................................................................................................... 52
memset....................................................................................................................... 53
modf........................................................................................................................... 53
movmem .................................................................................................................... 53
outportb..................................................................................................................... 53
peekb ......................................................................................................................... 54
pokeb ......................................................................................................................... 54
pow............................................................................................................................ 54
powerdown................................................................................................................ 55
printf.......................................................................................................................... 55
putchar ...................................................................................................................... 57
puts............................................................................................................................ 58
scanf .......................................................................................................................... 58
sendbyte..................................................................................................................... 60
ser_rdy ...................................................................................................................... 60
set_com_mode........................................................................................................... 61
set_double_baud ....................................................................................................... 61
set_hi_ex0 ................................................................................................................. 61
set_hi_ex1 ................................................................................................................. 62
set_hi_ser .................................................................................................................. 62
set_hi_t0.................................................................................................................... 62
set_hi_t1.................................................................................................................... 63
set_hi_t2.................................................................................................................... 63
set_lo_ex0 ................................................................................................................. 63
set_lo_ex1 ................................................................................................................. 64
SC51 User’s manual
5
http://www.spjsystems.com
Zgłoś jeśli naruszono regulamin