User guide
Chapter 4
The Command Language
The Command Language Interpreter (CLI) is a simple interactive interface between the
user an d the system. It loads and exe cut e s previously compiled programs that are held
either i n the current directory or one of the directories specified by the shell environ-
ment var i abl e (typically BCPLPATH or POSPATH) whose name is in rootnode!rtn
path.
These commands are describ ed in Section 4.3 and their source code can be found in
the com directory. The command language is a combination of the features provided
by the CLI and the collection of commands that can be invoked. Under Cintpos, a
similar CLI program provides command language interpreters in several contexts such
as those created by the commands: run, newcli, tcpcli and mbxcli. Details of the
implementation of both CLIs are given at the end of this chapter from page 128.
Commands can set a return code in the global returncode with zero meaning
successful ter mi n ati on and other values indicating the severity of the fault. Commands
that set a non zero retur n code are expected to leave a reason co de in result2. The
CLI copies the return code and reason code of the previous command into the CLI
variables cli
returncode and cli result2, respectively. These can be inspected by
commands such as if and why and also used by the CLI to terminate a command-
command if the failure was severe enough. For details, see the command failat on
page 115 below.
4.1 Bootstrapping Cintsys
When Cintsys is started, control is passed to the int er p re t er which, after a few initial
checks, allocates vectors for the memory of the Cintcode abstract machine and the tally
vector available for statistics gathering. The Cintcode memory is initialised suitably
for sub-allocation by getvec, which is then used to allocate space for the root node,
the initial stack and the initial global vector. The initial state shown in figure 4.1 is
completed by loading the object modules SYSLIB, BLIB and BOOT, and initialising the
root node, the stack and global vector. Interpretation of Cintcode instructions now
begins with the Cintcode register PC, P and G set as sh own in the figure, and Count set
to -1. The other registers are cleared. The first Cintcode instructi on to be executed is
the first instructi on of the body of the function start defined in sysb/boot.b. Since
99