User guide
4 CHAPTER 1. THE SYSTEM OVERVIEW
the debugger. The data word at location 4 holds a special bit pattern indicating
the presence of a func ti o n name placed just before the entry point. As can be
seen the name in this case is start. Similar information is packed at location 60
for the function fact. Most Cintcode instructions occupy one byt e and perform
simple operations on the registers and memo ry of the Cintcode machine. For
instance, the first two instructions of start (L1 and SP3 at locations 20 and 21)
load the constant 1 into the Cintcode A register an d then stores it at word 3 of
the current stack frame (pointed to by P). This corresponds to the initialisation
of the for-loop control variable i. The star t of the for-loop body has label L4
corresponding to location 22. The compil at i on of fact(i) is LP3 LF L2 K9 which
loads i and the entry address of fact and enters the function incrementing P by 9
locations). The re su l t of this function is returned in A which is stored in the stack
using SP9 in the appropriate position for the third argument of the call of writef.
The second argument, i, is setup using LP3 SP8, and the first argument which
is the format string is l oa d ed by LLL L9920. The next instruction (K4G 94)
causes the routine writef, whose entry point is in global vari ab l e 94, to be
called incrementing P by 4 words as it does so . Thus the compilation of the call
writef("fact(%n) = %i5*n", i, f(i)) occupies just 11 bytes from location 22
to 32, plus the 16 bytes at location 44 where the string is packed. The next three
instructions (L1 AP3 SP3) increment i, and L5 JNE L4 jumps to label L4 if i is
still less than 5. If the jump is not taken, control falls through to the instructions
L0 RTN causing start to return with result 0. Each instruction of this function
occupies one byte except for the LF, LLL, K4G and JNE instructions wh i ch each
occupy two. The body of the fun ct i on fact is equally easy to understand. It first
tests whether its argument is zero (JNE0 L5). If it is, it returns one (L1 RTN).
Otherwise, it computes n-1 by loading -1 and adding n (LM1 AP3) before calling
fact (LF L2 K4). The result is th en multiplied by n (LP3 MUL) and retur n i n g
(RTN). The space occupied by this code is just 12 bytes.
The debugger can be entered using the abort command.
0.030> abort
!! ABORT 99: User requested
*
The asterisk is the prompt inviting the user to enter a debu g gi n g command. The
debugger provides faci l it i es for inspecting and changing memory as well as setting
breakpoints and performing single step execution. As an e xam ple, a breakpoint
is placed at the first instruction of th e r o u t i n e clihook wh i ch is used by the
command language i nterpreter (CLI) to transfer control to a command. Con si der
the following commands:
* g4 b1
* b
1: clihook
*