User guide

9.2. THE CINTCODE INSTRUCTION SET 165
Kn 3 n 11
K b
KH h
KW w
These instructi ons call the function or routine whose e ntry point is in A and whose first
argument (if any) is in B. The new stack frame at position k relative to P where k is n,
b, h or w depending on which instruction is used. The effec t of these instructions is as
follows:
P!k := P // Save the old P pointer
P := P+k // Set its new value
P!1 := PC // Save the return address
PC := A // Set PC to the entry point
P!2 := PC // Save it in the stack for debugging
A := B // Put the first argument in A
P!3 := A // Save it in the stack
As can be seen, three words of link information (the old P pointer, the return address
and entry address) are stored in the base of the new stack frame.
KnG b 3 n 11
KnG1 b 3 n 11
KnGH h 3 n 11
These instructions deal with the c ommon situation where the entry point of the function
is in the global vector and the stack increment is in the range 3 to 11. The global number
gn is b, b + 256 or h depending on which funct i on code is used and stack increment k
is n. The first argument (if any) is in A. The effect of these instructions is as follows:
P!k := P // Save the old P pointer
P := P+k // Set its new value
P!1 := PC // Save the return address
PC := G!gn // Set the new PC value from the global value
P!2 := PC // Save it in the stack for debugging
P!3 := A // Save the first argument in the stack
RTN
This instruction causes a return from the current function or routine using the previ ous
P pointer and the return address held in P!0 and P!1. The effect of the instruction is
as follows:
PC := P!1 // Set PC to the return address
P := P!0 // Restore the old P pointer
When returning from a function the result will be in A.