$A Escape = '/'
/a page=58
/a just=1;  mark=2
/a top=6;  bottom=3
/a pageno=1
/a tab=2,8,16,19,22
/a left=8;  line=68
/b8
/l3m
I-code V1.3 Working-Notes
Peter S. Robertson
1 October 1984

/l0

           1   Philosophy
           2   Definitions
           3   Conventions
           4   Instructions

  Appendix 1  Encodings
  Appendix 2  Instructions which set the condition-code
  Appendix 3  Instructions which test the condition-code





      Note:  This document in not intended to be a
             complete formal description of I-code























                         Copyright (c) 1984
                        Lattice Logic Limited
                           9, Wemyss Place
                          Edinburgh EH3 6DH
                              Scotland
/n
/Lm
1   Philosophy
/b I-code is an intermediate code used to provide an interface between
the machine-independent and machine-dependent sections of a compiler.
/b Most intermediate codes in use today describe the execution of an
abstract machine which performs the desired computation. For example,
the intermediate code for a statement of the form:   X/ =/ Y+Z
would describe the operations of the abstract machine which would
compute the value of Y+Z and assign it to X. Using this sort of code
the machine-dependent section of the compiler has to map the abstract
machine onto the real target machine.
/b I-code uses a fundamentally different model. It describes the
execution of an abstract compiler which generates target code to
perform the desired computation; it does not describe an abstract machine
which will perform that computation. It is vital to understand that it does
not describe the function of the program directly but describes it
indirectly via the abstract compiler. It is this indirection which
gives I-code the power to be machine-independent without sacrificing
efficiency in the executable programs which it can be used to generate.
/b There are two important corollaries of this. Firstly the structures
and operations associated with the abstract compiler need have no
counterparts in the object program. For example the target machine
need have no hardware or software stack and neither need it have a true
condition code. Secondly the code assumes that the operations it describes
will be performed by the abstract compiler in the order specified with
no omissions. In particular the control transfer instructions do not
transfer control in the abstract compiler but indicate changes of
control flow in the program which is being compiled. This also does not
mean that any of the operations need have counterparts in the object program
nor that the order of the generated code need correspond to the order
of the I-code.
/b For example the Algol-60 statement:
   A := if B then C else D;
could not be encoded in the seemingly obvious way:
/l0i
   Stack A
   Stack B;  Test-Boolean;  BF 1
   Stack C;  Forward 2
   Label 1
   Stack D
   Label 2
   Assign-Value
/b0
as this would assign D to C, the last two objects stacked prior to the
Assign-Value instruction, and leave A on the stack.
/n
/Lm
2   Definitions
/a indent=3
/b/t1 byte-order /t3 All multi-byte values are specified with the
least-significant byte first.
/b/t1 unsigned  /t3 a natural binary number.
/b/t1 signed    /t3 a 2's complement binary number.
/b/t1 <b>       /t3 A one-byte unsigned number.
/b/t1 <integer> /t3 A four-byte signed integer number.
/b/t1 <label> /t3 An unsigned 16-bit value used to identify a simple label.
/b/t1 <n>     /t3 An unsigned 16-bit number.
/b/t1 <string> /t3 A byte-counted string constant.
/b/t1 <real>  /t3 A real constant in a textual encoding.
/b/t1 <tag> /t3 An unsigned 16-bit value used to identify a tag (descriptor).

/b/t1 condition-code /i3 A conceptual flag which is set at run-time by
the instructions listed in Appendix 2.
This flag need not exist in the target machine must is defined in order to
simplify the definitions of certain instructions.
 The values which this flag may take are:
/li
   equal, less than, greater than, true, false
This setting only remains valid for the duration of the next instruction
which must be one of the instructions listed in Appendix 3.

/b/t1 integer /t3 A general integer value, including subranges of integers.
/v24
/b/t1 labels /t3 I-code distinguishes two sorts of label.
/b 1. Simple labels have the property that they are only jumped to
in one direction, that is, all references to an instance of a simple label
are either all forward or all backward. This means that the same denotation may
be used for many simple labels. For example the following is valid:
/l0i
   Forward 1   >-----+
   ...                |
   Label 1     <-----+
   ...
   Forward 1   >-----+
   ...                |
   Label 1     <-----+
   ...
   Label 1     <-----+
   ...                |
   Backward 1  >-----+
/b All uses of a particular simple label must be in the same block
as the definition of that label.
/b Simple labels are encoded as two-byte unsigned integers although code
generators may assume the their values are within a fairly small range;
1..50 is common.
/v10
/b 2. General labels have none of the restrictions of simple labels.
They are identified by tags and will be defined automatically if
necessary when they are first used.
General labels are referenced by the instructions:
/l0i
   Jump <tag>
   Locate <tag>
   Stack <tag>
/b/t1 real /t3 A floating-point value, either single or double precision.
/b/t1 SOS /t3 The second-top item on the stack.
/b/t1 stack /t3 A first-in, last-out structure used to imply
the operands required by various I-code instructions.
The first item which can be removed from the stack is called TOS and
the item which can be removed after TOS is called SOS.
/n/t1 tags /t3 Tags are definitions of objects which are to be manipulated
by the compiler.
These definitions are created in a nested fashion; all tags defined in a
block are deleted when the end of that block is reached.
 On definition the machine-independent description of the
object is converted into the appropriate machine-dependent description
of the actual object to be used. Within this document the term 'tag' is
used to describe both this descriptor and the unsigned sixteen-bit integer
used as an index value to select it from the collection of all tags.
With the exception of the resolution of
forward references to procedures, tags are never altered.
When a copy of a tag value is pushed onto the stack the value becomes known
as a descriptor. Descriptors may be modified.
/b/t1 tag list /t3 is an ordered sequence of tag definitions used to
describe either the parameters required by a procedure or the
fields of a record. Components of a tag list are referred to either
explicitly by their position in the list (see SELECT) or implicitly
by sequence starting with the first to be specified (see Assign-Parameter).
/b/t1 TOS /t3 The top item on the stack.
/b/t1 list flag /t3 An internal flag which is set during the processing
of explicit lists of tag definitions. Its only purpose is to prevent
certain nested list structures.
/a indent=0
/n
/Lm
3 Conventions
/a indent=2

/b/t1 1. /t2 It is assumed that the reader is familiar with the IMP language and
its terminology.

/b/t1 2. /t2 Whenever a pointer-variable is used in the context of a value the
value of the data item pointed to will be used.

/b/t1 3. /t2 In general, diagnostic checks are implied rather than explicitly
specified.

/b/t1 4. /t2 Items on the stack are intended to be 'rules for generating' values
or references rather than the values or references themselves. For simplicity
the descriptions of instructions will often refer to items as if they actually
contain values or references.

/b/t1 5. /t2 By convention tag index values will often be replaced in examples
by the identifier which is assumed to have been associated with the tag in
question.

/b For example, given 'DEFINE/ 57,Fred......' then
'Stack/ 57' could be written 'Stack/ Fred'

/b/t1 6. /t2 The term 'error' is used to indicate a condition discovered by the
code-generator which should terminate the compilation with a suitable
error message.

/n
/Lm
4   Instructions
/a indent=3
/b/v12
/b/t1
Instruction: /t3 Absolute
/b/t1 Effect:      /t3 TOS is replaced by the absolute
value of TOS.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack is empty.
                /b0/t3 2. /t4 TOS is not integer or real.
/a indent=3
/b/t1 Example:     /t3 X = |Y+Z|
/l0i
Stack X;   Stack Y;  Stack Z;  Add
Absolute;  Assign-Value

/b/v12
/b/t1 Instruction: /t3 Access
/b/t1 Effect:      /t3 TOS is used as the final index into SOS. TOS is removed
from the stack leaving SOS as the new TOS.
/b/t1 Notes:       /t3 This instruction is used to process the final
dimension of an N dimensional array. See Index for the previous dimensions.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack contains less than two items.
                /b0/t3 2. /t4 TOS is not an integer value.
                /b0/t3 3. /t4 SOS does not describe an array.
/a indent=3
/b/t1 Example:     /t3 A(j) = 0
/l0i
Stack A;  Stack j;  Access
Byte 0;   Assign-Value

/b/v12
/b/t1 Instruction: /t3 Add
/b/t1 Effect:      /t3 TOS and SOS are removed from the stack and a new item
describing the  sum of the their values, SOS/ +/ TOS, is stacked. Integer values
will be converted into floating-point if one operand is integer and the other is
real.

/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack contains less than two items.
                /b0/t3 2. /t4 TOS (or SOS) is neither integer nor real type.
