User guide

100 CHAPTER 4. THE COMMAND LANGUAGE
no return link has been stored i nto the stack, this call of start must not attempt
to return in the normal way; however, its execution can still be terminated using
sys(Sys
quit,0).
The global vector and stack shown in figure 4.1 are used by start and form the
running environment both during initialization and while running the debugger. Th e
CLI, on the other hand, is provided with a new stack and a separate global vector,
thus allowing the debugger to use its own globals freely without interfering with the
command language interpreter or running commands. The global vector of 1000 words
is allocated for the CLI and this is shared by the CLI program and its running com-
mands. The st ack, on the other hand, is used exclusively by the command language
interpreter since it creates a coroutine for each command it runs.
stack globals
P Grootnode
0
PC
Entry to start
Tally vector
blklist
SYSLIB BLIB BOOT
Figure 4.1: The initial state
Control is passed to the CLI by means of the call sys(Sys interpret,regs) whi ch
recursively enters the intepreter from an initial Cintcode state specified by the vector
regs i n whi ch that P and G are set to point to the bases of a new stack and a new global
vector for CLI, respectively, PC is the l ocation of the first instruction of startcli, and
count is set to -1. This call of sys(Sys interpret,regs) is emb e dde d in the loop
shown below that occurs at the end of the body of start.
{ LET res = sys(Sys_interpret, regs) // Call the interpreter
IF res=0 DO sys(Sys_quit, 0)
debug res // Enter the debugger
} REPEAT
At the moment sys(Sys
interpret,regs) is first called, only globsize, sys and
rootnode have been set in CLI’s global vector and so the body of startroot must
be coded with care to avoid calling global functions before their entry points have be
placed in the global vector. Thus, for instance, instead of calling globin to initialise
the globals defined in BLIB, SYSLIB and DLIB, the following code is used:
sys(Sys_globin, rootnode!rtn_blib)
If a fault occurs during the execution of CLI or a command that it is running,
the call of sys(Sys
interpret,regs) will return with t he fault code and regs will