• Aucun résultat trouvé

UNISYS BTOS

N/A
N/A
Protected

Academic year: 2022

Partager "UNISYS BTOS"

Copied!
284
0
0

Texte intégral

(1)
(2)

e

UNISYS BTOS

C Compiler

Programming

Reference Manual

Copyright © 1988 Unisys Corporation All Rights Reserved

Unisys is a trademark of Unisys Corporation

(3)

The names, places and/or events used in this publication are not

intended to correspond to any individual, group, or association existing, living or otherwise. Any similarity or likeness of the names, placest

and/or events with the names of any individual living or otherwise, or that of any group or association is purely coincidental and unintentional.

NO WARRANTIES OF ANY NATURE ARE EXTENDED BY THE

DOCUMENT. Any product and related material disclosed herein are only furnished pursuant and subject to the terms and conditions of a duly executed Program Product License or Agreement to purchase or lease equipment. The only warranties made by Unisys, if any, with respect to the products described in this document are set forth in such License or

Agreement. Unisys cannot accept any financial or other responsibi1ity

that may be the result of your use of the information in this document or software material, including direct, indirect, special or consequential

damages.

You should be very careful to ensure that the use of this information and/or software material complies with the laws, rules, and regulations of the jurisdictions with respect to which it is used.

The information contained herein is subject to change without notice.

Revisions may be issued to advise of such changes and/or additions.

Comments or suggestions regarding this document should be submitted on a User Communication Form (UCF) with the CLASS specified as 3 (Applic. :Application Software), the Type specified as 3, and the product specified as the 7-digit form number of the manual.

(4)

v

About This Manual

This manual contains procedures and reference information on how to install and use the BTOS C Compiler, and then link the object code into an executable run file.

Who Should Use This Manual

This manual is designed for users who have a working knowledge of the C programming language; it is not intended to teach a user how to write a

program

in C.

The procedures are easier to perform if you are familiar

with BTOS operations. However, the necessary information on how to install and operate the

C

Compiler,

supplemented with references to your BTOS documentation, is included.

How to Use This Manual

If you are using the BTOS C Compiler for the first time, you should read section 1. It provides a brief overview of the product capabilities and features.

If you scan the table of contents and review the topics before you start, you may find this manual easier to t1se.

For definitions of terms used in this manual or related to this software, ref er to the glossary.

To locate specific information, use the index.

This manual contains seven sections, three appendixes, a glossary, and an index.

(5)

vi

About This Manual

Conventions

The following conventions apply throughout this manual:

o

The term BTOS refers to BTOS II in this manual.

o Information you enter at your keyboard appears in boldface.

o

Executive

commands

appear in

uppercase.

o

When two keys are used together for an operation, their names are hyphenated. For example, ACTION-GO

means

you

hold down ACTION and press GO.

Related Product Information

For information on the Operating System (BTOS), ref er to

the

BTOS II System Reference Manual.

For more information about BTOS II system calls and structures, ref er to the BTOS II System Procedural Interface Reference Manual.

For information on system status codes, ref er to the BTOS II System Status Codes Reference Manual.

For information on Executive level commands, refer to the BTOS II Standard Software Operations Guide.

For information on the Editor, refer to the BTOS II Editor Operations Guide.

For

information

on BTOS

Context

Manager TM II, ref er to

the

BTOS Context/Window Manager Installation and

Configuration Guide.

In addition, the following manuals are related to the BTOS C Compiler:

o

BTOS II Language Development Programming Guide (information

and

procedures for

using the

LINK, BIND, and LIBRARIAN commands)

o

BTOS II Debugger Programming Guide (information and procedures for debugging programs)

Context Manager is a trademark of Convergent, Inc.

(6)

Contents

About This Manual. ... .

Who Should Use This Manual ... . How to Use This Manual ... . How This Manual is Arranged ...•....•...

Conventions ... . Related Product Information ... .

Section 1: Overview ... .

Using the C Compiler ... . Features ... . Memory Requirements ... .

Section

2:

BTOS C Compiler Installation ... .

Installing C Compiler Software ...••••.•••...

Installing C Compiler Software on a BTOS Workstation ••.••..

Installing C Compiler Software on an XE520 Master .••••....

Configuring BTOS Context Manager II to Run This

Application ... .

