lines
Q14
through
Q19
calculate
B2
-
4AC.
The
following
lines
test
for a
negative
value
(which
would
produce
an
imaginary
root).
Q20x<0?
Is result negative?
Q21GT0I
If yes, branches to different routine.
Q22SQRT
If positive, takes square root.
Flags
A
flag
is an
indicator
of
status.
It is
either
set
(true)
or
clear
(false).
Testing
a
flag
is another
conditional
test that
follows
the 'Do if
true*
rule:
program
execution
proceeds
directly
if the
tested
flag
is
set,
and
it skips one line if the flag is
clear.
Meanings off Flags. The HP-32S has seven flags, numbered 0
through 6. Allof
these
flags
can be set,
cleared,
and
tested
by a pro
gram
instruction.
You
can
also
setand
clear
flags
from
the
keyboard.*
•
Flags
0,1, 2, 3, and 4 haveno
preassigned
meanings.
Thatis,
their
status will mean whatever you define it to mean in a given pro
gram. (See the example
below.)
•
Flag
5, whenset,willinterrupt a
program
whenan
overflow
occurs
within
the
program,
displaying
OVERFLOW
and
A.*
If
flag
5 is
clear,
a program with an overflow is not interrupted, though
OVERFLOW
is displayedbriefly when the programeventually stops.
•
Flag
6 is
automatically
set by the
calculator
any time an
overflow
occurs
(although you can alsoset
flag
6
yourself).
It has no
effect,
but
can
be
tested.
*
The
only
other
action
that
clears
flags
isthe
three-key
memory
clearing
operation
described
in appendix B.
t An
overflow
occurs
when
a
result
exceeds
the
largest
number
that
the
calculator
can
handle.
The
largest
possible
number
is
substituted
for
the
overflow
result.
6:
Programming
Techniques
97