74 Section 6: Branching and Looping
Keystrokes Display
35.355
N
12
.
¦(or any key)
35.355
Halts program execution.
Conditional Branching
Often there are situations when it is desirable for a program to be able to branch
to different lines in program memory, depending on certain conditions. For
example, a program used to calculate sales commissions might need to branch
to different program lines depending on the commission rate for the particular
sales level. Also, conditional branching can be used to end the execution of a
loop such as that in the preceding example. A conditional instruction can shift
the program out of a loop either after a specified number of loop executions, or
when a certain value within the loop has been reached.
The HP-10C provides two conditional test instructions that are used in programs
for conditional branching:
• £ tests whether the number in the X-register (represented by the x in
the key symbol) is less than or equal to the number in the Y-register
(represented by the y in the key symbol).
• ~ tests whether the number in the X-register is equal to zero.
The possible results of executing either of these instructions are:
• If the condition tested for is true when the instruction is executed,
program execution continues sequentially with the instruction in the next
line of program memory.
• If the condition tested for is false when the instruction is executed,
program execution skips the instruction in the next line of program
memory and continues with the instruction in the following line.
These rules can be summarized as “DO if TRUE.”