Section 3:

Using the C Compiler ... .

Memory Utilization .•...•...

Command Line Syntax ... . Frequently Used Command Line Options ...•...

Controlling Compilation Activity Options ... . Specifying Memory Model Options ... . Preprocessor Control Options ... . Disk Usage Options ... . Comment Control Option ... . Message Control Option ..•...•...

Adva need 0 pt ions ...•....•...•....•...

8086 Support ... . 8087 Support ... . Optimization Options ...••.•.•...

LINT and Warning Message Options •...•...

Debugging Options ... . Com pati bi lity Options ...•.•...

Fast Calling Sequence Option ...•..•...•...•..

Segment Naming Options ... . Overlay Support Options ...•...•...•..

CCompiler. CFG ...•...

Linking a Program ...•..•...•...

LINT Source Fiie Comments ... .

vii

v v v v

VI .

VI

1-1 1-1 1-2 1·2 2 .. 1 2-1 2-1 2-2 2-3

3-1 3-1 3-2 3-2 3-3 3-3 3-5 3-5 3-5 3-6 3-6 3-6 3-7 3-7 3-9

3-13 3-13 3-14 3-16

3-17 3-17

3-19 3·20

(7)

viii

• •

/*VARARGSn*

I ...

Compiler Operation ..

Temporary Files ...

• • • • • • • • • • • • • • • • • • • • • • • •

. .

• • • •

. . . . . . .

Section 4: Runtime Environment.

Pro1ram Execution ... . • • • • • •

Memory Organization •....•....•.••.

Pointer Arithmetic ...•..•...•.•..

• • • • •

• • • •

Section 5: Assembly Language Interface.

. . . . . .

• • •

External Variable Names ...•...

... . . .

The C and PL/M Calling Sequences ... . • • Function Arguments • • •

. .

Calling Functions ...•.•.••.•.••...•....••.• • • • • • Passing Return Values ...•.•..•.•..

. . .

Assembly Language Fiie Structure ... .

. . . . . . .

Defining Functions .•••...••••..•.••.•.•.••...•••. •••••••

Defining Data Constants ... .

. . . . .

Globa I Data ...•...•....

. . . . .

• • • • • • • • • • • •

Sample Assembly Language Modules ... . • • • • • • •

Small Model Version ••.•... • • • • • Medium. Large, and Huge Model Version ...

. . . . .

Section 6:

Library Reference .. .

. . . . . . .

library Overview ... . Runtime Support ...•...

1/0 Operations ....

UNIX Compatible 1/0.

Standard 1/0 ... .

. . . .

. .

BTOS I /0 Services ... .

Mathematical Functions ... .

• • • •

. . . . .

. .

. .

• •

. . . . . . . . .

• • • • • • • •

. . . . ..

Header Files ... . ASSERT.H ..

CT:xxx.H •• I . I I • • • I • • • • I . . . .

CTYPE. H •••..••••••••••••••••••••..•••..•••.••••••.•.••

ERRNO.H ..

FLOAT.H •••..•...•..•.•.•••..•...••..•..•...••••...

18086.H ... .

. . . . . . .

• • • • • • • • • • • •

. . . .

LIMITS.H •••..•••••....•.••...•...

. . . . . . .

• • • •

. . .

MATH. H •••..•••••....•...••.•..•..•••....•.•.•.••....•

SETJMP.H ...•..•...•.•....•...•...

. . .

SIGNAL.H .•..•••••..•.•.•....•..•..

. . . . . .

STDARG.H •••

STDDEF.H ....•...

. . ... . . . . .

• • • • •••

STOLi B. H .•••••••••••••••••••••.•••.•••••.•.••••.••••••

STDIO.H.

. . .

• • •

. . . . . .

STRING.H .•..•.•....•.•..•.••...•...••..•..•.•...

TIME.H ... .

. . . . . . . . . . . . . . . .

• • • • •

Library C Functions.

Contents

3-22 3-23

3-23 4-1 4-1

4 .. 3 4-4

5·1 5-1 5-2

5-2 5-4

5-5

5-6 5-7 5-7 5-8 5-8 5-9 5-9

6-1 6-1 6-1

6-1

6-2 6-2 6-3 6-3 6-4 6-4 6-4

6-5

6-5

6-5 6 .. 5

6-6

6 .. 6

6-6 6-7 6-7 6-7 6-7 6-7

6-7

6-8 6-8

(8)

Contents

abs ...•.•...•...•...

assert ... .

atof, atoi, atol, strtod, strtol ... . bsearch

. . . . . . . . .

. . . . . . . . . . . . . .

• • •

. . .

• ••• • It

check8087, inlt8087 ... .

. . . . . . . . . .

41 • •

close ....

. . . . . . . . . . .

creat ...•...•...

. .

ctl me, localtime, ascti me, gmtl me ...•..•...

ecvt, f cvt, gcvt . . .

. . . .

. . . . . . . . . .

exit, _exit ... .

. . . . . . . . .

. .

. .

.

exp, log, log 10, pow, sqrt ... . fclose, ff I ush ... .

. . . . . . . . . . .

• •

. .

feof, ferror, clearerr ... . floor, cei I, fmod, fabs ... . fopen, f reopen ...•...

fread, fwrite ..•... • • • • frexp, ldexp, modf •...•...•...•...

fseek, ftell, rewind ...•...

getc, getchar, fgetc, getw ... . gets, fgets ...

Index, rindex •..

inport, lnportb

. . . . . .

. . .

. . . . .

• •

. .

.

. . .

. . . . . . . . . .

• •

. . .

• • • • • • • • •

. . .

• •

. .

. . . . . . . .

isalpha, isupper, is lower, isdlgit, isxdigit, isalnum, isspace, lspunct, isprint, isgraph, iscntrl, isascil ••• • • lsearch.

. . . . . . . . . .

• • • • • • •

. . . . . . . . . . . .

lseek ..•..•••.•..•••...•••...•...••..•...

malloc, calloc, free, cfree, realloc .

. . . . . . .

memcpy, memset, memcmp, memchr ... . movmem ... . • •

. .

. . . .

.

. . . .

. .

open ... . A e II e • • •

. .

outport, outportb ..

. . . . . . . . . . . . . . . . . . . . . . . . . . .

peek, peekb ... . .

. . . .

.

poke, pokeb . . . • . . • . . . . ..

. . . . . . . . .

printf, fprintf, sprintf .... .

. . . . .

putc, putchar. fputc, putw ... . puts, f puts ... .

. . . . . . . . .

qsort, ssort .. ..

.

• • • •

rand, srand ...••..•...

. . . . . . .

read ...••...•...

scant, fscanf, sscanf ... .

. . .

segread ... .

. . . . .

• • • • • • • • • • •

. .

setbuf, setvbuf ...•.•...•...

setjmp, longjmp ... .

. . . . . . . . . .

setmem ... . ..

. . . . . . . . .

. .

• • • • • •

. .

. . . .

sin, cos, tan, asin, acos, atan, atan2 ... . sinh, cosh, tanh ....

. . . . .

• •

. .

.

. .

. . .

. . . .

ix 5 .. 9 6-10 6-11 6-13 6-14 6-15 6·16 6-17 6-19 6-20 6-21 6-22 6-23 6-24 6-25 6·27 6·28

6-29 6-30 6-31 6-32

6·33

5 .. 34

6·36

6-37 6-38 6-40 6-41 6-42 6·43 6-44 6-45 6-46 6-51 6-52 6-53 6-54 6-55 6-56 6-60 6·61 6·63 6·64 6-65 6·67

(9)

x

strcpy, strncpy

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

strlen ... .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

strspn, strcspn • • • • • • • • • • • • • • • • • • • • • •

strtok ... .

. . . . . . . . . . . . . .

• • • • • • • •

swab time

• • • • • • • • •

. . . .

.

.

. . . . . . . . .

. . .

. . . . . . . . . . . .

. .

. . . . .

. .

. . . . . . . . . . . . . . . . .

toupper, tolower, _toupper, _tolower, toascii ... . ungetc ....•....•...•.•...•...

unlink ... ..

vprintf, vfprintf, vsprlntf vscanf, vfscanf, vsscanf.

. . . .

• • • • •

. . .

..

.

• •

. . .

• • •

.

•••

..

write ... . • • ..

. . . . . . . . . . . . . . . ...

Section 7: The C Programming Language ... . BTOS C Features ... ..

Translation Phases and Limits ... .

. .

Preprocessor Translations ... .

Parser Translations ..•.•....•.. • • • • • •

. . . . . .

Optimizer Translations ...•....•...•....•..•.•

Code Generator Translations.

. . .

..

. . . . . . . . .

• • • • •

. .

Compiler Limits ... . • •

. . .

..

. . . . . . .

Pre process Ing ..•••....•....•....•.•..••....••...•....

Source File Inclusion ...

. . .

Define Macros ..•

. . . . . . .

FILE

-

LINE

-

...

. . . . . . . . . . . . . .

• •

. . . . . . .

• • • • • • • • • • • • ••••• • • • • • •

. . . . . . .

-

DATE

-

•••••••...•••••...•.••.. •••••

. . . . . .

- -

_Tl ME_ ... . SMALL ... .

-

MEDIUM

-

....

-

LARGE

-

•.•

. . . .

- -

• • • • ..

. . . . . . . . . . . . . . . . . .

HUGE ... . • • • •

- -

Cond itiona I Compilation ...•.••..•.••.•••...•.•.•....

Constant Expressions ... . Line Number Control .•..

#pragma Directives ....

#error Directives ..•...

. . .

..

.

• • • • •

..

. . . . . . .

. . . . .

. .

• •

. . .

• • •

. .

. .

. . .

• • • •

• • • •

. . .

. . . .

Null Directive ... . Comments ••..

Lexical Conventions

..

. . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . .

. . . .

.

. .

Source Text Conventions •...•....•.•....•..•....•...•..

Identifiers ...•...•...••....

. . . . . . . . . . . .

Keywords ••••.•••.•..

Numerical Constants ... . Integer Constants ... . Character Constants.

. . . . . . . . . . . . . . . .

Escape Sequences ..•.••...•.•....•....•

Floating Constants ..

Strings .•.

Operators.

. . .

. . . . . . . . . . . . . . . . .

• •

• •

. . . . .

• • • •

• • •

...

Contents 6-73 6-74 5 .. 75 6-76 6-77 6-78 6-79 6-80 6-81 6-82 6-83 6-84 7 .. 1 7 .. 1 7 .. 3

7-3

7 .. 4

7-4 7-5 7-5 7-5

7-6 7-7

7-10 7-10 7-10 7-10 7-11 7-11 7-11 7-11 7-11 7-12

7-13 7-14 7-14 7·14 7-14 7-15 7 .. 15 7-16

7-17 7-18 7-18 7-19 7-19 7-20 7-21 7-21

(10)

Contents

Punctuation ... . • • • • • • Trigraphs ....

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Types ...••...•...•.•...•...••..•....•...

Basic Types .•....••••.••...•.••...•..•....•...

I ntegra I Types ...••...•..•...•...

Characters and Integers ... .

. . . . . . . . . . . . . . . . . . . .

Unsigned .•.•...•....•...••••.••..•...

Floating Types .•....•....•.•.•...•.•.•...•....•.••.•

Void Type • • • • • • . • . . • • • • . • . . . • . . . • . • . . • . . • ... .

Enumerated Type •.•••...•....•....•••.••...•...

Composite Types •••.••••.•.•.••••••••••••••...•...•..•

Pointers ... .

. . . . . . .

• •

. . . . . . .

• •

Functions ...•..•.•... • •

. . . . . . . .

• • • • • •

Arrays .•••....••.•.•...•.••••.•...•.••.••••..

Structures and Unions ..•.•.. • • • • • • Bitfields ...•...

Type Modifiers .•.••.•...•..•....

. . . . . . . . . .

. .

Declarations ...•....•....•...

Storage Class Specifiers ....••.

. . . . . . . . . . .

.

. . . . . . . . .

Auto ..•.•....•••... • • • • • • • • • •

Extern ...•...

. . . . . . . . . . . . . . . . . . . . . . .

Register ....•.••.•..•...•..•.•...

. . . . . . .

.

Static ... .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

.

. . . . . .

Typedef ••.•...•.•.••.•..•...

. . . . . . . .

. . . . .

Type Specifiers ...•..•...•...••... e A Ill . . . .

Basic Arithmetic Type Specifiers ... . Structures and Unions •...•••...•...

. . . .

Enumerations ...•. • •

. . . . . . . .

. .

• •

Void ..•..•••..••••.•••....•..••..•...••...

.

.

. . . . .

Declarators ..•..•....•...•..•.•... • • • • • Pointer ... .

. . . . .

Function •...••••...••.•.••.•.•..•.•..••.•....•..•.

Array ••.

. . . . . . . ... . . . . . . . . . . . . . . . .

. . .

• • • •

Bitf ields ••..•••...

. . . . .

..

.

. . .

. . . . . . . . . .

Type names ..••.••.•.•..•••••.••••.••••••••••.•••...•••

Type Equivalence •••...•....•..•••..•.••.•.•..•••.

In itia I ization ••••.•••

... . . . . . . . . . . . . . .

Scope of ldentif iers .•• II • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • •

Linkage ....•••..•••..•.•.••.•..•.•..•.••••••...•

Expressions ...••...

Lval ues .••••...•

. . ....

• • • • • • • •

Primary Expressions •.•.••••.•..•.••••... II • • • • • •

Postfix 0 perators ..•....•••

. . .

. . . . .

... . . . . . . . . . .

Postfix Increment and Decrement Operators

. . . . .

Function Calls ..•..•.••• , ..•...•••..••• ,, ..••...••

PL/M Functions ...

Interrupt Functions

• • • • • • • • • • • • •

. . . . . . . . . . . . . . . . . . . . .

• •

. . .

. . .

XI

7-22 7-22 7-23 7-23 7-23 7-23 7-24 7-24 7-24

7.24

7-25 7-25 7-25 7-26 7-26 7-27 7-27 7-28 7-30 7-30 7-31 7-31 7-32 7-32 7-32 7-32 7-33 7 .. 34 7-35 7-35 7-36

7-37

7-38 7-39 7-40

7-41 7-41 7.43 7 .. 44 7.44 7 .. 45 7-45 7-46

7-46 7-46 7-49

7-50

(11)

xii

Unary Operators ...•.•....•.•.•..•...•.

Prefix Increment and Decrement Operators ...•..•...

Address and Indirection ••••...•...•...

Unary Arithmetic Operators ...•...

Casts •.•••..•..•...•.•..•••..•...••...•...••.

Binary Operators •...•...•.••.•...•...•..•.

Norma I Arithmetic 0 perators ... . Shift Operators ... . Relationa I 0 perators ••.•..•...•...•...

Bitwise Boolean Operators ... . Logical Operators .•...•...••••.•••••...•.•....

Cond itiona I Expressions ...••....• II • • • II • • • • • • • • • • • • • •

Simple Assignment ..•.•••...

Compound Assignment ... . Comma Operator ... ..

Constant Expressions ...•....•.•..•...•..•.•..•.•..•.•

Conversions ...•...••... II • • • • • • • • • • • •

Integral Widening Conversions ...•..•...•...

Usual Arithmetic Conversions ...•..•.•...•...•••...

Other Types ...•...•..•....•...

Statements ... .

Labeled Statements ..•...•..•.•.•..••••.•.•....•

E31C>C:~S •••••••••••••••••••••••••••••••••••••••••••••••••

Expression Statement ...•..•...

Null Statement ... . Selection Statements ... . Iteration Statements ...•...•..•.•...

Ju mp Statements .••...•...•.•...•...

lnline Assembly Statements ... . Using lnline Assembly Language ... . Instruction Mnemonics ... . lnline Assembler References to Data and Functions ... .

C Structure Members •...•..•....•.•...

Jump Instructions and Labels .•...•...•...

Comments on In Ii ne Assem ber Statements ... . External Definitions ...•...

Function Definitions ... . Data Definitions ... ..

Portability Considerations ... II • •

Appendix A: Diagnostic Messages ... .

Fatal Messages ... . Error Messages ... ..

Warning Messages ... .

Appendix B: Command Line Options Summary ... .

Contents 7-52 7-52 7-52 7-53 7-54 7-55 7-56 7-57 7-57

7-58

7-58 7-58 7 .. 5g 7 .. 59 7-60 7-60 7-60 7-61 7-61 7 .. s2 7-62 7-62 7-63 7-63 7-63 7-63 7-64 7-65 7-66

7-67 7-67 7-69 7-71

7-72 7-73 7-73 7-73 7.74 7-75

A-1 A-2

A·5

A-19

B·l

(12)

Contents xiii Appendix C: Library Summary . . . C-1 In put-Output Functions. . . • • . . . • . . . • . . . . • . . • • . . . • . C-1 Standard 1/0 • . . . • . . • . . . • • . • . . • . . . • . . . C-1

Block 1/0 . . . .. . • . . . • . . . C-3 Fi le Management . . . . • . . . • . . . • • . . . • • • • . . . C-3 String Handling... C-3 Memory Management. . . C-6

Miscellaneous Arithmetic. . .. . . . • . . . C-6 Searching and Sorting . . . C-7

Program Control • . . . • . . . • . . . . • . • . . . C-7

Date and Time Management. . . • . . . .. .. . . . . C-8 Hardware Functions . . • . . . • . . . C-8 Mathematical Library • • . . • . • . . . . • . . • . • . • • . . . C-9

Glossary ... Glossary-1

Index ... - ... . lndex-1

(13)
(14)

Figures

4-1 4-2 4-3

4-4

Small Model Segments ...•...

Medium Model Segments ... . Large Model Segments ... . Huge Model Segments ... .

Tables

2-1 Application Information for Context

Manager ... .

3-1

Memory Models and Link Files ... .

xv

2-3 3-19

(15)
(16)

Section 1

1-1

Overview

This

section

gives you an overview of the Unisys

BTOS C Compiler, with a look at capabilities, operations, and f ea tu res.

The BTOS C Compiler is capable of generating programs with effectively unlimited amounts of instruction code and data. A compilation switch that controls the amount of

code and data allowed in a program is available. The

compiler allows you to compile separate source files, that you

can

combine to

produce

an

executable

program with the BTOS Linker.

C, a robust and portable programming language, was

developed for a UNIX operating system in the early 1970s by Dennis Ritchie at Bell Laboratories. The flexibility and efficient executing speed of C lend themselves to

structured programming techniques.

Using the C Compiler

The C Compiler runs on a BTOS workstation (826, 827, B28, B38, or B39) executing BTOS II 1.0 or higher. You can also install it on an XE520 master system and execute

it on any BTOS cluster workstation.

You need to have the language development software on your system. Specifically you must have the following:

o BIND command

o

ASSEMBLE command (for use of the inline assembler option)

o Temporary disk storage for intermediate results during each compile

The temporary disk storage should be approximately twice the size of

the

source file you compile when you generate object files directly, or three to four times its size when you generate assembly language output.

You install the software from the three installation

diskettes (refer to section 2). Other files on the diskettes

(17)

1-2 Overview

Features

The C Compiler provides you with the following features:

o

Four memory models: small, medium, large, and huge Huge models allow applications to exceed the normal limitation of 64 Kb for data (globals, statics, and stack

area).

o Mixed-model programming

Mixed-model programming allows use of far data

pointers while compiling modules in the medium model.

o Numerous compile-time switches

1.,hese are provided to control compilation and code generation.

o Built-in LINT facility

This can be used for examining a collection of source files for bugs and obscurities.

o

BTOS II compatibility

o

8087 emulation support and/or use of a floating point

coprocessor

o

UNIX-like support of input/output redirection and pipes.

Memory Requirements

BTOS C requires a minimum memory size of 250 Kb to compile source programs of moderate size.

(18)

Section 2

2-1

BTOS C Compiler Installation

You can use the procedures in this section to install your BTOS C Compiler software. After you install the

software,

you enter the CCOMPILER command at the Executive level to run the compiler.

Installing C Compiler Software

You install the C Compiler software from three 5-1/4-inch software diskettes, B25CE1-1, B25CE1-2, and B25CE1-3.

The diskettes are write-protected.

Note: Because

C

chains to other run files, all C files reside on the [Sys]<Sys> and [Sys]<BtosC> directories. No directory specification is allowed on the Software Installation command form.

To install the C Compiler software on your system, you must have BTOS II 1.0 or higher installed. To use the BTOS C Compiler, you must have approximately 2200 sectors available.

Installing C Compiler Software on a BTOS Workstation

To install the C Compiler software on a BTOS workstation, use the following procedure:

1 Disable the cluster if the system is clustered (use the Executive DISABLE CLUSTER command or power down the other cluster units).

2 Insert the software diskette into the floppy drive [fO].

3 Enter SOFTWARE INST ALLA TI ON at the Executive command line.

4 Press GO.

(19)

2-2 BTOS C Compiler Installation 5 Follow the instructions displayed.

When the system finishes software installation, the highlighted message INSTALLATION OF

BTOS C COMPILER COMPLETE

appears,

followed by an Executive command prompt.

6 Remove the software diskette.

If your workstation is clustered,

you

can resume

cluster operations

using

the RESUME CLUSTER command.

The CCOMPILER command is now available at

the

Executive level;

you

can use the command to compile

C programs.

Installing C Compiler Software on an XE520 Master

To install the C Compiler software on an XE520 master system, use the following procedure:

1 Boot the cluster workstation you want to use for software installation on the XE520.

2 Power down all other cluster workstations.

3 Insert the diskette into the floppy drive [fO] on your workstation.

4 Enter XESOFTWARE INSTALLATION at the

Executive command

line.

5

Press

GO.

6 ~ .. ollow the instructions displayed.

(20)

BTOS C Compiler Installation 2-3

Configuring BTOS Context Manager II to Run This Application

BTOS Context Manager II is BTOS software that lets you run several applications simultaneously so that you can rapidly switch back and forth between them. When

configuring (setting up) Context Manager, you provide information about the applications you wish to run.

Table 2-1 contains information you may need when

configuring Context Manager for this application. For an explanation of how to use this information, refer to the

BTOS Context/Window Manager Installation and

Configuration Guide.

Table 2-1 Application Information for Context Manager Run file name

Run file version Runs in Protected Mode

Minimum memory required

Maximum memory required

Able to be swapped Needs Executive screen

exec.run 6

yes

250 KB

250 KB

yes

no

Loads own font no Loads own keyboard no translation table

Directly manipulates no the video

Special Notes: Command case should be 'CM'.

(21)
(22)

Section 3

3.1

Using the C Compiler

The C Compiler software package allows you to compile separate source files that can be combined to produce

executable programs using the BTOS Linker. The compiler

can generate files

to

assemble

using

the BTOS

Assembler

or produce

standard

object

files.

This section provides you with procedures and information that you need to use the C Compiler. For more information about the Linker, refer to the BTOS II Language

Development Programming Guide.

Memory Utilization

The compiler is capable of

generating programs

with

effectively unlimited amounts of instruction code and data.

A compilation switch controls the amount of code and data allowed in a program.

A total of four memory

models

are supported. Four

sets

of libraries are supplied, one set for each memory model. The memory models are:

Small Medium

Large

Huge

Maximum

Code 64 Kb

1 Mb 1 Mb 1 Mb

+

+ +

+

Maximum Data

64 Kb 64 Kb

1 Mb (64 Kb of

globals/statics and stack)

1 Mb (64 Kb of

globals/statics per source file plus 64 Kb stack)

The smaller models use

memory

more

efficiently

and

program execution may be somewhat faster. The larger models give the programmer complete flexibility for

(23)

3-2 Using the C Compiler

Command Line Syntax

The CCOMPILER command invokes

each

pass of

the

compiler with appropriate options. The [options] line

consists of a series of options (each preceded by '-'), and

the Filename

line specifies one source file to compile. If a filename is provided with no extension, a .C extension is supplied. If some other extension is given, the file is

treated as

if it

had a .C extension.

To compile your C program, use the following

procedure:

1 At the Executive level, enter CCompiler. The following form appears:

Command: CCOMPILER [options]

Filename

2 Enter the options you need in the Options field.

If you supply

more

than one option, separate

each

by a

space. You can place options in

any

order, and

you

can

include any number of them as long as there is room in the command line.

3

Enter

the

name of

the C source file that you want to compile in the filename field.

4 Press Go.

The compiler creates an output file using the

so11rce

filename with an .obj extension for object files or an

.asm extension for assembly

language

files.

Normally, compiler

messages are written to

the

screen. To

direct

these compiler

messages

to a

file other

than

STDOUT, specify redirection on the options line. For

example:

>[splb]

>output.err

Frequently Used Command Line Options

The most freqt1ently used compiler options are described in

this

subsection. The

options

are organized by topic. ~.,or a complete alphabetical list of the compiler options, ref er to appendix B.

(24)

Using the C Compiler 3-3 Controlling Compilation Activity Options

-S This option is required if you have inline assembly statements in your source file. When present, the

named source file is compiled producing an assembly language output file. This .asm file is not assembled, but

requires

you to use the ASSEMBLE command to produce an object file for linking. This option is also useful when you wish to see the assembly language output for your C program.

-k If the compiler detects any

errors

it will exit with an error code of 1. For compilations invoked by a

submit file, this error code will cause the submit file processing to stop. By default, the compiler always exits with an error code of 0, allowing submit file processing to continue.

Specifying Memory Model Options

BTOS C provides four memory models to choose from:

small, medium, large, and huge. All of the source files for a program must be compiled with the same memory model option.

The memory model selected determines the size of pointers in memory and as a

result

determines

the

amot1nt of

memory a

program can

use. A program should use

the

smallest memory

model

that the

program

fits in, since the

smaller memory models

are much

more efficient

than

larger

ones, both in execution speed and in memory

requirements.

Mixed model programming allows programmers to gain

finer control over the manipulation of pointers. Because of the use of special keywords, however, mixed model

programs are not directly

portable

to other environments, so this technique should be used with caution. Used

properly, mixed model programming can provide high performance pointer rnanip11lation even in the larger memory models.

(25)

3-4 Using the C Compiler These compiler options specify, for the large and huge

memory models (and for far pointers in any memory

model), which of two forms of pointer arithmetic is to be used. Files compiled with the same memory model, but

different pointer arithmetic types, can be used in the same program. Refer to section 4 for more information about the runtime environment.

-mh

-mhf

-ml

-mlf

-mm

-mmf

-ms

-msf

This option causes the compiler to produce huge memory model output code. The 20-bit pointer arithmetic is performed using

subroutines.

This option causes the compiler to produce huge memory model output code. The 16-bit pointer arithmetic is performed using inline instructions.

This option causes the compiler to produce large memory model output code. The 20-bit pointer arithmetic is performed using

subroutines.

This option causes the compiler to produce large memory model output code. The 16-bit pointer arithmetic is performed using inline instructions.

This option causes the compiler to produce medium memory model output code. Far

pointers use full 20-bit pointer arithmetic if

they

appear in the files being compiled.

This option causes the compiler to produce medium memory model output code. 14..,ar

pointers use 16-bit pointer arithmetic if they

appear

in the files being compiled.

This option causes the compiler to produce

small memory model output code. Far pointers use full 20-bit pointer arithmetic if they

appear in the files being compiled.

This option causes the compiler to produce

small memory model output code. Far pointers use 16-bit pointer arithmetic if they appear in the files being compiled.

(26)

Using the C Compiler 3-5

Preprocessor Control Options

These options control the specification of preprocessor

#define macros and the specification of search directories for #include files. These options may be used as many

times as

required.

-Didentifier Defines the named identifier to the string consisting of the single character '1'

-Diden =string Defines the named identifier iden to the string after the equal sign. The string cannot contain any spaces or tabs.

-!directory The indicated directory is searched for

#include files in addition to

the

current directory.

-lJidentifier Undefines any previous definitions of the named identifier.

Disk Usage Options

These options change the directory used for temporary and output files.

-nlpath -n2path

-nopath

Places any

.$CC

files in the directory named by path.

Places any other

temporary

files in the directory named by path.

Places any .obj or .asm files in the directory named by path.

Comment Control Option

This option provides for the use of nested comments in the source file.

-C

If present, nested comments are allowed.

Références

Documents relatifs

So this function has tidy memory behavior — all of the memory it allocates while running (its local variable, its one heap block) is deallocated by the time it exits.

Abstract values (of type val ) used in the semantics of the CompCert languages (see [27]) are the disjoint union of 32-bit integers (written int ( i )), 64-bit integers (written long

L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des

Since its inception, the Tiger Compiler Project lacked this very section (see Section 1.4 [History], page 6) and that dedicated to coding style (see Section 2.4 [Coding Style], page

Control information

Control information

Negative intervals are processed in the increasing order of their lower bound, where the variable p is used as a pointer to the position where we may potentially find a point

CompCert ’s memory model limits pointer arithmetic: every implementation- defined operations on pointers results in an undefined behaviour of the memory model.. This may