/a indent=3
/b/t1 Example:     /t3  A = B + C
/l0i
Stack A;  Stack B;  Stack C;  Add;  Assign-Value

/b/v12
/b/t1 Instruction: /t3 Address
/b/t1 Effect:      /t3 TOS is replaced by the address of the object it
describes.
/b/t1 Notes:       /t3 Commonly the type of an address will be indistinguishable
from integer.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack is empty.
                /b0/t3 2. /t4 TOS does not have an address.
/a indent=3
/b/t1 Example:     /t3 P = Addr(Q)
/l0i
Stack P;  Stack Q;  Address;  Assign-Value

/b/v12
/b/t1 Instruction: /t3 Adjust
/b/t1 Effect:      /t3 The address of SOS is adjusted forwards or backwards by
TOS items of the same size as SOS. This may be thought of as an array accessing
instruction where SOS defines the zero'th element.

/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack contains less than two items.
                /b0/t3 2. /t4 TOS is not an integer.
                /b0/t3 3. /t4 SOS does not reference a data object.
/a indent=3
/b/t1 Example:     /t3 N == N[X]
/l0i
Stack N;  Stack N;  Stack X
Adjust;  Assign-Reference

/b/v12
/b/t1 Instruction: /t3 Alias <string>
/b/t1 Effect:      /t3 <string> is noted as the current alias.
/b/t1 Note:        /t3 See 'Begin' and 'Define'
/A indent=4
/b/t1 Errors:      /t3 None
/a indent=3
/b/t1 Example:     /t3 %external %integer Thing %alias "SS$THING"
/l0i
Alias "SS$THING"
Define THING..........

/b/v12
/b/t1 Instruction: /t3 Alt-Start
/b/t1 Effect:      /t3 This instruction marks the start of an alternative
sequence of tag definitions.
/b/t1 Note:        /t3 The instructions Alt-Start and Alt-Finish  are brackets
and must be properly nested.

/A indent=4
/b/t1 Error:       /t3 1. /t4 List flag is not set.
/a indent=3
/b/t1 Example:
/l0i
%recordformat F(%integer X, (%integer Y %or %real Z))
Define F.......
Start
   Define X.....
   Alt-Start
      Define Y.....
   Next-Alt
      Define Z.....
   Alt-Finish
Finish

/b/v12
/b/t1 Instruction: /t3 Alt-Finish
/b/t1 Effect:      /t3 This instruction marks the end of a list of
alternatives.
/b/t1 Notes:       /t3 Alt-Start and Alt-Finish must be properly nested.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 List flag is not set.
                /b0/t3 2. /t4 There has been no unmatched Alt-Start instruction.
/a indent=3
/b/t1 Example:
/l0i
%recordformat F(%integer X, (%integer Y %or %real Z))
Define F.......
Start
   Define X.....
   Alt-Start
      Define Y.....
   Next-Alt
      Define Z.....
   Alt-Finish
Finish

/b/v12
/b/t1 Instruction: /t3 And
/b/t1 Effect:      /t3 TOS and SOS are removed from the stack and the logical
AND of their values, SOS/ &/ TOS, is stacked.

/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack contains less than two items.
                /b0/t3 2. /t4 TOS and SOS are not both integer values.
/a indent=3
/b/t1 Example:     /t3  A = B & C
/l0i
Stack A;  Stack B;  Stack C;  And;  Assign-Value

/b/v12
/b/t1 Instruction: /t3 Assign-Parameter
/b/t1 Effect:      /t3 TOS is passed as the next parameter to SOS.
TOS is removed from the stack leaving SOS as the new TOS.
/b/t1 Note:        /t3 Parameters must be specified in the order of the
definition of the parameter list. If the parameter list is empty the occurence
of this instruction implies that the procedure has a variable number of
parameters and so the parameters are to be passed in a C-like manner; this also
requires that the procedure be called using the Variable-Call instruction.

/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack contains less than two items.
                /b0/t3 2. /t4 SOS is not a procedure descriptor.
                /b0/t3 3. /t4 TOS is unsuitable for this parameter.
/a indent=3
/b/t1 Example:     /t3 J = Calc(1, K)
/l0i
Stack J;  Stack Calc
Byte 1;   Assign-Parameter
Stack K;  Assign-Parameter
Call

/b/v12
/b/t1 Instruction: /t3 Assign-Value
/b/t1 Effect:      /t3 The value of TOS is assigned to the data item
referenced by SOS. Both TOS and SOS are removed from the stack.
/b/t1 Notes:       /t3 Integer values will be converted to real if necessary.
/A indent=4
/b/t1 Error:       /t3 1. /t4 The stack contains less than two items.
/a indent=3
/b/t1 Example:     /t3 A = B+C
/l0i
Stack A;  Stack B;  Stack C;  Add;  Assign-Value

/b/v12
/b/t1 Instruction: /t3 Assign-Reference
/b/t1 Effect:      /t3 The pointer variable referenced by SOS is made to
point at the variable referenced by TOS.
Both TOS and SOS are removed from the stack.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack contains less than two items.
                /b0/t3 2. /t4 SOS is not a reference to a pointer variable.
                /b0/t3 3. /t4 TOS is not a reference to a variable.
                /b0/t3 4. /t4 The types of TOS and SOS are different.
/a indent=3
/b/t1 Example:     /t3 P == Q
/l0i
Stack P;  Stack Q;  Assign-Reference

/b/v12
/b/t1 Instruction: /t3 Backward <label>
/b/t1 Effect:      /t3 Control is to be transferred unconditionally to <label>
at run-time.
/A indent=4
/b/t1 Errors:      /t3 <label> is currently undefined.
/a indent=3
/b/t1 Example:     /t3 X=X+1 %while A(X) = 0
/l0i
Label 16
Stack A;  Stack X;  Access
Byte 0;  Compare-Values;  BNE 17
Stack X;  Stack X;  Byte 1;  Add;  Assign-Value
Backward 16
Label 17

/b/v25
/b/t1 Instruction: /t3 Begin
/b/t1 Effect:      /t3 An anonymous procedure is defined here and called once.
A new block is entered. If an alias has been noted (see Alias) that string will
be used for identifying the block in diagnostic information leaving
no alias noted.
/b/t1 Notes:       /t3 The sequence "Begin/ ....../ End"
may always be replaced by a sequence of the form:
/li
Define X...... Start Finish ...... End;  Stack X;  Call
where X is a suitable unique tag.
/A indent=4
/b/t1 Errors:      /t3 None
/a indent=3
/b/t1 Example:     /t3 %begin;  Newline;  %end
/l0i
Begin
   Stack Newline;  Call
End

/b/v12
/b/t1 Instruction: /t3 BEQ <label>
/b/t1 Effect:      /t3 When execution of the object program reaches this
point control is to be transferred to the given simple label if the
condition code is set 'equal', otherwise control is to pass onto the
next instruction.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The previous instruction did not set the
condition-code.
                /b0/t3 2. /t4 <label> does not get defined by a LABEL instruction
                         before the end of the current block.
/a indent=3
/b/t1 Note:        /t3 <label> must refer to a simple label which must be
defined somewhere after the BEQ instruction, that is BEQ can only specify
a forward jump (although the object program may use a backward jump).
/b/t1 Example:     /t3 IF x <> y THEN p = q;
/l0i
Stack x;  Stack y;  Compare-Values
BEQ 12
Stack p;  Stack q;  Assign-Value
Label 12

/b/v12
/b/t1 Instruction: /t3 BF <label>
/b/t1 Effect:      /t3 When execution of the object program reaches this
point control is to be transferred to the given simple label if the
condition code is set 'false', otherwise control is to pass onto the
next instruction.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The previous instruction did not set the
condition-code.
/b0/t3 2. /t4 <label> does not get defined by a LABEL instruction before the end of the
current block.
/a indent=3
/b/t1 Note:        /t3 <label> must refer to a simple label which must be
defined somewhere after the BF instruction, that is BF can only specify
a forward jump (although the object program may use a backward jump).
/b/t1 Example:     /t3 if B then P := Q;
/l0i
Stack B;  Test-Boolean
BF 12
Stack P;  Stack Q;  Assign-Value
Label 12

/b/v12
/b/t1 Instruction: /t3 BGE <label>
/b/t1 Effect:      /t3 When execution of the object program reaches this
point control is to be transferred to the given simple label if the condition
code is set 'greater than' or 'equal' , otherwise control is to pass onto the
next instruction.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The previous instruction did not set the
condition-code.
/b0/t3 2. /t4 <label> does not get defined by a LABEL instruction before the end of the
current block.
/a indent=3
/b/t1 Note:        /t3 <label> must refer to a simple label which must be
defined somewhere after the BGE instruction, that is BGE can only specify
a forward jump (although the object program may use a backward jump).
/b/t1 Example:     /t3 %if X < Y %then P = Q
/l0i
Stack X;  Stack Y;  Compare-Values
BGE 12
Stack P;  Stack Q;  Assign-Value
Label 12

