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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

Using Advanced Options<br />

The cc command provides a nu mber of advanced programming options that give greater<br />

control over the compilation process and the final form of the executable program. The<br />

following sections describe a number of these options.<br />

Using the near and far Keyword s<br />

The near and far keywords are special type modifiers that define the length and meaning<br />

of the address of a given variable. The near keyword defines an object with a 16-bit<br />

address. The far keyword defines an object with a full 32-bit segmented address. Any<br />

data item or function can be accessed.<br />

The near and far keywords override the normal address length generated by the compiler<br />

for variables and functions. In small model programs, far can be used to access data and<br />

functions in segments outside of the program. In middle and large model programs, near<br />

can be used to access data with just an offset.<br />

The examples in Table 2-1 illustrate the far and near keywords as used in declarations in<br />

a small model program.<br />

*<br />

**<br />

***<br />

2-16<br />

Table 2-1. Examples of near and far Keywords in a Small Model Program<br />

Declaration<br />

char c;<br />

char far d;<br />

char *p;<br />

char far *q;<br />

char * far r;<br />

char far * far s;<br />

int foo();<br />

int far foo();<br />

Address Size<br />

near (16 bits)<br />

far (32 bits)<br />

near (16 bits)<br />

near (16 bits)<br />

far (32 bits)<br />

far (32 bits)<br />

near (16 bits)<br />

far (32 bits)<br />

This is shown for syntactic completeness.<br />

This is similar to accessing data in a long model program.<br />

Item Size<br />

8 bits (data)<br />

8 bits (data)<br />

16 bits (near pointer)<br />

32 bits (far pointer)<br />

16 bits (near pointer)*<br />

32 bits (far pointer)**<br />

function returning 16 bits<br />

function returning 16 bits***<br />

This example leads to trouble in most environments. The far call changes the CS<br />

register and makes run time support unavailable.

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

Saved successfully!

Ooh no, something went wrong!