User guide

166 CHAPTER 9. THE DESIGN OF CINTCODE
9.2.8 Flow of Co ntrol and Relations
The following instruction s are used in the compilation of conditional and unconditional
jumps, and relational expressions . The symbol rel denotes EQ, NE, LS, GR, LE or GE
indicating the relation being tested.
J Ln PC := Ln
J$ Ln PC := Ln
Jrel Ln IF B rel A DO PC := Ln
Jrel$ Ln IF B rel A DO PC := Ln
Jrel0 Ln IF A rel 0 DO PC := Ln
Jrel0$ Ln IF A rel 0 DO PC := Ln
The destinat i ons of these jump instructions are comput ed using the rel ative addressing
mechanism described in Section 9.1.3. Notice than when the comparison is with zero,
A holds the left operand of the relation.
GOTO PC := A
This instruction is only used in the compilation of the GOTO command.
FHOP A := 0; PC := PC+1
The FHOP instruction is only used in the compilation of relational expressions in non
conditional contexts as in the compilation. The assignment: x := y < z is typically
compiled as follows:
LP4 Load y
LP5 Load z
JLS 2 Jump to the LM1 instr u ct i on if y<z
FHOP A := FALSE; and hop over the LM1 instruct i on
LM1 A := TRUE
SP3 Store in x
9.2.9 Switch Instructions
The instructions are used to impleme nt switches are SWL and SWB, switching on the
value held in A. They both assume that all case constants are in the range 0 to 65535,
with the compiler taking appropriate action when this constraint is not satisfied.
SWL filler n dlab L
0
. . . L
n1
This instruc ti on is used when there are sufficie nt case constants all within a small
enough range. It performs the jump by selecting an ele me nt from a vector of 16 bit
resolving half words. The quantities n, dlab, and L
0
to L
n1
are 16 bit half words,
aligned on 16 bit b oundar i e s by the optional fil l e r byte. If A is in the range 0 to n 1 it
uses the appropriate res ol v i ng half word L
A
, otherwise it uses the resolving half word