|
Section 11: Branching and Looping171
|
|
|
X>Y?
|
|
tests to see if the value in the X-register is greater than the value
in the Y-register.
|
|
|
X>0?
|
|
tests to see if the value in the X-register is greater than zero.
|
|
|
X<Y?
|
|
tests to see if the value in the X-register is less than the value
in the Y-register.
|
|
|
X<0?
|
|
tests to see if the value in the X-register is less than zero.
|
|
|
X≤Y?
|
|
tests to see if the value in the X-register is less than or equal
to the value in the Y-register. Display execution is
X<=Y?
|
|
|
X<=0?
|
|
tests to see if the value in the X-register is less than or equal to zero.
|
|
|
X≠Y?
|
|
tests to see if the value in the X-register is not equal
to the value in the Y-register.
|
|
|
X≠0?
|
|
tests to see if the value in the X-register is not equal
to zero.
|
|
|
Two of these conditionals, X=Y? and
X≠Y? can be used to compare ALPHA
strings as well as numbers. All of the other conditionals compare only
numbers. If two strings are ‘‘equal’’
( X=Y? ), then they are exactly equal
in length and have identical characters.
|
|
Each conditional essentially asks a question when it is encountered as an
instruction in a program. If the answer is YES, program execution
continues sequentially downward with the next instruction in program
memory. If te answer is NO, the calculator branches around the
next instruction.
|
|
(When you execute any of these conditionals manually from the keyboard, the
HP-41C displays the answer to the conditional question. If the
condition is true the display shows
YES. If the conditional is
false, the display shows NO.)
|
|
In other words, the calculator will do the next line if the
test is true. This is the ‘‘DO IF TRUE’’ rule.
|
|
For example:
|
|
|
|
The line immediately following the conditional test can contain any
instruction. The most commonly used instruction will be a
GTO instruction. This will branch program
execution to another section of program memory. If the conditional
test is true. For example:
|