User guide

62 CHAPTER 3. THE LIBRARY
cli
returncode and cli result2 where they can be inspected by commands such as
if and why.
n := str2numb(str) CIN:y, POS:y, NAT:y
This function c onverts the string str into an integer. Characte r s other than 0 to
9 and - are ignored. The result is negative or zero if str%1=’-’. This f unc ti on is no
longer recommended, string
to number should be used inste ad.
n := string
to number(str) CIN:y, POS:y, NAT:y
This attempt s to set result2 to the integer represented by the s tr i ng str. It returns
TRUE is successful and FALSE otherwise. The following are examples of acceptable
strings: "’A’", "123", "-99", "+63", "#377", "-#x7FF" and "+#b1011011".
res := sys(op,...) CIN:y, POS:y, NAT:y
The file sysc/cintsys.c contains the main program of the Cintsys sy st em . It
also includes the definition of an important function dosys which provide access to
I/O operati on s and many other operating system primitives. The file sysc/cinterp.c
contains a C implementation of the Cintcode interpreter. With different compile time
settings this file can generate a faster version by reducing the number of debugging aids
present. Sometimes there is an even faster version of the interpreter implemented in
assembly language, see, for instance, sysasm/linux/cintasm.s. The BCPL function
sys provides an interfac e between BCPL and dosys.
The file sysc/cintpos.c contains the main program of the Cintpos system. It has
much is common with sysc/cintsys.c incl u di ng the function dosys.
The sys function is de fin ed by hand i n cin/syscin/syslib and just invokes the
SYS Cintcode instruction. When SYS is encountered by the interpreter, it normall y
just calls dosys passing the BCPL P and G p oi nters as arguments. But certain sys
operations such as sys(Sys
quit,code) are pr ocessed directly by the inter pr e t er .
As might be expected there are many sys operations concer ned with interrupts
that are only avai l ab l e under Cintpos.
res := sys(Sys
buttons) CIN:y, POS:y, NAT:y
On non standard machines such as the GP2X gaming machine there are buttons
that can be pressed. This call returns a bit pattern indicating which buttons are
currently pressed.
res := sys(Sys callc, fno, a1, a2 ...) CIN:y, POS:y, NAT:y
This makes the cal l cfuncs(args, g) where cfuncs is a C function defined in
sysc/cfuncs.c. The argument args points to memory locations holding fno, a1, a2,
etc., and g points to the base of the global vector.
The fol l owing table summarises the callc op er at i ons currently availabl e (when
running under Linux).
res := sys(Sys
callc, c name2ipaddr, a1) CIN:y, POS:y, NAT:y
The name or dotted decimals of a host is given i n a1 and the result is its IP address
or -1 i f there is an error.