/b/v30
/b/t1 Instruction: /t3 BGT <label>
/b/t1 Effect:      /t3 When execution of the object program reaches this
point control is to be transferred to the given simple label if the
condition code is set 'greater than', otherwise control is to pass onto the
next instruction.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The previous instruction did not set the
condition-code.
/b0/t3 2. /t4 <label> does not get defined by a LABEL instruction before the end of the
current block.
/a indent=3
/b/t1 Note:        /t3 <label> must refer to a simple label which must be
defined somewhere after the BGT instruction, that is BGT can only specify
a forward jump (although the object program may use a backward jump).
/b/t1 Example:     /t3 %if X <= Y %then P = Q
/l0i
Stack X;  Stack Y;  Compare-Values
BGT 12
Stack P;  Stack Q;  Assign-Value
Label 12

/b/v12
/b/t1 Instruction: /t3 BLE <label>
/b/t1 Effect:      /t3 When execution of the object program reaches this
point control is to be transferred to the given simple label if the condition
code is set 'less than' or 'equal' , otherwise control is to pass onto the
next instruction.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The previous instruction did not set the
condition-code.
/b0/t3 2. /t4 <label> does not get defined by a LABEL instruction before the end of the
current block.
/a indent=3
/b/t1 Note:        /t3 <label> must refer to a simple label which must be
defined somewhere after the BLE instruction, that is BLE can only specify
a forward jump (although the object program may use a backward jump).
/b/t1 Example:     /t3 %if X > Y %then P = Q
/l0i
Stack X;  Stack Y;  Compare-Values
BLE 12
Stack P;  Stack Q;  Assign-Value
Label 12

/b/v30
/b/t1 Instruction: /t3 BLT <label>
/b/t1 Effect:      /t3 When execution of the object program reaches this
point control is to be transferred to the given simple label if the
condition code is not set 'equal', otherwise control is to pass onto the
next instruction.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The previous instruction did not set the
condition-code.
/b0/t3 2. /t4 <label> does not get defined by a LABEL instruction before the end of the
current block.
/a indent=3
/b/t1 Note:        /t3 <label> must refer to a simple label which must be
defined somewhere after the BLT instruction, that is BLT can only specify
a forward jump (although the object program may use a backward jump).
/b/t1 Example:     /t3 %if X >= Y %then P = Q
/l0i
Stack X;  Stack Y;  Compare-Values
BLT 12
Stack P;  Stack Q;  Assign-Value
Label 12

/b/v30
/b/t1 Instruction: /t3 BNE <label>
/b/t1 Effect:      /t3 When execution of the object program reaches this
point control is to be transferred to the given simple label if the
condition code is not set 'equal', otherwise control is to pass onto the
next instruction.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The previous instruction did not set the
condition-code.
/b0/t3 2. /t4 <label> does not get defined by a LABEL instruction before the end of the
current block.
/a indent=3
/b/t1 Note:        /t3 <label> must refer to a simple label which must be
defined somewhere after the BNE instruction, that is BNE can only specify
a forward jump (although the object program may use a backward jump).
/b/t1 Example:     /t3 %if X = Y %then P = Q
/l0i
Stack X;  Stack Y;  Compare-Values
BNE 12
Stack P;  Stack Q;  Assign-Value
Label 12

/b/v22
/b/t1 Instruction: /t3 Bounds
/b/t1 Effect:      /t3 The value of TOS is noted as 'upper-bound' and the
value of SOS is noted as 'lower-bound'. TOS and SOS are removed from the stack.
/b/t1 Notes:       /t3 This instruction is used as a preliminary to defining
%switch vectors and %own, %const and %external arrays.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack contains less than two items.
                /b0/t3 2. /t4 TOS and SOS are not both integer values.
                /b0/t3 3. /t4 The value of TOS is less than the value of SOS.
/a indent=3
/b/t1 Example:     /t3 %switch Sw(-3:3)
/l0i
Byte 3;  Negate
Byte 3;  Bounds
Define Sw.......

/b/v30
/b/t1 Instruction: /t3 BT <label>
/b/t1 Effect:      /t3 When execution of the object program reaches this
point control is to be transferred to the given simple label if the
condition code is set 'false', otherwise control is to pass onto the
next instruction.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The previous instruction did not set the
condition-code.
/b0/t3 2. /t4 <label> does not get defined by a LABEL instruction before the end of the
current block.
/a indent=3
/b/t1 Note:        /t3 <label> must refer to a simple label which must be
defined somewhere after the BT instruction, that is BT can only specify
a forward jump (although the object program may use a backward jump).
/b/t1 Example:     /t3 if not B then P := Q
/l0i
Stack B;  Test-Boolean
BT 12
Stack P;  Stack Q;  Assign-Value
Label 12

/b/v12
/b/t1 Instruction: /t3 Byte <b>
/b/t1 Effect:      /t3 The unsigned byte value <b> is stacked.
/b/t1 Notes:       /t3 This is a compact form for the Integer instruction
when small values are to be stacked.
/A indent=4
/b/t1 Errors:      /t3 None
/a indent=3
/b/t1 Example:     /t3 X = 200
/l0i
Stack X;  Byte 200;  Assign-Value

/b/v12
/b/t1 Instruction: /t3 Call
/b/t1 Effect:      /t3 The procedure described by TOS is called. If
TOS is a procedure which returns a result TOS is replaced by that result,
otherwise TOS is removed from the stack.
/b/t1 Notes:       /t3 Predicates do not return a result but set the
condition-code.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack is empty.
                /b0/t3 2. /t4 TOS does not describe a procedure.
                /b0/t3 3. /t4 There has not been the same number of parameters
assigned using Assign-Parameter as is specified by the parameter list.
/a indent=3
/b/t1 Example:     /t3 Newline
/l0i
Stack Newlines;  Byte 4;  Assign-Parameter;  Call

/b/v12
/b/t1 Instruction: /t3 Compare-References
/b/t1 Effect:      /t3 The address of SOS is compared to the address of TOS and
the condition-code is set appropriately. TOS and SOS are then removed from the
stack.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack contains less than two items.
/b0 /t3 2. /t4 TOS or SOS is not a reference for a data object.
/a indent=3
/b/t1 Example:     /t3 %integername M;  %integer N
/l0i
%if N == M %then Newline

Stack N;  Stack M;  Compare-References
BNE 14
Stack Newline;  Call
Label 14

/b/v30
/b/t1 Instruction: /t3 Compare-Repeated-Values
/b/t1 Effect:      /t3 SOS is compared to TOS and the condition-code is set
appropriately. SOS is then removed from the stack leaving TOS.
/b/t1 Notes:       /t3 The types of both TOS and SOS must be one of the
following four:
/l0i
   Integer or Real
   String
   Record
   Set
/b0 Integer values will be converted to real if one operand is real.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack contains less than two items.
/b0/t3 2. /t4 The types of TOS and SOS are incompatible.
/a indent=3
/b/t1 Example:     /t3  %if 1 <= X <= 12 %then X = 0
/l0i
Byte 1;  Stack X;  Compare-Repeated-Values
BGT 15
Byte 12;  Compare-Values
BGT 15
Stack X;  Byte 0;  Assign-Values
Label 15

/b/v12
/b/t1 Instruction: /t3 Compare-Unsigned-Values
/b/t1 Effect:      /t3 SOS is compared against TOS with the values being
interpreted as unsigned values.
The condition-code is set accordingly and TOS and SOS are removed from the
stack
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack contains less than two items.
                /b0/t3 2. TOS and SOS are not both integer values.
/a indent=3
/b/t1 Example:     /t3 %if U1 < U2 %then U2 = 0
/l0i
Stack U1;  Stack U2;  Compare-Unsigned-Values
Bge 31
Stack U2;  Byte 0;  Assign-Value
Label 31

/b/v30
/b/t1 Instruction: /t3 Compare-Values
/b/t1 Effect:      /t3 SOS is compared to TOS and the condition-code is set
appropriately. TOS and SOS are then removed from the stack.
/b/t1 Notes:       /t3 The types of both TOS and SOS must be one of the
following four:
/l0i
   Integer or Real
   String
   Record
   Set
