Do/Else/Fin; Do/Fin Directives - Xerox 530 Language And Operations Reference Manual

Table of Contents

Advertisement

DO/ELSE/FIN
Iteration Control
The DO directive defines the beginning of an iteration
loop; ELSE and FIN define the end of an iteration loop.
These directives have the form
Command
Argument
1-_
Label
. " . - - . -
I---~be!l
DO
exp
ELSE
--
. - -
FIN
whete
label
is any valid symbol.
Use of a label is op-
tional. When present, it is initiallyassigned the
value 0 and incremented by 1 each successive
time through the loop. Note that label is not de-
fined as the current value of the execution loca-
tion counter. However, it may be the target label
of a GOTO search.
exp
is an absolute, evaluatable (no forward, lit-
eral, or external references) expression that rep-
resents the count of how many times the DO-loop
is to be assembled.
A label field entry is ignored for ELSE or FIN unless it is
the target label in a GOTO search. Argument field entries
are always ignored in an ELSE or FIN directive.
Figure 3 illustrates the logical flow of a DO/ELSE/FIN loop.
The assembler processes each DO-loop as follows:
1.
Establ ishes an internal counter and defines its value
as zero.
2.
Ifa label ispresentontheDOline, setsitsvalueto zero.
3.
Eva luates the express ion that represents the count.
4.
If the count is less than or equal to zero, discontinues
assemblyuntilan ELSEorFINdirectiveis encountered.
a.
If an ELSE directive is
encounter,-~d,
assembles
statements following it unti
I
a fIN directive is
encountered.
b.
If a FIN directive is encountered, terminates
control of the DO-loop and resumes assembly at
the next stfltement.
5.
If
the count is greater than zero, processes the D
0-
loop as follows:
a.
Increments the current value of the label by
1.
b.
Assembles all lines encountered up to the first
ELSE or FIN directive.
c.
Repeats steps 5a and 5b unti
I
the loop has been pro-
cessed the number oftimes specifi ed by the count.
d.
Terminates control of the DO-loop and resumas
assembly at the statement following the FIN.
If the expression in the DO directive is not evaluatable
(i.
e.,
if
it contai ns an external or forward reference), Ex-
tended Symbol sets the label (if present) to thevalue zero,
30
Extended Symbol Di recti ves
produces an error noti fi cati on, and processes the DO
directive as if the expression has been evaluated as zero.
The label for the DO directive may be redefined within the
loop, but the assembl er wi
\I
increment the val ue of the
label at the beginning of each iteration. For example,
K
K
DO
LDA
SET
FIN
5
K-l
K+1
The statements between DOand FIN will be assembled five
times. The argument of the LDAwi
II
be 0,
2, 4, 6,
and
8.
Any symbols in "exp
II
that are redefinable may also be
changed within the loop without affecting the number of
times the loop is executed.
For example:
HOURS
RATE
HOURS
SET
SET
DO
SET
FIN
8
5
HOURS*RATE
2
The loop wi II be assembled 40 times.
Since the label on a DO statement is redefinable, it may
be reused on subsequent DOs following the FIN associated
with the labeled DO.
DO-loops may be nested; i.e., a DO-loop may exist
within another DO-loop. An inner DO-loop must be con-
tained comp letely w,ithin an outer DO-loop. There may be
a maximum of
30
nested DO-loops.
A
DO-loop must be completed on the same program level in
which it
0:
iginates; that is, if a DO directive occurs in
the main program, the associated FIN for that di rective
must also be in the main program.
If
a DO directive occurs
within a procedure definition, the associated FIN for that
directive must also be within the definition.
When the assembler encounters a DO-loop, the statements
in
the loop arc listed even if they are not processed (for
example, the C'.lse of DO 0).
Example
15.
DO/FIN Directives
A
DO
ADD
FIN
5
NUM+A
This is the equivalent of
ADD
NUM+1
ADD
NUM+2
ADD
NUM+3
ADD
NUM+4
ADD
NUM+5

Advertisement

Table of Contents
loading

This manual is also suitable for:

Sigma 3Sigma 2

Table of Contents