Refining the CCU
Last Edit November 2, 1996; May 1, 1999; July 7, 2001
Am2910 Instructions
Test End Loop (LOOP)
A third repeat loop construct is LOOP, which behaves similarly
to RFCT except that the test which determines whether or not
the loop is repeated is some selected condition other than <COUNTER>
= 0. On CC' = HIGH, LOOP behaves similarly to CONT, with the
added operation of POPping the stack. On CC' = LOW, the loop
start address is referenced from the top of the stack. The register/counter
is unaffected. The PL' enable is ACTIVE.
A loop using the instruction LOOP requires that a PUSH instruction
immediately preceed the first microinstruction in the loop,
the one whose address is to be pushed onto the stack (see Figure
4-22a). Sample code for severla loops is shown in Figure 4-22b.
Figure 4-22a Test end of loop (LOOP, D, 1101). Must preceed
first statement in the loop.
The LOOP microinstruction is the programming equivalent of
a DO UNTIL or DO WHILE programming construct.
Figure 4-22b Sample Code for several loops
COND JUMP PL and POP [stack] (CJPP)
The way to conditionally exit a loop is to execute CJPP. This
instruction may also be used to conditionally exit a subroutine
where a return to the calling location is to be aborted.
CJPP is a conditional jump using the pipeline register to provide
the branch address (see Figure 4-23
).
The difference between CJP and CJPP is that the latter POPs
the stack when CC' = LOW. When CC' = HIGH, CJPP becomes CONT.
The PL' enable is ACTIVE.
Figure 4-23 Conditional jump pipeline and POP (CJPP, B,
1011)
CJPP is used to conditionally exit loops formed using PUSH
and RFCT, TWB or LOOP. It is not needed for loops formed with
RPCT which do not invlove the stack.
Three-Way Branch (TWB)
There can be instances where the construct DO X TIMES WHILE
Ci = FALSE is necessary. The microinstruction
equivalent of this is TWB, a dual-test branch or loop microinstruction
(see Figure 4-24a).
TWB will loop, referring to the top of the stack for the start
adress, if CC' = HIGH and <COUNTER> ≠ 0.
The stack wil be POPped on the branch if CC' = HIGH and
<COUNTER> = 0. TWB will behave similarly to CONT
if CC' = LOW with the addition of POPping the stack, regardless
of the counter value. If <COUNTER> ≠ 0, the counter
will be decremented. In all cases, the PL' enable is active. Sample code for a three-way branch is shown in Figure 4-24b.
Figure 4-24a Three-way branch (TWB, F, 1111)
Figure 4-24b Sample Code for a Three-way branch
An example of the type of problem for which TWB is useful is
given in Figure 4-26. This is a key match memory search,
where the counter defines the length of the block of memory
being searched and the condition tested is a match on the selected
key.
Figure 4-26 Programming a memory search on key for a search
on n+1 locations
|