Intel XENIX 286 Programmers Guide (86) - Tenox.tc
Intel XENIX 286 Programmers Guide (86) - Tenox.tc Intel XENIX 286 Programmers Guide (86) - Tenox.tc
XENIX Programming cc: C Compiler Creating Small, Middle, Large, and Huge Programs The cc command supports the creation of programs of a variety of sizes and purposes using the -Ms, -Mm, -Ml, -Mh, and -i options. These options define the size of a given program by defining the number of segments in physical memory to be allocated for your program's use. They also determine how the system loads the program for execution. The cc command allows the creation of programs in five different memory models: impure-text small model, pure-text small model, middle model, large model, and huge model. Each model defines a different type of program structure and storage. Impure-Text Small Model These programs occupy one 64K-byte physical segment in which both text (machine instructions) and data are combined. By default, cc creates impure small model programs. They can also be created using the -Ms option. Pure-Text Small Model These programs occupy two 64K-byte physical segments. Text and data are in separate segments. The text is read-only and may be shared by several processes at once. The maximum program size is 128K bytes. Pure small model programs are created using the -i flag when linking small model programs. Middle Model These programs occupy several physical segments when linked, but only one segment contains data. A text segment is allocated per source module, but all data segments are combined. Special calls and returns are used to access functions in other segments. The total amount of text can be any size. Data must not exceed 64K bytes. Middle models programs are created using the -Mm option. These programs are always pure. Large Model These programs occupy several physical segments with both text and data in as many segments as required. Text is handled as in middle model. Special addresses are used to access data in other segments. Text and data may be any size, but no data item may be larger than 64K bytes. Large model programs are created using the -Ml option. These programs are always pure. Huge Model These programs occupy several physical segments with both text and data as in large model, but arrays may span segments, allowing them to be larger than 64K bytes. Arrays which span more than two segments (128K bytes) must contain elements whose size in bytes is a power of two. Huge model programs are created using the -Mh option. These programs are always pure. Small and middle model object files can be linked only with object files and libraries of the same model. Large and huge model object files can be linked only with large and huge model object files and libraries. You cannot combine small, medium, and large/huge model object files into one executable program. cc automatically selects the correct small, middle, or large versions of the standard libraries based on the configuration option. It is up to you to make sure that all of your object files and private libraries are properly compiled in the appropriate model. 2-5
cc: C Compiler XENIX Programming The special calls and returns used in middle and large model programs may affect execution time, particularly if frequent calls are made to very short routines. In middle, large, and huge model programs, function pointers are 32 bits long. In large and huge model programs, data pointers are 32 bits long. Programs making use of such pointers must be written carefully to avoid incorrect declaration and use of these types. lint will help to check for correct use. Keep the following in mind when programming in huge model. Objects No object can cross a segment boundary. Objects are defined as data structures that can be elements of an array, scalar objects (integers and floating point numbers), and composite objects (structures and unions). If the array requires three or more segments (more than 128K bytes), then the size of the objects in the array must be a power of two. Address Space When accessing a huge model array, the compiler simulates a linear address space. Array Alignment Arrays of objects requiring more than one segment are aligned so that no object crosses a 64K-byte boundary. Pointer Size Another item to be considered when programming in huge model is the value produced by sizeof(huge_item) and sizeof(huge_ptrl - huge_ptr2). To obtain the correct value, sizeof must be type cast as a long 2-6 (long)sizeof(huge item) (long)sizeof(huge =ptrl - huge _ptr2) where the value returned is a long instead of a normal integer.
- Page 1 and 2: 0 • • •
- Page 3 and 4: The information in this document is
- Page 5 and 6: Table of Contents CONTENTS Compiler
- Page 7 and 8: Table of Contents CONTENTS Using Ot
- Page 9 and 10: Table of Contents CONTENTS Assemble
- Page 11 and 12: Table of Contents CONTENTS CHAPTER
- Page 13 and 14: Table of Contents TABLES TABLE TITL
- Page 15 and 16: Introduction XENIX Programming 10.
- Page 17 and 18: cc: C Compiler XENIX Programming Cr
- Page 19: cc: C Compiler XENIX Programming Th
- Page 23 and 24: cc: C Compiler XENIX Programming Cr
- Page 25 and 26: cc: C Compiler XENIX Programming Th
- Page 27 and 28: cc: C Compiler XENIX Programming Co
- Page 29 and 30: cc: C Compiler XENIX Programming Sa
- Page 31 and 32: cc: C Compiler XENIX Programming Us
- Page 33 and 34: cc: C Compiler XENIX Programming Wh
- Page 35 and 36: cc: C Compiler XENIX Programming Co
- Page 37 and 38: cc: C Compiler XENIX Programming d
- Page 39 and 40: cc: C Compiler XENIX Programming Se
- Page 41 and 42: lint: C Program Checker XENIX Progr
- Page 43 and 44: lint: C Program Checker XENIX Progr
- Page 45 and 46: lint: C Program Checker XENIX Progr
- Page 47 and 48: lint: C Program Checker XENIX Progr
- Page 49 and 50: lint: C Program Checker XENIX Progr
- Page 51 and 52: lint: C Program Checker XENIX Progr
- Page 53 and 54: make: Program Maintainer XENIX Prog
- Page 55 and 56: make: Program Maintainer XENIX Prog
- Page 57 and 58: make: Program Maintainer XENIX Prog
- Page 59 and 60: make: Program Maintainer XENIX Prog
- Page 61 and 62: make: Program Maintainer XENIX Prog
- Page 63 and 64: make: Program Maintainer XENIX Prog
- Page 65 and 66: make: Program Maintainer print: $(F
- Page 67 and 68: SCCS: Source Code Control System XE
- Page 69 and 70: SCCS: Source Code Control System XE
cc: C Compiler <strong>XENIX</strong> Programming<br />
The special calls and returns used in middle and large model programs may affect<br />
execution time, particularly if frequent calls are made to very short routines.<br />
In middle, large, and huge model programs, function pointers are 32 bits long. In large<br />
and huge model programs, data pointers are 32 bits long. Programs making use of such<br />
pointers must be written carefully to avoid incorrect declaration and use of these types.<br />
lint will help to check for correct use.<br />
Keep the following in mind when programming in huge model.<br />
Objects<br />
No object can cross a segment boundary. Objects are defined as data structures<br />
that can be elements of an array, scalar objects (integers and floating point<br />
numbers), and composite objects (structures and unions). If the array requires<br />
three or more segments (more than 128K bytes), then the size of the objects in<br />
the array must be a power of two.<br />
Address Space<br />
When accessing a huge model array, the compiler simulates a linear address<br />
space.<br />
Array Alignment<br />
Arrays of objects requiring more than one segment are aligned so that no object<br />
crosses a 64K-byte boundary.<br />
Pointer Size<br />
Another item to be considered when programming in huge model is the value<br />
produced by sizeof(huge_item) and sizeof(huge_ptrl - huge_ptr2). To obtain the<br />
correct value, sizeof must be type cast as a long<br />
2-6<br />
(long)sizeof(huge item)<br />
(long)sizeof(huge =ptrl - huge _ptr2)<br />
where the value returned is a long instead of a normal integer.