'near' and 'far' keywords (was Re: cdecl keyword ( re: C Decl ... ))

Daniel A. Glasser dag at chinet.UUCP
Sat Apr 16 00:11:34 AEST 1988


In article <146 at obie.UUCP> wes at obie.UUCP (Barnacle Wes) writes:
>So why should we force these MS-DOSisms on the rest of the C-speaking
>world?  This is yet another kludge around the Intel iAPX?86
>architecture (or lack thereof :-), just like "near" and "far".  Tell
>me, what does "near" mean on a 68000 system?  I can call C routines
>from the Unix fortran compiler WITHOUT declaring the C routine to be
>of "fortran calling sequence."  Let's not put these kludges in a C
>language standard.  If your programming environment needs them, let
>them be (non-portable) extensions to the standard needed to support
>your (non-) operating system!

Although I agree fully with Wes's comments about MS-DOSisms, the common
extensions 'near' and 'far' can be used to some benifit in a 68000 compiler.
The architecture of the 68000 is such that PC Relative calls and data
references are faster and smaller than their absolute counterparts, and on
systems with runtime relocation reduce the load time and load module size
by an additional amount.  With the addition of these two keywords, a compiler
can be directed to generate one or the other type of reference by default and
the use the keyword to override this.  That is not to say that I believe that
these keywords should be added to the standard, but that they should be listed
as a common extension so that their usage is consistant between different
envionments.  (Although the useage would be similar between the M68000 and
I80x86 environments, the meaning would be quite different.)

The compiler that I work on for the M68000 does not support this extension,
but does support generation of either PC relative or absolute references for
data fetches and calls.  Use of the PC relative option is very tricky because
the range of the fetches must be +-32k from the instruction, and sometimes
the functions are too far away.  With the addition of the near and far
extensions, I could simply (with a knowlege of the structure of my program)
declare the far away functions to be far, compile with all function calls
defaulting to PC relative, and compile the modules that get loaded at the
end with PC relative data references.  (The environment I work on has the
data segment directly following the text segment and the bss directly after
that.)

(The above example is supposed to demonstrate the difference in meaning
of these keywords for different environments.)

Disclaimer:
	I speak for the millions of subjigated lifeforms that are forced
	to unite to form my body.  They may not agree with me, but I am
	a heartless tyrant.  I make no claims to speak for any other
	conglomerations of protoplasm, micro or macro.
-- 
		Daniel A. Glasser	dag at chinet.UUCP
    One of those things that goes "BUMP!!! (ouch!)" in the night.
 ...!att-ih!chinet!dag | ...!ihnp4!mwc!dag | ...!ihnp4!mwc!gorgon!dag



More information about the Comp.lang.c mailing list