User guide

3.3. GLOBAL FUNCTIONS 45
defined i n the standard re si de nt library. Most of these are defined in BCPL in the files:
sysb/klib.b, sysb/blib.b and sysb/dlib.b, one library (cin/syscin/syslib) is in
hand written Cintcode since it contains instructions that cannot be generated by the
BCPL compiler. The functions defined in syslib are sys, changeco and muldiv.
The standard library functions are described in alphabetical order.
abort(code) CIN:y, POS:y, NAT:n
This causes an exit from the current invocation of the interpre te r , returning code
as the error code. If code is zero execution exits from the Cintcode system. If code
is -1 execution resumes using the faster version of the interpreter (fasterp). If code
is -2 the entire Cintcode memory is written to file DUMP.mem is a compacted form for
processing by CLI commands such as dumpsys or dumpdebug. If code is positive, under
normal conditions, the interactive debugger is entered.
res := appendstream(scb) CIN:y, POS:y, NAT:y
This function sets the position of stream scb to the end so that anything written
to the stream will be appended. The result is FALSE if scb is not an inout stream or
cannot be positioned for other reasons. It returns TRUE oth er wi se .
ch := binrdch() CIN:y, POS:y, NAT:y
This call behaves like rdch() but does not skip over carriage return (’*c’) char-
acters.
ch := binwrch(ch) CIN:y, POS:y, NAT:y
This call behaves like wrch(ch) but does treat ch as a special character and so
does not call deplete at the end of lines and does not inser t carriage return (’*c’)
characters.
res := callco(cptr, arg) CIN:y, POS:y, NAT:y
This call suspends the current coroutine and transfers control to the corou-
tine point e d t o by cptr. It does this by resuming execution of the functi on that
caused its suspension, which then immediately returns yi e l di ng arg as result. When
callco(cptr,arg) next receives control it yiel ds the result it is given. The definition of
callco is i n blib.b and is as follows.
LET callco(cptr, a) = VALOF
{ IF cptr!co_parent DO abort(110)
cptr!co_parent := currco
RESULTIS changeco(a, cptr)
}
res := callseg(name, a1, a2, a3, a4) CIN:y, POS:y, NAT:y
This function loads the compiled program f rom the file name, initialises its global
variables and calls start with the four arguments a1,...,a4. It returns the result of
this call, after unloading the program.