/b0 Integer values will be converted to real if necessary.
/b0 The comparison is signed where integer values are concerned.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack contains less than two items.
/b0 /t3 2. /t4 The types of TOS and SOS are incompatible.
/a indent=3
/b/t1 Example:     /t3  %if S < "123" %then X = 0
/l0i
Stack S;  String "123";  Compare-Values
BGE 13
Stack X;  Byte 0;  Assign-Values
Label 13

/b/v12
/b/t1 Instruction: /t3 Complement
/b/t1 Effect:      /t3 TOS is replaced by the ones-complement of TOS.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack is empty
                /b0/t3 2. /t4 TOS is not an integer value.
/a indent=3
/b/t1 Example:     /t3 P = \Q
/l0i
Stack P;  Stack Q;  Complement;  Assign-Value

/b/v18
/b/t1 Instruction: /t3 Concat
/b/t1 Effect:      /t3 TOS and SOS are removed from the stack and the
concatenation of their values, SOS.TOS, is stacked.

/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack contains less than two values.
                /b0/t3 2. /t4 TOS and SOS are not both string values.
/a indent=3
/b/t1 Example:     /t3 S = T.U.V
/l0i
Stack S
Stack T;  Stack U;  Concat
Stack V;  Concat
Assign-Value

/b/v12
/b/t1 Instruction: /t3 Control <n>
/b/t1 Effect:      /t3 The value <n> is considered to be of the form p<<14+q.
The value q is to be used by the p'th pass of the compiler in an
 implementation-specific manner.
/A indent=4
/b/t1 Errors:      /t3 None
/a indent=3

/n
/b/t1 Instruction: /t3 Define <tag> [id] <a> <b> <c>
/b/t1 Effect:      /t3 A new tag value is created.
/a indent=5
/b/t3  <tag>/t5 defines the tag index which will be used to select the
value.
/b/t3 [id] /t5 specifies the actual identifier associated with the
described object. It is a sequence of zero or more characters terminated
by a comma. This identifier will be used for external linkage if
necessary unless overridden by an Alias.
[id] will also be used for run-time diagnostic information.
/b/t3 <a> /t5 A two-byte value: <a> = T<<4+F where:
/l0i
T = 0 : void
    1 : integer            {qualified by <b>}
    2 : real               {qualified by <b>}
    3 : string             {maximum length <b>}
    4 : record             {format <b>}
    5 : boolean
    6 : set
    7 : 8-bit-enumerated   {format <b>}
    8 : 16-bit-enumerated  {format <b>}
    9 : pointer
   10 : char
11-15 : undefined          {error}

F = 0 : void
    1 : simple                  {byte}
    2 : indirect                {bytename}
    3 : general label
    4 : recordformat
    5 : undefined               {error}
    6 : switch
    7 : routine
    8 : function
    9 : map
   10 : predicate
   11 : array                   {array}
   12 : array indirect          {arrayname}
   13 : indirect array          {namearray}
   14 : indirect array indirect {namearrayname}
   15 : undefined               {error}

/n
/t3 <b> /t5 If T is INTEGER <b> takes the following meanings:
/l0i

<b> =       1, full range
            2, range 0..255
            3, range -32768..32767
/b
If T is REAL <b> takes the following meanings:
/l0i

<b> =       1, normal precision
            4, double precision
/b If T is STRING <b> gives the maximum length of the string.
/b0 If T is RECORD <b> gives the tag of the corresponding recordformat.
/b0 If T is enumerated <b> gives the tag of the dummy format used to
identify the enumerated value identifiers.
/b/t3 <c> /t5 is a two-byte value: U<<5+I<<4+S<<3+X where:
/l0i
   U is 1 check the object for unassigned
        0 otherwise
   I is 1 if the object is an indirect object,
        0 otherwise
   S is 1 if this is a %spec,
        0 otherwise
   X  = 0 :: automatic (stack) allocation
        1 :: %own
        2 :: %constant
        3 :: %external
        4 :: %system
        5 :: %dynamic
        6 :: %primitive
        7 :: %permanent

/b0 An indirect object (I=1) differs from F=2 in that F=2 implies that
the actual object created will be a pointer and will be dereferenced
whenever used unless explicit action is taken (e.g. use of Assign-Reference).
If I=1 a pointer will be created (usually as an integer) and will be
treated as an integer (or address) with no automatic dereferencing taking
place.
/a indent=3
/b/t1 Notes:       /t3 The tag values within a block should be dense and
preferably consecutive. All tag values within a block must have values greater
than the maximum tag value yet defined within the enclosing block.
/b0 Tag definitions remain valid until the end of the enclosing block.
/b0 The tag values used within a recordformat definition must all be zero;
the fields of a record are selected by their position in the format,
numbered starting from one.

/v26
/l0
                       x = illegal combination

                                         1 1 1 1 1
                 F = 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4
                    *-----------------------------*
            T = 0   | |x| | |x|x| | |x| | |x| |x| |
                    |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-|
                1   |x| | |x|x|x|x|x| | |x| | | | |
                    |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-|
                2   |x| | |x|x|x|x|x| | |x| | | | |
                    |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-|
                3   |x| | |x|x|x|x|x| | |x| | | | |
                    |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-|
                4   |x| | |x| |x|x|x| | |x| | | | |
                    |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-|
                5   |x| | |x|x|x|x|x| | |x| | | | |
                    |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-|
                6   |x| | |x|x|x|x|x| | |x| | | | |
                    |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-|
                7   |x| | |x|x|x|x|x| | |x| | | | |
                    |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-|
                8   |x| | |x|x|x|x|x| | |x| | | | |
                    |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-|
                9   |x| | |x|x|x|x|x| | |x| | | | |
                    |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-|
               10   |x| | |x|x|x|x|x| | |x| | | | |
                    *-----------------------------*
/b/v12
/b/t1 Instruction: /t3 Define-Range <tag>
/b/t1 Effect:      /t3 The given tag is defined to be the integer range
defined by lower-bound and upper-bound.
/A indent=4
/b/t1 Error:       /t3 1. /t4 The two bounds have not been defined.
/a indent=3
/b/t1 Example:     /t3 Var x:1..10;  ...... x := i;
/l0i

Byte 1;  Byte 10;  Bounds
Define-Range 99.......
Define x........
Stack x;  Stack i;  Test-Range 99;  Assign-Value

/b/v12
/b/t1 Instruction: /t3 Diagnose <n>
/b/t1 Effect:      /t3 The value <n> is considered to be of the form p<<14+q.
The value q is to be used by the p'th pass of the compiler in an
 implementation-specific manner.
/A indent=4
/b/t1 Errors:      /t3 None
/a indent=3

/b/v30
/b/t1 Instruction: /t3 Dimension <n><d>
/b/t1 Effect:      /t3 <d> pairs of integer values on the stack
are used to define the bounds of the last <n> arrays to have been defined.
Code is generated, if necessary, to
allocate the arrays  and the definitions are adjusted to reference the
appropriate storage.
/b/t1 Notes:       /t3 The pairs of values are stacked in order of
the declaration, that is, first dimension first.
/b0 In each pair of values the lower bound is stacked before the upper bound.
/b0 The last <n> tags must have had consecutive index values.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack contains less than 2*<d> items.
                /b0/t3 2. /t4 The last <n> definitions were not all arrays.
/a indent=3
/b/t1 Example:     /t3 %integerarray A, B, C(1:2, Low:4)
/l0i
Define A......
Define B......
Define C......
Byte 1;     Byte 2
Stack Low;  Byte 4
Dimension 3 2

/b/v12
/b/t1 Instruction: /t3 Div
/b/t1 Effect:      /t3 TOS and SOS are removed from the stack and the real
quotient, SOS/ /// TOS, is stacked. Integer values will be converted into
floating-point before the division is attempted.

/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack contains less than two items.
/b0 /t3 2. /t4 TOS (or SOS) is neither integer nor real type.
/a indent=3
/b/t1 Example:     /t3  A = B // C
/l0i
Stack A;  Stack B;  Stack C;  Div;  Assign-Value

/b/v12
/b/t1 Instruction: /t3 Duplicate
/b/t1 Effect:      /t3 A copy of TOS is pushed onto the stack.
/b/t1 Note:        /t3 After this instruction TOS and SOS are identical.
/A indent=4
/b/t1 Error:       /t3 1. /t4 The stack is empty.
/a indent=3
/b/t1 Example:     /t3 int A[10],x;
/l0i
A[x]++;

Stack A;  Stack x;  Adjust
Duplicate
Byte 1;  Add;  Assign-Value

