User guide
72 CHAPTER 3. THE LIBRARY
oldcount := sys(Sys
setcount, newcount) CIN:y, POS:y, NAT:n
One of the Cintcode registers is called count which is inspected just before the
interpreter processes the next instruction. If count>0 it is decremented and the in-
struction processed. If count=0 the interpreter returns to the calling (C) program with
error code 3.
The Cintcode System nor mal l y has two resident interpreters. One is calle d cinterp
implemented in C and the other is called fasterp which is sometimes implemented in
assembly l anguage . fasterp is faster than cinterp since it provides fewer debugging
aids, does not count instruction executions and does not implement t he profiling feature.
Setting count to a negati ve value causes this faster interpreter to be invoked and setting
count to a positive value causes the slower interpreter to b e used. Normally the CLI
command interpreter is used to make this switch, see Section 4.3.
With some debugging versions of fasterp, setting count to -2 causes it to exe-
cute just one instruction b ef ore returning with error code 10. This feature assists the
debugging of a new versions of fasterp and is particularly useful when fasterp is
implemented in assembly language.
regs!0 A register – work register
regs!1 B register – work register
regs!2 C register – work register
regs!3 P register – the stack frame pointer
regs!4 G register – the base of the global vector
regs!5 ST register – the status regi st er (unused)
regs!6 PC register – the program counter
regs!7 Count register – see below
regs!8 MW register – Used onl y on 64-bit systems, see below
The count register is normally decremented every time a Cintcode instruction is
interpreted. When the count reaches zero the interpreter saves the registers and returns
with a result (=3) to indicate that this has happened. If the count register is positive,
it indicates how many Cintcode instructions should be executed before the interpreter
returns. A count of -1 is treated as infinity and causes the fast interpreter fasterp to
be used.
Either interpreter returns when a fault, such as div i si on by zero, occurs or when
a call of sys(Sys_quit,...) or sys(Sys_setcount,...) is made. When returning,
the current state of the Cintcode registers is saved. The r et ur ne d result is either
the second argument of sys(Sys_quit,...) or on e of the builtin return c odes in the
following table: