HP -11C Owner's Handbook Manual page 59

Hide thumbs Also See for HP-11C:
Table of Contents

Advertisement

114
Section 7; Program Decisions and Control
Conditional Branch
Control of Program Loop
If test true,
looping continues.
If test false,
looping terminates.
Keystrokes
Display
(S)(P7R)
000-
Sets HP-11C to Program
mode.
f)CLEAR [PRGM
000-
#)(CBL)(C
001-42,21,13
0
002-
0 } Clears R, of any
STO}1
003-
44
1J unwanted data from
previous calculations.
004-42,21,
0 Begins loop.
006-
1
006-44,40,
1
Integer counter/
increment.
~~
w
~~ yee
ae
~~
wee
YS
Ye
VY
wee
YY
YY
WY
Section 7: Program Decisions and Control
15
Keystrokes
Display
(RCL}1
oo7-
45
1
(f)(PSE]
008-
4231
Displays next integer.
Qy
oo9-
11°
Square root of integer.
(f)(PSE]
010-
4231
Displays square root.
(ajftst
011-
4336
Recalls copy of integer
from LAST X register.
1
012-
1
Compares last integer to
0
013-
O highest integer allowed by
iS
014-
4220
the program.
GTO}O
015-
22
O Conditional branch. If
last integer is less than 10,
go to (LBL]0 and resume...
9 \(Cly
016-
4335
...otherwise, avoid another
{¢ ][RTN)
017-
4332
loop, clear displayed X-
register and halt program.
(S)[PZR)
Sets HP-11C to Run mode.
To run the program press [f](€]. The calculator will display a table
of integers from 1 to 10 with their corresponding square roots.
When 0.0000 is displayed, program execution is completed.
How It Works: When you press
[f] (C], the calculator searches
through
program
memory
until it encounters
the [f] [LBL] (C
instruction, It executes that label and each subsequent instruction
in sequential order through line 014, the [x >1] conditional test. If
the result of the [x>1] conditional test is true—that is, the last
integer used was less than 10—the following [GTO] 0 instruction is
executed, the calculator returns to the (LBL) 0 instruction at line 004,
and execution resumes as a new iteration of the loop. However, if
the result of the
[x>)}
conditional test is false, meaning the last
integer used was 10, the
[GTO] 0 instruction is bypassed and the
loop is terminated.
For
an
additional
discusssion
of looping
and
loop control
techniques, refer to page 214, Looping, in part III of this handbook.
Problem.
Write
a
program
to
calculate
and
display
sales
commissions. For sales of less than $100 the commission should be
10% of the sale. For sales of $100 or more the commission should be
15%. Use a conditional branch in your solution.

Advertisement

Table of Contents
loading

Table of Contents