/b/v12
/b/t1 Instruction: /t3 End
/b/t1 Effect:      /t3 This instruction marks the end of a block.
All tags defined within the block are deleted (made undefined) and become
available for re-use. If the block is a %routine this instruction also
implies a 'Return' instruction.
/A indent=4
/b/t1 Error:       /t3 1. /t4 The stack is not empty.
/a indent=3

/b/v12
/b/t1 Instruction: /t3 End-Of-File
/b/t1 Effect:      /t3 The compilation is to be abandoned with an error message.
/b/t1 Notes:       /t3 This instruction is required at the end of an I-code
file even though in correct programs it will never be executed. It is
there to provide a check on the operation of the code-generator and to
permit the code-generator to use a one-character look-ahead.
/A indent=4
/b/t1 Errors:      /t3 None
/a indent=3

/b/v12
/b/t1 Instruction: /t3 Eval
/b/t1 Effect:      /t3 The value described by TOS is protected against
being altered as the side-effect of alterations to any variables which
make up that value.
/b/t1 Notes:       /t3 Commonly this instruction loads the value of TOS
into a machine register.
/a indent=4
/b/t1 Error:       /t3 1. /t4 The stack is empty.
/a indent=3
/b/t1 Example:     /t3 a = b + c++
/l0i
Stack a;  Stack b;  Stack c;  Add
Eval
Stack c;  Stack c;  Byte 1;  Add;  Assign-Value
Assign-Value

/b/v12
/b/t1 Instruction: /t3 Eval-Addr
/b/t1 Effect:      /t3 The address of the object described by TOS is
protected against alteration.
/b/t1 Notes:       /t3 Commonly this instruction loads the address of the
object refered to be TOS into a machine register.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack is empty.
                /b0/t3 2. /t4 TOS is not a reference.
/a indent=3
/b/t1 Example:     /t3 int *p;
/l0i
*p++ = 10;

Stack p;  Eval-Addr;  Stack p;  Duplicate
Byte 1;  Adjust;  Assign-Value
Byte 10;  Assign-Value

/b/v12
/b/t1 Instruction: /t3 Finish
/b/t1 Effect:      /t3 This instruction marks the end of a list of tag
definitions corresponding to either a parameter list or a recordformat
definition. List flag is cleared and the tag list is processed in any
ways necessary.
If the tag list is associated with a procedure spec or a recordformat
this instruction also marks the 'end' of the associated 'block'.
/A indent=4
/b/t1 Note:        /t3 The list of definitions may be empty.
/b/t1 Errors:      /t3 1. /t4 List flag is clear.
                /b0/t3 2. /t4 There has been an unmatched Alt-Start.
/a indent=3
/b/t1 Examples:    /t3 %routine Test(%integer j,k)
/l0i
Define Test.........
Start
   Define j......
   Define k......
Finish

%recordformat F(%integer P %or %real R)

Define F..........
Start
   Define P......
   Next-Alt
   Define R......
Finish
/b/v12
/b/t1 Instruction: /t3 Float
/b/t1 Effect:      /t3 The value described by TOS is converted into
a real value if necessary.
/b/t1 Notes:       /t3 If TOS is already a real this operation is a no-op.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack is empty.
                /b0/t3 2. /t4 TOS is neither integer nor real.
/a indent=3

/n
/b/t1 Instruction: /t3 For <label>
/b/t1 Effect:      /t3 This instruction marks the start of a FOR statement.
<label> is the label to be jumped to on %repeat and <label+1> is
the label to be jumped to on an %exit.
/b/t1 Notes:       /t3 The corresponding %repeat will be the next
instruction of the form: Backward/ <label>.
/b0 <label+1> should only be defined explicitly if the loop contains an explicit
%exit instruction.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack contains less than four items.
                /b0/t3 2. /t4 The top three items on the stack are not
integer values.
                /b0/t3 3. /t4 The fourth item on the stack is not a
reference to an integer variable.
                /b0/t3 4. /t4 No Backward <label> instruction occurs
before the end of the current block.
/a indent=3
/b/t1 Example:     /t3 A(j) = 0 %for J = 1, 1, N
/l0i
Stack J;  Byte 1;  Byte 1;  Stack N
For 40
Stack A;  Stack J;  Access
Byte 0;  Assign-Value
Backward 40

/b/v12
/b/t1 Instruction: /t3 Forward <label>
/b/t1 Effect:      /t3 Control is transferred forward unconditionally to <label>
/A indent=4
/b/t1 Error:       /t3 1. /t4 <label> does not get defined by a Label
instruction before the end of the current block.
/a indent=3
/b/t1 Example:     /t3 %if X=0 %then Y=1 %else Y=2
/l0i
Stack X;  Byte 0;  Compare-Values;  Bne 20
Stack Y;  Byte 1;  Assign-Value
Forward 21
Label 20
Stack Y;  Byte 2;  Assign-Value
Label 21

/b/v12
/b/t1 Instruction: /t3 Include <string>
/b/t1 Effect:      /t3 This instruction marks the start (or end) of
the code generated from source contained in an include file. If <string>
is null it marks the end of an include file.
/A indent=4
/b/t1 Errors:      /t3 None
/a indent=3

/b/v12
/b/t1 Instruction: /t3 Index
/b/t1 Effect:      /t3 TOS is used as the next index into SOS. TOS is removed
from the stack leaving SOS as the new TOS.
/b/t1 Notes:       /t3 This instruction is used to process the first N-1
dimensions of an N dimensional array. See Access for the final dimension.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack contains less than two items.
                /b0/t3 2. /t4 TOS is not an intger value.
                /b0/t3 3. /t4 SOS is not an array descriptor.
/a indent=3

/b/v12
/b/t1 Instruction: /t3 Init <n>
/b/t1 Effect:      /t3 <n> copies of the init-value are added to the list
of values associated with the init-variable. The init-value is either
the default value (unassigned) if the stack is empty, the value of TOS
(possibly converted to real) if TOS is a constant, or the address of TOS
if TOS is a variable.
The init-variable is the last static object to have been defined using Define.
/A indent=4
/b/t1 Error:       /t3 1. /t4 TOS, if it exists, is not of the same type
as the init-variable.
/a indent=3
/b/t1 Examples:    /t3 %ownintegerarray A(1:5) = 1(3), 4, 99
/l0i
Byte 1;  Byte 5;  Bounds
Define A.......
Byte 1;  Init 3
Byte 4;  Init 1
Byte 99; Init 1

%owninteger P = -1
Byte 1;  Negate
Define P......
Init 1

/b/v12
/b/t1 Instruction: /t3 Init-Type <n>
/b/t1 Effect:      /t3 The type of the init-variable (see Init) is considered
to be <n> for the purposes of subsequent 'Init' instructions. <n> encodes
the type as in the type field of 'Define'.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 <n> does not correspond to a valid type.
/a indent=3

/b/v12
/b/t1 Instruction: /t3 Int
/b/t1 Effect:      /t3 TOS is replaced by Int(TOS), that is, the nearest
integer to the value of TOS. The type of the new TOS is integer.
/b/t1 Notes:       /t3 See the IMP Library Definition for a discussion of
the details of the INT function.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack is empty.
                /b0/t3 2. /t4 TOS is neither integer nor real.
/a indent=3
/b/t1 Example:     /t3 I = Int(R+0.3)
/l0i
Stack I;  Stack R;  Real <0.3>;  Add
Int
Assign-Value

/b/v12
/b/t1 Instruction: /t3 Intpt
/b/t1 Effect:      /t3 TOS is replaced by Intpt(TOS), that is, the integer
part of TOS. The type of the new TOS is integer.
/b/t1 Notes:       /t3 See the IMP Library Definition for a discussion of
the details of the INTPT function.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack is empty.
                /b0/t3 2. /t4 TOS is neither integer nor real value.
/a indent=3
/b/t1 Example:     /t3 I = Intpt(R-S)
/l0i
Stack I;  Stack R;  Stack S;  Sub
Intpt
Assign-Value

/b/v12
/b/t1 Instruction: /t3 Integer <integer>
/b/t1 Effect:      /t3 The integer value <integer> is pushed into the stack
and becomes the new TOS.
/b/t1 Notes:       /t3 The instruction 'Byte' is an abbreviation for this
instruction when the value is in the range 0..255.
/A indent=4
/b/t1 Errors:      /t3 None
/a indent=3
/b/t1 Example:     /t3 X = 2500
/l0i
Stack X;  Integer 2500;  Assign-value

/b/v12
/b/t1 Instruction: /t3 Integer-Power
/b/t1 Effect:      /t3 TOS and SOS are removed from the stack
and the value of SOS raised to the integer power of the value of TOS,
SOS^^TOS, is stacked.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack contains less than two items.
                /b0/t3 2. /t4 TOS and SOS are not integer values.
