HP -32S Owner's Manual page 80

Rpn scientific calculator
Table of Contents

Advertisement

Press IR/SI (run/stop) or a to resume the program. The value you
keyed in then writes over the contents of the X-register and is stored
in the given variable. If you have not changed the displayed value,
then that value is retained in the X-register.
The area-of-a-circle program with an INPUT instruction looks like
this:
R01
LBL
R
fl02
INPUT R
R03
x*
R04 tf
R05
x
R06
RTN
Using INPUT in a Program.
1. Decide which data values you will need, and assign them names.
(In the area-of-a-circle example, the onlyinput needed is the ra
dius, which we can assign to R.)
2. In the beginningof the program, insert an INPUT instruction for
each variable whose value you will need. Later in the program,
when you write the part of the calculation that needs a given
value, insert a IRCL Ivariable instruction to bring that value back
into the stack.*
For Example: See the Time Value of Money* program on page 222
in part 4.The first thing that routine T does is collect all thenecessary
input for the variables N, I, B, P, and F (lines T02 through T06).
• Since the INPUT instruction also leaves the value you just entered in the X-register, you
don't have torecall the variable ata later time—you could INPUT it and use it when you
need it. You might be able to save some memory space this way. However, in a long pro
gram it is simpler to justinput all yourdata up front, and then recall individual variables as
you need them.
Remember also mat the user of the program can do calculations while the program is
stopped, waiting for input. This can alter the contents of the stack, which might affect the
nextcalculation to be doneby the program. Thus the program should not assume that the
X-, Y-, and Z-registers'contents will be the same before and after the INPUT instruction. If
you collect all the data in the beginning and then recall them when neededfor calculation,
then this prevents the stack's contents from being altered just before a calculation.
78
5: Simple Programming

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents