09.06.2013 Views

Intel XENIX 286 Programmers Guide (86) - Tenox.tc

Intel XENIX 286 Programmers Guide (86) - Tenox.tc

Intel XENIX 286 Programmers Guide (86) - Tenox.tc

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>XENIX</strong> Programming cc: C Compiler<br />

Creating Small, Middle, Large, and Huge Programs<br />

The cc command supports the creation of programs of a variety of sizes and purposes<br />

using the -Ms, -Mm, -Ml, -Mh, and -i options. These options define the size of a given<br />

program by defining the number of segments in physical memory to be allocated for<br />

your program's use. They also determine how the system loads the program for<br />

execution.<br />

The cc command allows the creation of programs in five different memory models:<br />

impure-text small model, pure-text small model, middle model, large model, and huge<br />

model. Each model defines a different type of program structure and storage.<br />

Impure-Text Small Model<br />

These programs occupy one 64K-byte physical segment in which both text<br />

(machine instructions) and data are combined. By default, cc creates impure<br />

small model programs. They can also be created using the -Ms option.<br />

Pure-Text Small Model<br />

These programs occupy two 64K-byte physical segments. Text and data are in<br />

separate segments. The text is read-only and may be shared by several processes<br />

at once. The maximum program size is 128K bytes. Pure small model programs<br />

are created using the -i flag when linking small model programs.<br />

Middle Model<br />

These programs occupy several physical segments when linked, but only one<br />

segment contains data. A text segment is allocated per source module, but all<br />

data segments are combined. Special calls and returns are used to access<br />

functions in other segments. The total amount of text can be any size. Data<br />

must not exceed 64K bytes. Middle models programs are created using the -Mm<br />

option. These programs are always pure.<br />

Large Model<br />

These programs occupy several physical segments with both text and data in as<br />

many segments as required. Text is handled as in middle model. Special<br />

addresses are used to access data in other segments. Text and data may be any<br />

size, but no data item may be larger than 64K bytes. Large model programs are<br />

created using the -Ml option. These programs are always pure.<br />

Huge Model<br />

These programs occupy several physical segments with both text and data as in<br />

large model, but arrays may span segments, allowing them to be larger than 64K<br />

bytes. Arrays which span more than two segments (128K bytes) must contain<br />

elements whose size in bytes is a power of two. Huge model programs are<br />

created using the -Mh option. These programs are always pure.<br />

Small and middle model object files can be linked only with object files and libraries of<br />

the same model. Large and huge model object files can be linked only with large and<br />

huge model object files and libraries. You cannot combine small, medium, and<br />

large/huge model object files into one executable program. cc automatically selects the<br />

correct small, middle, or large versions of the standard libraries based on the<br />

configuration option. It is up to you to make sure that all of your object files and<br />

private libraries are properly compiled in the appropriate model.<br />

2-5

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!