/a indent=3
/b/t1 Example:     /t3 J = K^^3
/l0i
Stack J;  Stack K;  Byte 3;  Integer-Power
Assign-Value

/b/v12
/b/t1 Instruction: /t3 Jump <tag>
/b/t1 Effect:      /t3 Control is transferred unconditionally to the general
label <tag>.
/b/t1 Notes:       /t3 This control transfer may pass over block boundaries.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 <tag> is defined but is not a general label.
                /b0/t3 2. /t4 <tag> is undefined but does not become defined
in a suitable block before the end of the program. A suitable block
is one which is either the same block as the Jump instruction or is a
block which properly contains that instruction.
/a indent=3
/b/t1 Example:     /t3/c+6   X = 1
/l0i
Pos:  Y = Y+1
      ->Pos %if Y < 0

   Stack X;  Byte 1;  Assign-Value
   Locate Pos
   Stack Y;  Stack Y;  Byte 1;  Add;  Assign-Value
   Stack Y;  Byte 0;  Compare-Values
   Bge 18
   Jump Pos
   Label 18

/b/v14
/b/t1 Instruction: /t3 Label <label>
/b/t1 Effect:      /t3 The simple label <label> is defined to be here.
If outstanding references to the label exist they are satisfied and the
label ceases to be defined. This ensures that all references to this label are
in the same direction.
/A indent=4
/b/t1 Errors:      /t3 None
/a indent=3
/b/t1 Example:     /t3 S = "**" %if S = ""
/l0i
Stack S;  String "**";  Compare-Values
Bne 26
Stack S;  String "";  Assign-Value
Label 26

/b/v12
/b/t1 Instruction: /t3 Left
/b/t1 Effect:      /t3 TOS and SOS are removed from the stack
and the value of SOS logically shifted left by the value of TOS,
SOS/ <</ TOS, is stacked.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack contains less than two items.
/b0 /t3 2. /t4 TOS and SOS are not both integer values.
/b0 /t3 3. /t4 The value of TOS is negative or greater than or equal to the
number of bits in an integer.
/a indent=3
/b/t1 Example:     /t3  A = B << C
/l0i
Stack A;  Stack B;  Stack C;  Left;  Assign-Value

/b/v12
/b/t1 Instruction: /t3 Line <n>
/b/t1 Effect:      /t3 The current position is associated with the start of
the code for source line <n>.
/b/t1 Error:       /t3 1. /t4 The stack is not empty.
/b/t1 Example:     /t3
/l0i
  X = 1
  Y = 3;  Z = 4

   Line 5;  Stack X;  Byte 1;  Assign-Value
   Line 6;  Stack Y;  Byte 3;  Assign-Value
   Line 6;  Stack Z;  Byte 4;  Assign-Value

/b/v12
/b/t1 Instruction: /t3 Localise
/b/t1 Effect:      /t3 The area pointed at be <a> is copied into the local
stack frame and <a> is updated to point at the new area.
/b/t1 Notes:       /t3 If the first byte of the new area is at X, <a>
is updated to the address X-<c>.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack contains less than three items.
                /b0/t3 2. /t4 <a> is not a reference.
                /b0/t3 3. /t4 <b> and <c> are not integer values.
/a indent=3

/b/v12
/b/t1 Instruction: /t3 Locate <tag>
/b/t1 Effect:      /t3 The tag is defined as a general label if necessary and
made to reference the current position in the program.

/b/t1 Error:       /t3 1. /t4 <tag> is already defined.
/b/t1 Example:     /t3/c+6   X = 1
/l0i
Pos:  Y = Y+1
      ->Pos %if Y < 0

   Stack X;  Byte 1;  Assign-Value
   Locate Pos
   Stack Y;  Stack Y;  Byte 1;  Add;  Assign-Value
   Stack Y;  Byte 0;  Compare-Values
   Bge 18
   Jump Pos
   Label 18

/b/v12
/b/t1 Instruction: /t3 Mod
/b/t1 Effect:      /t3 TOS and SOS are removed from the stack and are replaced
by the value 'SOS/ MOD/ TOS' where MOD is as defined in section 6.7.2.2
of the Pascal standard BS 6192:1982.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack contains less than two items.
                /b0/t3 2. /t4 TOS and SOS are not both integer values.
/a indent=3
/b/t1 Example:     /t3 m := p MOD q;
/l0i
Stack m;  Stack p;  Stack q;  Mod
Assign-Value

/b/v12
/b/t1 Instruction: /t3 Mul
/b/t1 Effect:      /t3 TOS and SOS are removed from the stack
and the value of SOS multiplied by the value of TOS,
SOS/ */ TOS, is stacked.
Integer values will be converted into floating-point if one operand
is integer and the other is real.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack contains less than two items.
/b0/t3 2. /t4 TOS (or SOS) is neither integer nor real type.
/a indent=3
/b/t1 Example:     /t3  A = B * C
/l0i
Stack A;  Stack B;  Stack C;  Mul;  Assign-Value

/b/v12
/b/t1 Instruction: /t3 Negate
/b/t1 Effect:      /t3 The value in TOS is negated and left as TOS.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack is empty.
                /b0/t3 2. /t4 TOS is not an integer or real value.
/a indent=3
/b/t1 Example:     /t3 A = -B
/l0i
Stack A;  Stack B
Negate;  Assign-Value

/b/v12
/b/t1 Instruction: /t3 Next-Alt
/b/t1 Effect:      /t3 This instruction marks the end of one alternative and the
start of the next
/A indent=4
/b/t1 Error:       /t3 1. /t4 List flag is not set.

/a indent=3
/b/t1 Example:
/l0i
%recordformat F(%integer X, (%integer Y %or %real Z))
Define F.......
Start
   Define X.....
   Alt-Start
      Define Y.....
   Next-Alt
      Define Z.....
   Alt-Finish
Finish

/b/v12
/b/t1 Instruction: /t3 Null-Set
/b/t1 Effect:      /t3 A descriptor of a null set is stacked.
/A indent=4
/b/t1 Errors:      /t3 None
/a indent=3
/b/t1 Example:     /t3 SetA := [];
/l0i
Stack SetA;  Null-Set;  Assign-Value

/b/v20
/b/t1 Instruction: /t3 On <n> <label>
/b/t1 Effect:      /t3 This instruction marks the start of an %on %event
block.  <n> is a sixteen-bit set of flags where each trapped event
is represented by a 1-bit, with the least-significant bit corresponding to
event 0 and the most-significant bit event 15.
/b/t1 Notes:       /t3
<label> is the simple label which marks the end of the event block.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 <n> does not have any bits set.
                /b0/t3 2. /t4 <label> is not defined before the end of the
current block.
/a indent=3
/b/t1 Example:     /t3 %on 9 %start;  %return;  %finish
/l0i
On 512 17
Return
Label 17

/b/v12
/b/t1 Instruction: /t3 Or
/b/t1 Effect:      /t3 TOS and SOS are removed from the stack
and the value of SOS logically ORed with the value of TOS,
SOS/ !/ TOS, is stacked.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack contains less than two items.
/b0/t3 2. /t4 TOS and SOS are not both integer values.
/a indent=3
/b/t1 Example:     /t3  A = B ! C
/l0i
Stack A;  Stack B;  Stack C;  Or;  Assign-Value

/b/v12
/b/t1 Instruction: /t3 Pop
/b/t1 Effect:      /t3 TOS is removed from the stack.
/A indent=4
/b/t1 Errors:      /t3 The stack is empty.
/a indent=3
/b/t1 Example:     /t3 X := Y := 0
/l0i
Stack X;  Duplicate
Stack Y;  Duplicate
Byte 0;  Assign-Value;  Assign-Value
Pop

/b/v12
/b/t1 Instruction: /t3 Quotient
/b/t1 Effect:      /t3 TOS and SOS are removed from the stack
and the value of SOS integer-divided by the value of TOS,
SOS/ ///// TOS, is stacked.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack contains less than two items.
                /b0/t3 2. /t4 TOS (or SOS) is not an integer.
/a indent=3
/b/t1 Example:     /t3  A = B //// C
/l0i
Stack A;  Stack B;  Stack C;  Quotient;  Assign-Value

/b/v12
/b/t1 Instruction: /t3 Real <real>
/b/t1 Effect:      /t3 The real constant <real> is pushed onto the stack.
/A indent=4
/b/t1 Errors:      /t3 None
/a indent=3
/b/t1 Example:     /t3 Z = -1.23
/l0i
Stack Z;  Real <1.23>;  Negate
Assign-Value

