User guide
168 CHAPTER 9. THE DESIGN OF CINTCODE
These instructions are used move val ue s between register A, B and C.
NOP
This instruction has no effect.
SYS
This instruction is used in body of the han d written library routine sys. If A is zero
then the inter pr e te r returns with exception code P!4.
If A is -1 it set register count to P!4, setting A to the previous value of count.
Changing the value of count may change which of the two interpreters is used. For
more details see Section 4.3.
Otherwise, it performs a system operation returning the result in A. In the C im-
plementation of the interpreter this is done by the following code:
c = dosys(p, g);
MDIV
This instruction is used as the one and only instruction in the body of the hand wri t t en
library rout i ne muldiv, see Section 3.3. It divides P!5 into the double length product of
P!3 and P!4 placing the resul t in A and the remainder in the global variable result2.
It then performs a function return (RTN). Its effect is as follows:
A := <the result>
G!Gn_result2 := <the remainder>
PC := P!1 // PC := P!1
P := P!0 // P := P!0
CHGCO
This inst r uc ti on is used in the implementation of coroutines. It is the one an d only
instruction in the bo dy of the hand wri t te n library routine changeco(val,cptr) where
val is passed in Cintcode register A and cptr is in P!4. Its effect, which is rather subtle,
is shown below. For more information see page 46.
G!Gn_currco!0 := P!0 // !currco := !P -- changeco’s old P pointer
PC := P!1 // PC := P!1 -- changeco’s return address
G!Gn_currco := P!4 // currco := cptr
P := P!4!0 // P := !cptr
BRK
This instruction is used by the debugger to implement break points. It causes the
interpreter to return with exception code 2.