Proposal to add modules to C

Jan Steinman jans at mako.UUCP
Tue May 21 06:32:56 AEST 1985


The NS32000 Series has hardware support for this concept.  (I'm suprised
Henry didn't mention this in his posting -- he seems to know the NS32000.)
It is quite well explained in the National literature, so I won't go over it
in detail.  The trick to resolving external module addresses at run time is to
store them in a "link table", then use a known index into the table to access
the routine.  The extra fetch adds to the (already considerable) overhead of
procedure/function calls; I know of no NS32000 compilers that make use of this
feature, but then I don't know of too many!  For instance the function
"printf()" gets compiled to the following assembly code in "traditional" use:

	jsr	_printf	;Does not exist at assemble time, must be linked.

The linker then loads in all the printf() code (which probably includes a lot
of dead code if you only wanted to do "printf("%s\n", string);) and resolves
the address in the "jsr" call.  Using National's external addressing, the
compiler-generated instruction

	cxp	1234	;(or some other meaningless-to-humans index)

causes a jsr (sort of) through the 1234th location in the module's link table.
Linking is then a simple matter of contiguous loading with no address
resolution needed.  The many address fetches needed makes this a slow process;
National does it about as efficiently as can be expected.

This might be less than accurate, and I've left out detail, but the concept
of "modules" is supported by NS32000 hardware.  Look in their book for more.
-- 
:::::: Jan Steinman		Box 1000, MS 61-161	(w)503/685-2843 ::::::
:::::: tektronix!tekecs!jans	Wilsonville, OR 97070	(h)503/657-7703 ::::::



More information about the Comp.lang.c mailing list