/b/v12
/b/t1 Instruction: /t3 Real-Power
/b/t1 Effect:      /t3 TOS and SOS are removed from the stack
and the value of SOS raised to the integer power TOS,
SOS^TOS, is stacked. The type of this value is real.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack contains less than two items.
                /b0/t3 2. /t4 SOS is neither an integer nor a real value.
                /b0/t3 3. /t4 TOS is not an integer value.
/a indent=3
/b/t1 Example:     /t3 R = 12^X
/l0i
Stack R;  Byte 12;  Stack X;  Real-Power
Assign-Value

/b/v12
/b/t1 Instruction: /t3 Reference <n>
/b/t1 Effect:      /t3 TOS is replaced by a reference to an object of
type <n> at the address given by the original TOS.
the value of <n> is encoded in the same way as the type information, <a>,
in the Define instruction.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack is empty.
                /b0/t3 2. /t4 TOS is not an integer (address) value.
/a indent=3
/b/t1 Example:     /t3 P = Integer(Q)
/l0i
Stack P;  Stack Q;  Reference 1
Assign-Value

/b/v12
/b/t1 Instruction: /t3 Remainder
/b/t1 Effect:      /t3 TOS and SOS are removed from the stack and are replaced
by the value REM(SOS, TOS). The exact definition of REM is given in the
IMP Library Definition.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack contains less than two items.
                /b0/t3 2. /t4 TOS and SOS are not both integer values.
/a indent=3
/b/t1 Example:     /t3 Digit = Rem(N, 10)
/l0i
Stack Digit;  Stack N;  Byte 10;  Remainder
Assign-Value

/b/v12
/b/t1 Instruction: /t3 Return
/b/t1 Effect:      /t3 A return sequence is generated to return control
from the current block.
/A indent=4
/b/t1 Errors:      /t3 None
/a indent=3
/b/t1 Example:     /t3 %return %if X # 0
/l0i
Stack X;  Byte 0;  Compare-Values
Beq 19
Return
Label 19

/b/v12
/b/t1 Instruction: /t3 Return-False
/b/t1 Effect:      /t3 The current block returns false.
/b/t1 Notes:       /t3 This is usually accomplished by setting the true
condition-code appropriately.
/A indent=4
/b/t1 Error:       /t3 1. /t4 The current block is not a predicate.
/a indent=3
/b/t1 Example:     /t3 %false %if Flag = 0
/l0i
Stack Flag;  Byte 0;  Compare-values
Bne 42
Return-False
Label 42

/b/v12
/b/t1 Instruction: /t3 Return-Reference
/b/t1 Effect:      /t3 The address of the object referenced by TOS is
returned as the result of the map.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The current block is not a map.
                /b0/t3 2. /t4 The stack is empty.
                /b0/t3 3. /t4 TOS is not a reference to a data object.
/a indent=3
/b/t1 Example:     /t3 %result == X
/l0i
Stack X;  Return-Reference

/b/v12
/b/t1 Instruction: /t3 Return-True
/b/t1 Effect:      /t3 The current block returns true.
/b/t1 Notes:       /t3 This is usually accomplished by setting the true
condition-code appropriately.
/A indent=4
/b/t1 Error:       /t3 1. /t4 The current block is not a predicate.
/a indent=3
/b/t1 Example:     /t3 %true %if Flag = 0
/l0i
Stack Flag;  Byte 0;  Compare-values
Bne 42
Return-True
Label 42

/b/v12
/b/t1 Instruction: /t3 Return-Value
/b/t1 Effect:      /t3 TOS is removed from the stack and returned as the
result of the function defined by the current block.
/b/t1 Notes:       /t3 Integer values will be converted to real if necessary.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack is empty.
                /b0/t3 2. /t4 The current block is not a function.
/a indent=3
/b/t1 Example:     /t3 %result = "Hello"
/l0i
String "Hello"
Return-Value

/b/v12
/b/t1 Instruction: /t3 Right
/b/t1 Effect:      /t3 TOS and SOS are removed from the stack
and the value of SOS logically left shifted by the value of TOS,
SOS/ >>/ TOS, is stacked.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack contains less than two items.
/b0 /t3 2. /t4 TOS and SOS are not both integer values.
/b0 /t3 3. /t4 The value of TOS is negative or greater then or equal to the
number of bits in an integer.
/a indent=3
/b/t1 Example:     /t3  A = B >> C
/l0i
Stack A;  Stack B;  Stack C;  Right;  Assign-Value

/b/v12
/b/t1 Instruction: /t3 Round
/b/t1 Effect:      /t3 TOS is replaced by the value ROUND(TOS) where ROUND is as
defined in section 6.6.6.3 of the Pascal standard BS 6192:1982, with the
extension that ROUND returns the value of its parameter if that value is already
an integer.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack is empty.
                /b0/t3 2. /t4 TOS is neither integer nor real.
/a indent=3
/b/t1 Example:     /t3 i := Round(r+0.1);
/l0i
Stack i;  Stack r;  Real <0.1>; Add
Round;  Assign-Value

/b/v12
/b/t1 Instruction: /t3 Select <n>
/b/t1 Effect:      /t3 TOS is replaced by the <n>'th item in the format
of TOS.
Fields within records are numbered from 1; alternative markers have
no effect on the numbering.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack is empty
                /b0/t3 2. /t4 TOS is not a record.
                /b0/t3 3. /t4 The format of TOS does not contain 
at least <n> items.
/a indent=3
/b/t1 Example:     /t3 %recordformat F(%integer P %or %record (F)%name Q)
/l0i
%record (F) R
R/_Q/_P = 0

Stack R;  Select 2;  Select 1
Byte 0;  Assign-Value

/b/v12
/b/t1 Instruction: /t3 Set-Format <tag>
/b/t1 Effect:      /t3 TOS is converted to be a record of format <tag>.
This never involves any instructions being executed in the object program.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 <tag> is not a recordformat.
                /b0/t3 2. /t4 The stack is empty.
                /b0/t3 3. /t4 TOS is not a reference to a variable.
/a indent=3

/b/v12
/b/t1 Instruction: /t3 Signal <n>
/b/t1 Effect:      /t3 The event <n>,SOS,TOS is signalled.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack contains less than two items.
                /b0/t3 2. /t4 TOS and SOS are not both integer values.
/a indent=3
/b/t1 Example:     /t3 %signal 1,2,3
/l0i
Byte 3;  Byte 2;  Signal 1

/b/v16
/b/t1 Instruction: /t3 Size-Of
/b/t1 Effect:      /t3 TOS is replaced by the integer value giving the
number of bytes in the object referenced by the original TOS.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack is empty.
                /b0/t3 2. /t4 TOS is not a reference to a data object.
/a indent=3
/b/t1 Example:     /t3 P = Sizeof(R)
/l0i
Stack P;  Stack R;  Size-Of;  Assign-Value

/b/v12
/b/t1 Instruction: /t3 Stack <tag>
/b/t1 Effect:      /t3 The tag with index value <tag> is pushed onto the stack.
/A indent=4
/b/t1 Error:       /t3 1. /t4 <tag> has not been defined.
/a indent=3
/b/t1 Example:     /t3 A = B
/l0i
Stack A;  Stack B;  Assign-Value

/b/v14
/b/t1 Instruction: /t3 Stack-Condition <b>
/b/t1 Effect:      /t3 The values of SOS and TOS are compared as in 
Compare-Values but instead of the condition-code being set, TOS and SOS
are replaced by the constant 1 (true) or 0 (false) depending on whether
the condition specified by <b> is true or false.
The values of <b> are the encodings of the instructions:
/l0i
BEQ, BNE, BLT, BLE, BGT, BGE, BT, BF
/A indent=4
/b/t1 Notes:       /t3 The comparison is signed when integers are concerned.
/b/t1 Errors:      /t3 1. /t4 The stack contains less than two items.
                /b0/t3 2. /t4 TOS and SOS cannot be compared.
                /b0/t3 3. /t4 <b> is not a valid condition.
/a indent=3
/b/t1 Example:     /t3 B := (X=Y);
/l0i
Stack B
Stack X;  Stack Y;  Stack-Condition BEQ
Assign-Value

/b/v18
/b/t1 Instruction: /t3 Stack-In
/b/t1 Effect:      /t3 TOS and SOS are removed from the stack and
are replaced by an integer value which is 1 (true) if SOS is IN the set TOS
or 0 (false) if SOS is not IN the set TOS.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack contains less than two items.
                /b0/t3 2. /t4 TOS is not a set or SOS is not an integer.
