Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!utgpu!utcsri!greg
From: greg@utcsri.UUCP
Newsgroups: comp.sys.nsc.32k
Subject: Re: cxp/rxp instructions
Message-ID: <5139@utcsri.UUCP>
Date: Fri, 24-Jul-87 23:38:00 EDT
Article-I.D.: utcsri.5139
Posted: Fri Jul 24 23:38:00 1987
Date-Received: Sat, 25-Jul-87 16:06:57 EDT
References: <1439@tekchips.TEK.COM> <486@ivax.doc.ic.ac.uk>
Reply-To: greg@utcsri.UUCP (Gregory Smith)
Organization: CSRI, University of Toronto
Lines: 43
Keywords: Shared libraries
Summary: 

>>>1) What good are the cxp/rxp instructions?...
>>>The reason I ask is that evern cxp/rxp causes the 32xxx to read
>>>from the mod table and I can see this as slowing things down A LOT.
>>
>>These instructions support shared libraries.  Yes, they are somewhat
>>slower than jsr/ret, but they are MUCH faster than doing shared library 
>> calls in software!
>
I haven't seen the other advantage of cxp/rxp yet, so I'll bring it up.

Cxp/rxp ops allow a program to be divided into a number of modules, each
having its own static data. When cxp is used to call a procedure in a different
module, the sb register is reloaded to point to the data of that module.
This static data can be accessed by indexing from the sb register, and the
less data there is, the smaller the indices will be on average. The NS32k
allows three different sizes of index; thus smaller indices mean smaller
and somewhat faster code.
  If cxp is not used, all of the static data for the whole program will be
lumped together, and must be addressed using absolute addressing or by
potentially large offsets from the sb. Note that the external data addressing
mode ( which is time-consuming ) need not be used to access data in another
module; you can use absolute addressing in this case ( not if the other
module is a shared resident library of course ).
 Subroutines which can be called externally must end in rxp, and thus must
be called via cxp, even when called from within the same module. In order
to reduce this effect, the compiler should be able to determine which routines
cannot be externally called, and make them 'jsr/rts' routines.
Unfortunately, in C, the only routines which cannot be called externally are
those decalared 'static', and this declaration is rarely used.
( I am assuming one foo.c file compiles to a single ns32k module, which is
the logical way to do it ).
Languages such as Concurrent Euclid, which directly support the 'module'
paridigm, can make much better use of the cxp/rxp instructions.

Finally, if each object module is an ns32k module ( and if the external
data addressing mode is used ), linking of object modules can be done
VERY cheaply ( i.e. without modifying any of the program text segment ).
This is similar to the way resident shared libraries are done - a RSL
is effectively linked to the program at load time.
-- 
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg
Have vAX, will hack...