Loop Control Using [Isg] - HP -11C Owner's Handbook Manual

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

Advertisement

132
Saction 9; The index Register
Loop Control Using
Example:
Here is a program that illustrates how [ISG] works. It
contains a loop that pauses to display the current value in R; and
uses [ISG] to control the number of passes through the loop and the
value of a squared number. The program generates a table of
squares of even numbers from 2 through 50.
Keystrokes
Display
(a\[P7R}
000-
Program mode.
(A)CLEAR (PRGM]
000-
f)(CBL){A}
001-42,21,11
Program label.
2
002-
2 } Current counter value
(nnnnn).
003-
48
004-
0
005-
5 | Counter test value (xxx).
006-
ce)
iey
: } Increment value (yy).
009-
4425
Store loopcontrol value in
Ry.
010-42,21,
1
Begin the loop.
011-
4525
Recall the number in Rj.
012-
4344
Take the integer portion.
013-
4231
Pause todisplay the
integer.
gf")
014-
4311
Square the number.
f)(PSE
015-
4231
Display the square of the
number.
(Afisc
016-
42
6
Increment R; by 2 and
check to see that the
counter is not greater than
the final number (50). If
the counter is greater than
the final number, skip the
next line in the program.
GTO]1
017—
22
1
Loopback
to label 1.
9 ){RTN
018-
4332
Halts the program.
9 ){P/R
Run mode.
~~
ew
a
wee
ee
YY
Section 9: The index Register
133
Now run the program by pressing [f)[A].
Keystrokes
Display
A)
2.0000
When the calculator
4.0000
begins executing, it first
pauses to display the
4.0000
number to be squared,
16.0000
then pauses to display the
'
square of the number.
:
When the loop counter
50.0000
increments beyond 50, the
2,500.0000
program halts.
Here is what happens when you run the above program.
1,
Under label [A], the number 2.05002 is stored in the I-register
as the loop control value:
annnn
XXX
|
yw
(0000)2
050
02
Current Counter
Test
Increment
Value
Value
Value
2.
Under label 1, the following sequence occurs:
After 2 and 4 (the square of 2) are displayed, the current
counter value in Ry, 00002 (nnnnn), is incremented by the
increment value 02 (yy). The new number in R; is 4.05002,
which is interpreted by your calculator as:
nnnnan
XXX
yy
(0000)4
050
02
Current Counter
Test
Increment
Value
Value
Value
The new counter value is then compared to the test value 050
(xxx). As the counter value has not exceeded the test value,
the calculator proceeds to the next line, [GTO] 1, and the
process is repeated with the new number.

Advertisement

Table of Contents
loading

Table of Contents