/a indent=3
/b/t1 Example:     /t3 B := (x IN s);
/l0i
Stack B
Stack x;  Stack s;  Stack-In
Assign-Value

/b/v12
/b/t1 Instruction: /t3 Stack-Unsigned-Condition <b>
/b/t1 Effect:      /t3 The values of SOS and TOS are compared as in 
Compare-Unsigned-Values but instead of the condition-code being set TOS and SOS
are replaced by the constant 1 (true) or 0 (false) depending on whether
the condition specified by <b> is true or false.
The values of <b> are the encodings of the instructions:
/l0i
BEQ, BNE, BLT, BLE, BGT, BGE, BT, BF
/b/t1 Notes:       /t3 The comparison is unsigned when integers are concerned.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack contains less than two items.
                /b0/t3 2. /t4 TOS and SOS cannot be compared.
                /b0/t3 3. /t4 <b> is not a valid condition.
/a indent=3
/b/t1 Example:     /t3 B := (Ux < Uy);
/l0i
Stack B
Stack Ux;  Stack Uy;  Stack-Unsigned-Condition BLT
Assign-Value

/b/v22
/b/t1 Instruction: /t3 Start
/b/t1 Effect:      /t3 This instruction marks the start of a list of
tags defining the parameters to a procedure or the components of
a record.
List flag is set.
/b/t1 Notes:       /t3 This instruction must always follow the definition of a
procedure or recordformat tag.
There must be a matching 'Finish' before the end of the block.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 List flag is set.
                /b0/t3 2. /t4 The last instruction was not a 'Define'
which introduced a procedure or recordformat.
/a indent=3
/b/t1 Example:     /t3 %routine Newline; ....; %end
/l0i
Define Newline.........
Start
Finish
......
End

/b/v12
/b/t1 Instruction: /t3 String <string>
/b/t1 Effect:      /t3 The string constant <string> is pushed onto the stack.
/A indent=4
/b/t1 Errors:      /t3 None
/a indent=3
/b/t1 Example:     /t3 S = "Hello"
/l0i
Stack S;  String "Hello";  Assign-Value

/b/v12
/b/t1 Instruction: /t3 Sub
/b/t1 Effect:      /t3 TOS and SOS are removed from the stack
and the value of SOS minus the value of TOS,
SOS/ -/ TOS, is stacked.
Integer values will be converted into floating-point if one operand
is integer and the other is real.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack contains less than two items.
/b0/t3 2. /t4 TOS (or SOS) is neither integer nor real type.
/a indent=3
/b/t1 Example:     /t3  A = B - C
/l0i
Stack A;  Stack B;  Stack C;  Sub;  Assign-Value

/b/v12
/b/t1 Instruction: /t3 Switch-Jump <tag>
/b/t1 Effect:      /t3 TOS is used to index into the switch vector and
control is then transferred to the selected label.
TOS is removed from the stack.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack is empty.
                /b0/t3 2. /t4 <tag> is not a switch.
/a indent=3
/b/t1 Example:     /t3 ->Sw(J)
/l0i
Stack J;  Switch-Jump Sw

/b/v12
/b/t1 Instruction: /t3 Switch-Label <tag>
/b/t1 Effect:      /t3 The label selected from the switch vector is defined
the be here. TOS is removed from the stack.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack is empty.
                /b0/t3 2. /t4 <tag> is not a switch in the current block.
                /b0/t3 3. /t4 TOS is not an integer value within the bounds
of <tag>.
/a indent=3
/b/t1 Example:     /t3 Sw(12):
/l0i
Byte 12;  Switch-Label Sw

/b/v12
/b/t1 Instruction: /t3 Swop
/b/t1 Effect:      /t3 The top two items on the stack are reversed. That is,
TOS becomes the new SOS, and SOS becomes the new TOS.
/A indent=4
/b/t1 Error:       /t3 1. /t4 The stack contains less than two items.
/a indent=3
/b/t1 Example:     /t3 X = Y
/l0i
Stack Y;  Stack X;  Swop;  Assign-Value

/b/v12
/b/t1 Instruction: /t3 Test-Boolean
/b/t1 Effect:      /t3 The condition-code is set to 'false' or
'true' depending on whether TOS is 0 (false) or 1 (true).
TOS is removed from the stack.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack is empty.
                /b0/t3 2. /t4 TOS is not a boolean value.
/a indent=3
/b/t1 Example:     /t3 If B Then DoIt;
/l0i
Stack B;  Test-Boolean;  BF 43
Stack DoIt;  Call
Label 43

/b/v16
/b/t1 Instruction: /t3 Test-In
defined by TOS. /b/t1 Effect:      /t3 The value of SOS is tested for inclusion
within the set TOS.
The condition-code is set 'true' or 'false' accordingly. Both TOS and
SOS are removed from the stack.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack contains less than two items.
                /b0/t3 2. /t4 SOS is not an integer value.
                /b0/t3 3. /t4 TOS is not a set value.
/a indent=3
/b/t1 Example:     /t3 If NOT x IN s Then x := 0;
/l0i
Stack x;  Stack s;  Test-In
Bt 31
Stack x;  Byte 0;  Assign-Value
Label 31

/b/v12
/b/t1 Instruction: /t3 Test-Nil
/b/t1 Effect:      /t3 A check is performed to ensure that TOS is not NIL.
An event is signalled if it is, or if TOS points to a heap item which
has been returned to the heap (disposed).
/b/t1 Notes:       /t3 This test can also perform an unassigned variable check.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack is empty.
                /b0/t3 2. /t4 TOS is not a pointer variable.
/a indent=3
/b/t1 Example:     /t3 P^ := 0;
/l0i
Stack P;  Test-Nil
Reference <1>
Byte 0;  Assign-Value

/b/v22
/b/t1 Instruction: /t3 Test-Range <tag>
/b/t1 Effect:      /t3 The value of TOS is checked to be within the range
defined by the tag. If the value is not in the range an event is signalled.
/b/t1 Notes:       /t3 The event is signalled at run-time.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack is empty.
                /b0/t3 2. /t4 TOS is not an integer value.
                /b0/t3 3. /t4 <tag> does not define a range.
/a indent=3
/b/t1 Example:     /t3 Byteval := Bigval;
/l0i
Stack Byteval
Stack Bigval;  Test-Range Byterange
Assign-Value

/b/v12
/b/t1 Instruction: /t3 Trunc
/b/t1 Effect:      /t3 TOS is replaced by the value TRUNC(TOS) where TRUNC is as
defined in section 6.6.6.3 of the Pascal standard BS 6192:1982, with the
extension that Trunc returns the value of its parameter if that value is already
an integer.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack is empty.
                /b0/t3 2. /t4 TOS is neither integer nor real.
/a indent=3
/b/t1 Example:     /t3 i := Trunc(r+0.1);
/l0i
Stack i;  Stack r;  Real <0.1>; Add
Trunc;  Assign-Value

/b/v12
/b/t1 Instruction: /t3 Variable-Call
/b/t1 Effect:      /t3 The procedure described by TOS is called. This differs
from 'Call' in that the procedure may have a variable number of parameters.
/b/t1 Notes:       /t3 This instruction is used to call 'C' procedures
and its definition is as wooly as the definition of that language.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack is empty.
                /b0/t3 2. /t4 TOS is not a procedure descriptor.
/a indent=3
/b/t1 Example:     /t3 try(1);  try(1,2);
/l0i
Stack try;  Byte 1;  Assign-Parameter
Variable-Call
Stack try;  Byte 1;  Assign-Parameter
Byte 2;  Assign-Parameter
Variable-Call

/b/v12
/b/t1 Instruction: /t3 Xor
/b/t1 Effect:      /t3 TOS and SOS are removed from the stack
and the value of SOS exclusively ORed with the value of TOS,
SOS/ !!/ TOS, is stacked.
/A indent=4
/b/t1 Errors:      /t3 1. /t4 The stack contains less than two items.
                /b0/t3 2. /t4 TOS and SOS are not both integer values.
/a indent=3
/b/t1 Example:     /t3  A = B !! C
/l0i
Stack A;  Stack B;  Stack C;  Xor;  Assign-Value

/n
/Lm
Appendix 2  Instructions which set the condition-code
/l0i


Call {predicate}
Compare-Values         Compare-Unsigned-Values
Compare-References     Compare-Repeated-Values
Test-Boolean           Test-In
/b6/v12
/Lm
Appendix 3  Instructions which test the condition-code
/l0i


BEQ       BF
BGE       BGT
BLE       BLT
BNE       BT
/e
