Program Control3
3 – 6
The loop stack stores the last instruction addresses and termination
conditions of temporarily dormant loops. Up to four levels can be stored.
The only extra cycle associated with the nesting of DO UNTIL loops is the
execution of the DO UNTIL instruction itself, since the pushing and
popping of all stacks associated with the looping hardware is automatic.
When using the counter expired (CE) status as the termination condition
for the loop, an additional cycle is required for the initial loading of the
counter. Table 3.1 shows the termination conditions that can be used with
DO UNTIL.
Syntax Status Condition True If:
EQ Equal Zero AZ = 1
NE Not Equal Zero AZ = 0
LT Less Than Zero AN .XOR. AV = 1
GE Greater Than or Equal Zero AN .XOR. AV = 0
LE Less Than or Equal Zero (AN .XOR. AV) .OR. AZ = 1
GT Greater Than Zero (AN .XOR. AV) .OR. AZ = 0
AC ALU Carry AC = 1
NOT AC Not ALU Carry AC = 0
AV ALU Overflow AV = 1
NOT AV Not ALU Overflow AV = 0
MV MAC Overflow MV = 1
NOT MV Not MAC Overflow MV = 0
NEG X Input Sign Negative AS = 1
POS X Input Sign Positive AS = 0
CE Counter Expired
FOREVER Always
Table 3.1 DO UNTIL Termination Condition Logic
When a DO UNTIL instruction is executed, the 14-bit address of the last
instruction and a 4-bit termination condition (both contained in the DO
UNTIL instruction) are pushed onto the 18-bit by 4-word loop stack.
Simultaneously, the PC incrementer output is pushed onto the PC stack.
Since the DO UNTIL instruction is located just before the first instruction
of the loop, the PC stack then contains the first loop instruction address,
and the loop stack contains the last loop instruction address and
termination condition. The non-empty state of the loop stack activates the
loop comparator which compares the address on top of the loop stack
with the address of the next instruction. When these two addresses are
equal, the loop comparator notifies the next address source selector that
the last instruction in the loop will be executed on the next cycle.