Text preview for : BCPL_Runtime_Package_Oct77.pdf part of xerox BCPL Runtime Package Oct77 xerox alto memos_1977 BCPL_Runtime_Package_Oct77.pdf



Back to : BCPL_Runtime_Package_Oct7 | Home

(ALTODOCS)BCPLRUNTIME.TTY;3 MON 17-0CT-77 1:42AM PAGE 1


For Xerox Internal Use Only -- October 17, 1977

Bcpl Runtime Package October 16, 1977 1




Bcpl Runtime Package




This package is a replacement for the standard Bcpl runtime (the one
built into the Alto Operating System), in which nearly all of the
operations have been microprogrammed. Typical Bcpl programs run 25 to
30 percent faster than with the standard routines, depending primarily
on their frequency of procedure calls and their richness in complex
structure references. Use of this package also permits one to Junta to
levBasic if desired, for a savings of approximately 500 words of main
memory.

The microprogrammed runtime is entirely compatible with the standard
one. It does not require programs to be modified or recompiled, and it
works correctly during calls to the Operating System as well as to your
own procedures. The simplest use of this package requires only that
you load the necessary microcode into the Ram and call one
initialization routine.
The package also provides a convenient framework in which to define and
microprogram additional emulator opcodes.



1. Standard Use

The simplest case applies when you do not need to include any special
microcode of your own. The file BcplRuntime.Dm is a dump-format file
containing Bcp1Runtime.Br and BcplRuntimeMc.Br. These modules should
be loaded with your program, along with the LoadRam procedure,
available separately as LoadRam.Br.

Early during initialization, your program should execute the following:
external [ LoadRam; InitBcplRuntime; RamImage ]
if LoadRam(Ramlmage) eq 0 then InitBcp1Runtime()
(LoadRam returns zero if it successfully loaded the Ram and a nonzero
result otherwise, e.g., because no Ram board is installed.)
Once this has been done, the space occupied by LoadRam.Br and
BcplRuntimeMc.Br may be reclaimed. Bcp1Runtime.Br must remain resident
throughout execution of the program, but it occupies only about 150
words whereas the others consume nearly 3000.

InitBcplRuntime sets up a 'user finish procedure' (in the manner
described in the O.S. manual, section 3.12), whose purpose is to
restore the normal Bcpl runtime routines when the program 'finish'es
for any reason. Operation of this mechanism is ordinarily invisible;
however, there are two situations in which the programmer must be aware
of its workings.

First. if you execute a Junta and later a CounterJunta. the
CounterJunta will itself cause the standard Bcpl runtime to be
restored. The later restoration performed by the BcplRuntime package
will be redundant and will do no harm. but the standard (slower) Bcpl
runtime will be in use once the CounterJunta has been executed.
tL




......... _.. _----_..._ - - - - - - - - - - - - - - - - - - - - -
(ALTOOOCS)BCPLRUNTIME.TTY;3 MON 17-0CT-77 1:42AM PAGE 2

:." .
For Xerox Internal Use Only -- October 17, 1977 ".' I




Bcpl Runtime Package October 16, 1977 2




Second, if you Junta away the standard Bcpl runtime routines
themselves, you must be careful to perform initialization in the
correct order. In particular, InitBcplRuntime must be called before
the Junta and before any other code that sets up user finish
procedures. This ensures that at 'finish' time, the cleanup procedure
in the BcplRuntime package will be the last user finish procedure
executed, immediately before control returns to the operating system
for the final time. If this convention is not followed, a subsequent
call on the Bcpl runtime would end up diving into garbage (since
InitBcplRuntime saves and restores only the runtime statics, not the
code) .


2. Adding Your Own Microcode

In order to implement additional emulator instructions or install
microcode for special devices, it is necessary to understand the
workings of the package in some detail. If you don't want to do those
things, you need read no further.
The source files are contained in the dump-format file
BcplRuntimeSource.Om. It includes, among other things, the following
microcode source files:
BcplRuntimeMc.Mu The top-level microcode source file, which
'includes' all the others.
EmulatorOefs.Mu Standard label and R-register definitions useful in
writing code to be run as part of the emulator
task.
RamTrap.Mu Declarations and code for dispatching all opcodes
that trap into the Ram.
GetFrame.Mu Microcode implementing the Bcpl runtime 'GetFrame'
and 'Return' operations.
BcplUtil.Mu Microcode implementing all remaining Bcpl runtime
operations.
In addition to these files, you need AltoConsts23.Mu (or whatever the
current version is), MU.Run, and PackMu.Run. The latest (October 11,
1977) version of Mu is required.
To add new opcodes, you will need to edit BcplRuntimeMc.Mu and
RamTrap.Mu (which should be renamed to something else first). The
changes to Bcp1RuntimeMc.Mu are trivial: simply append 'include'
statements for each of your own source files.
RamTrap.Mu contains the following predefinition:

