c51 compiler

Download C51 Compiler

Post on 03-Jan-2017

213 views

Category:

Documents

1 download

Embed Size (px)

TRANSCRIPT

  • C51 CompilerOptimizing 8051 C Compiler

    and Library Reference

    Users Guide 01.97

  • ii

    Information in this document is subject to change without notice and does notrepresent a commitment on the part of the manufacturer. The software describedin this document is furnished under license agreement or nondisclosureagreement and may be used or copied only in accordance with the terms of theagreement. It is against the law to copy the software on any medium except asspecifically allowed in the license or nondisclosure agreement. The purchasermay make one copy of the software for backup purposes. No part of this manualmay be reproduced or transmitted in any form or by any means, electronic ormechanical, including photocopying, recording, or information storage andretrieval systems, for any purpose other than for the purchasers personal use,without written permission.

    Copyright 1988-1997 Keil Elektronik GmbH., and Keil Software, Inc.All rights reserved.

    Keil C51 is a trademark of Keil Elektronik GmbH.Microsoft, MS-DOS, and Windows are trademarks or registered trademarksof Microsoft Corporation.IBM, PC, and PS/2 are registered trademarks of International BusinessMachines Corporation.Intel, MCS 51, MCS 251, ASM-51, and PL/M-51 are registeredtrademarks of Intel Corporation.

    Every effort was made to ensure accuracy in this manual and to give appropriatecredit to persons, companies, and trademarks referenced herein.

  • Keil Software C51 Compiler Users Guide iii

    PrefaceThis manual describes how to use the C51 Optimizing C Compiler to compile Cprograms for your target 8051 environment. The C51 Compiler package can beused on all 8051 family processors and is executable under MS-DOS. Thismanual assumes that you are familiar with the MS-DOS operating system, knowhow to program 8051 processors, and have a working knowledge of the Clanguage.

    NOTEMS-DOS and PC-DOS are, in essence, the same operating system. This manualuses MS-DOS or just DOS when referring to either system.

    If you have questions about programming in C, or if you would like moreinformation about the C programming language, refer to Books About the CLanguage on page 2.

    Many of the examples and descriptions in this manual discuss invoking thecompiler from the DOS command prompt. While this may not be applicable toyou if you are running C51 within an integrated development environment,examples in this manual are universal in that they apply to all programmingenvironments.

  • iv Contents

    Manual OrganizationThis users guide is divided into eight chapters and six appendices:

    Chapter 1. Introduction, describes the C51 compiler.

    Chapter 2. Compiling with C51, explains how to compile a source file usingthe C51 cross compiler. This chapter describes the command-line directives thatcontrol file processing, compiling, and output.

    Chapter 3. Language Extensions, describes the C language extensionsrequired to support the 8051 system architecture. This chapter provides adetailed list of commands, functions, and controls not found in ANSI Ccompilers.

    Chapter 4. Preprocessor, describes the components of the C51 preprocessorand includes examples.

    Chapter 5. 8051 Derivatives, describes the 8051 family derivatives that theC51 compiler supports. This chapter also includes tips for improving targetperformance.

    Chapter 6. Advanced Programming Techniques, lists important informationfor the experienced developer. This chapter includes customization filedescriptions, and optimizer and segment names. This chapter also discusses howto interface C51 with other 8051 programming languages.

    Chapter 7. Error Messages, lists the fatal errors, syntax errors, and warningsthat you may encounter while using C51.

    Chapter 8. Library Reference, provides you with extensive C51 library routinereference material. The library routines are listed by category and include file.An alphabetical reference section, which includes example code for each of thelibrary routines, concludes the chapter.

    The Appendix includes information on the differences between compilerversions, writing code, and other items of interest.

  • Keil Software C51 Compiler Users Guide v

    Document ConventionsThis document uses the following conventions:

    Examples Description

    README.TXT Bold capital text is used for the names of executable programs, datafiles, source files, environment variables, and commands you enter atthe MS-DOS command prompt. This text usually represents commandsthat you must type in literally. For example:

    CLS DIR BL51.EXE

    Note that you are not required to enter these commands using all capitalletters.

    Language Elements Elements of the C language are presented in bold type. This includeskeywords, operators, and library functions. For example:

    if != longisdigit main >>

    Courier Text in this typeface is used to represent information that displays onscreen or prints at the printer.

    This typeface is also used within the text when discussing or describingcommand line items.

    Variables Text in italics represents information that you must provide. Forexample, projectfile in a syntax string means that you must supply theactual project file name.

    Occasionally, italics are also used to emphasize words in the text.

    Elements that repeat Ellipses () are used in examples to indicate an item that may berepeated.

    Omitted code...

    Vertical ellipses are used in source code examples to indicate that afragment of the program is omitted. For example:

    void main (void) {...while (1);

    !Optional Items" Optional arguments in command-line and option fields are indicated bydouble brackets. For example:

    C51 TEST.C PRINT !(filename)"{ opt1 | opt2 } Text contained within braces, separated by a vertical bar represents a

    group of items from which one must be chosen. The braces enclose allof the choices and the vertical bars separate the choices. One item inthe list must be selected.

    Keys Text in this sans serif typeface represents actual keys on the keyboard.For example, Press Enter to continue.

  • vi Contents

  • Keil Software C51 Compiler Users Guide vii

    Contents

    Chapter 1. Introduction......................................................................................1Books About the C Language ....................................................................................... 2

    Chapter 2. Compiling with C51.........................................................................3Environment Settings.................................................................................................... 3Running C51 ................................................................................................................. 4

    DOS ERRORLEVEL.............................................................................................. 5C51 Output Files ..................................................................................................... 5

    Control Directives......................................................................................................... 6Directive Categories................................................................................................ 6

    Reference ...................................................................................................................... 9AREGS / NOAREGS............................................................................................ 10ASM / ENDASM .................................................................................................. 12CODE.................................................................................................................... 14COMPACT ........................................................................................................... 15COND / NOCOND ............................................................................................... 16DEBUG................................................................................................................. 18DEFINE ................................................................................................................ 19DISABLE.............................................................................................................. 20EJECT................................................................................................................... 22FLOATFUZZY..................................................................................................... 23INTERVAL........................................................................................................... 24INTPROMOTE / NOINTPROMOTE .................................................................. 25INTVECTOR / NOINTVECTOR ........................................................................ 27LARGE ................................................................................................................. 29LISTINCLUDE..................................................................................................... 30MAXARGS........................................................................................................... 31MOD517 / NOMOD517 ....................................................................................... 32MODDP2 / NOMODDP2..................................................................................... 34NOAMAKE .......................................................................................................... 35NOEXTEND......................................................................................................... 36OBJECT / NOOBJECT ....................................................................................