Campbell 21X Instrukcja Operatora Strona 43

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 191
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 42
lf Then/Else may be
nested
to form
logical
AND
pr
OR branching.
Figure
3.8-2
illustrates
anlAND
construction.
lf
conditions A
and
B
are
trde, the
instructions
included
between
lF B
and thelfirst
End Instruction
will
be
executed. lf either of the
conditions is false,
execution will
jump
to
the corresponding End
Instruction,
qkipping
the
instructions
between.
rF
A
(BB-92
WITH
COMMAND J0)
SECTION 3.
INSTRUCTION SET BASICS
encountered, execution branches
to the END
Instruction
95
which closes the
case test
(see
lnstruction
93).
3.8.2
END,
INSTRUCTION
95
END,
Instruction
95,
is required to
mark
the end
of:
1. A Subroutine
(starts
with lnstruction
87)
2. A
Loop
(starts
with Instruction
85)
3. An |F... THEN DO sequence
(starts
with
one
of
lnstructions 89-93
with the THEN DO
command 30).
4. A case
statement
(starts
with Instruction
93)
The lF instructions
89-93
require
Instruction
95
only
when
the
THEN DO command
30
is used.
lf one of
the above
instructions
is used
without
the
corresponding END, the 21X
will
display
error
22
when compiling the
program.
Error 21
is
displayed if END
is
used
without being
preceded
by one
of these
instructions
(Section
3.10).
An END
instruction
is
always
paired
with the
most recent instruction that requires an END and
does
not
already
have
one.
A
way
of visualizing
this is to
draw
lines
between
each
instruction
requiring
an END and the
END
paired
with it
(as
in Figure
3.8-2).
The lines must
not
cross.
To
debug logic
or
find a missing or
extra
END error,
list the
program
and draw the
lines.
Subroutines
can be
called
from other
subroutines; they cannot be
embedded within
other subroutines.
A
subroutine
must
end before
another subroutine begins
(Enor
20).
Any loops
or lF...THEN DO
sequences
started within a
subroutine must end before the
subroutine.
3.8.3
NESTING
A branching or loop
instruction which
occurs
before a
previous
branch or
loop has
been
closed
with the
END instruction
is nested. The
maximum nesting level
is 9 deep. Error 30 is
displayed when attempting
to compile a
program
which
is nested too
deep.
The Loop Instruction, 87, counts
as
1
level.
lnstructions 86, 88, 89, 91,
and 92
each
count as
one levelwhen used
with the THEN DO
command
30.
Use of Else,
lnstruction
94,
also
counts
as
one nesting
leveleach time it
is
used.
For example, the
AND
construction
above
is
--
rF B
(88-e2
!V|TH
cor/MAND
Jo)
I
I
,
INSTRUCTIONS
TO
.i:
EXECUTE
IF
A
AND
B
ARE BOTH
TRUE
END B
(e5)
END
A
(s5)
FIGURE 3f8-2.
Logical AND Construction
Figure
3.8-3]illustrates
the
instruction
sequence
that will resuft
in
subroutine
X
being executed
if
either
A
or B
is true.
lF A
(88-92
with
command 30)
Calllsubroutine
X
(86,
command=X)
ELSE
(e4)
lF B
(88-92
with command 3O)
Callsubroutine
X
(86,
command=X)
ENq B
(e5)
ENq
A
(es)
FIGURE
$.8-3.
Logical
OR Construction
A logical
Ofl
can also
be constructed by setting
a
flag
if a colnparison
is true.
(The
flag is
cleared
before
making the comparisons.)
After
all comparis0ns have
been made, execute the
desired instructions
if
the
flag
is
set.
The
Begin
Case
Instruction 93
and
lf Case
Instruction 88 allow
a series of
tests
on the
value
in an input ldcation.
The case
test is
started
with
Instruction 90 which specifies
the location to test.
A series
of
Instructions
83 are then used to
compare thQ
value
in
the
location with fixed
values. Wh0n the value
in the
input
location
is
less
than
th4
fixed value specified in
Instruction
83 the
comrhand
in
that
Instruction 83
is
executed; when the
next lnstruction 83
is
3-5
Przeglądanie stron 42
1 2 ... 38 39 40 41 42 43 44 45 46 47 48 ... 190 191

Komentarze do niniejszej Instrukcji

Brak uwag