!37,40, TrapDispatch", GetFrame, Return, BcplUtility;




-_ _
.. ........ _.... _.... _.... _._-_._.. _-_ _ . _ - - - - - - - - - - - - - - - - - - - - - - - - -
...
(ALTODOCS>BCPLRUNTIME.TTY;3 MON 17-0CT-77 1:42AM PAGE 2:1

The labels in this predefinition correspond to the opcodes #60000,
#60400, #61000, #61400, ... , #77400 (a total of 32). However, several
of these cannot be used because their execution does not cause a trap
into the Ram. These are #60000, #60400, #61000, #64400, #65000,
tL
(ALTODOCS)BCPLRUNTIME.TTY;3 MON 17-0CT-77 1:42AM PAGE 3-


For Xerox Internal Use Only -- October 17, 1977

Bcpl Runtime Package October 16, 1977 3




#67000, and #77400. The GetFrame, Return, and BcplUtility instructions
use #61400, #62000, and #62400. All others are available for your own
use simply by adding labels to the predefinition.

When one of these labels is reached, the Alto is in a clean state (no
TASK or memory reference pending), the accumulators ACO through AC3
contain the values supplied by the emulated program, and IR (the DISP
bus source) contains the low-order 8 bits of the opcode, which may be
used for further dispatch if desired.
The routine should finish by executing the following sequence of
operations:
TASK;
something;
SWMODE;
:START;
It is essential that the TASK be executed as late as possible before
the branch to START. The worst-case path in the Rom microcode
beginning at START consists of 19 microinstruction cycles without a
TASK. It has been determined empirically that as few as 3
microinstructions inserted between 'something' and 'SvJMODE' in the
above sequence causes Diablo Model 44 disks to get data-late errors.
(Alas, it is not possible to say 'SWf.100E, TASK' in one microinstruction
because they are both F1's. In hindsight, it would have been nice if
SWMOOE had been implemented in such a way as to cause a TASK also.)
BcplUtil.Mu contains three convenient exit points to which opcode
emulation routines may branch. The code for these exit points is:
StartO: PC~L;
Start1: L~PC, SWMODE;
Start2: PC~L, :START;
One may branch to StartO having just executed 'L~ new PC, TASK;', to
Start1 having just executed 'TASK; something;', or to Start2 having
just executed 'TASK; something; L~ new PC, SWMOOE;'.
Standard R-registers available to the routine are listed in
EmulatorOefs.Mu. These are SAD, XREG, XH, MTEMP, DWAX, and MASK. All
except MTEMP are used exclusively by the emulator task and may be
clobbered arbitrarily (the standard Nova emulator in the Rom does not
depend on them). MTEMP is usable by any task but is safe only until
the next TASK.
You may need to modify EmulatorOefs.f.1u if your microcode defines labels
in low, fixed locations (e.g., START or the task starting addresses).
Note that EmulatorDefs.Mu defines all labels except TRAP1 in a way that
does not consume space in the Ram. You may need to change one or more
of these (e.g., START) to ordinary predefinitions if you intend to
define them in the Ram.

The microcode is assembled and turned into a .Br file by means of the
commands:
Mu BcplRuntimeMc.Mu
PackMu BcplRuntimeMc.Mb BcplRuntimeMc.Br




------------------------------,----,-,-----,-,-"'-"""-'- ,,-, ,,---,,-,--,-------------------- -,----------------------
(ALTODOCS>BCPLRUNTIHE.TTY;3 MON 17-0CT-77 1:42AM PAGE 4


For Xerox Internal Use Only -- October 17. 1977
Bcpl Runtime Package October' 16. 1977 4




The Bcpl runtime microcode contained in the package occupies 337
(decimal) microinstruction words.
tL




------_._---_.__ .... ",-----,-,-,- , - - - - - - - - - - - - - - - - - - ,-_ ... _-,-"---,----------
musum.txt 9-MAY-78 9:29:21 Page 1


Mu Summary



T ..