
                       FOR EXPERIENCED HP CALCULATOR USERS


If you are an experienced HP-41 user then you should be very familiar with
the RPNDEMO environment.  The purpose of this section is to explain how
RPNDEMO differs from the HP-41.

First keep in mind that the purpose of RPNDEMO is to demonstrate how a
general RPN computer works, not how the HP-41 works.  RPNDEMO is not intended
to be an HP-41 simulator although the instruction set is patterned after the
HP-41 language.

   The major differences with the HP-41 are as follows:

1. RPNDEMO has 100 memory registers designated R00-R99.  There is no SIZE
   instruction.

2. RPNDEMO will hold up to 999 program lines and no more.  The editor
   automatically numbers the lines from 001-999.

3. RPNDEMO has 100 numeric labels numbered 00-99.  RPNDEMO does not use
   alpha labels for branching purposes but you can use alpha labels to name
   your program or to write comments in your programs.  Label search does
   not wrap around and corresponds more to assembly language conventions.
   Numeric labels should be unique since the program performs label searches
   from the top of your program down until it finds the first matching label.
   A second same label will never be found.

4. RPNDEMO has 10 general purpose user flags designated F00-F09.  There are
   no systems flags.

5. The DSE and ISG instructions operate with integer values only.  There is
   no unpacking of an eeeii number.  The decrement/increment value is always
   1.

6. RPNDEMO has 10 levels of subroutine calls and the screen will actually
   show the line number return addresses float up and down on the subroutine
   return stack as a program executes so you can monitor program flow.

7. RPNDEMO does not employ an alpha register as on the HP-41.  RPNDEMO is a
   numerically oriented computer that always shows you the contents of its
   working registers and flags and current memory bank and subroutine stack.


                                                                       page 67



8. RPNDEMO does not use FIX, SCI, or ENG display instructions.  It does of
   course always show you all of the significant digits in a number.  RPNDEMO
   will automatically switch to a scientific format when numbers become too
   small or too large to be displayed in a regular fixed point format.  You
   have no control over display formats but you will always see every
   significant digit.

9. RPNDEMO includes all of the common arithmetic functions but excludes some
   of the HP-41's more exotic or miscellaneous functions.  Most notably there
   are no statistics registers.  Only those functions shown in the HELP
   screen or language syntax list are available.  The MOD function has been
   replaced by QR ala the PPC ROM.

10. RPNDEMO does not include functions peculiar to the HP-41 environment such
    as ADV, ASN, CAT, COPY, PACK, etc.  Note that there is a BEEP instruction
    but no TONE or PSE.  Also, a VIEW instruction would be redundant.

11. RPNDEMO works with only 1 program at a time so there is no END
    instruction.  The author considers this to be a very desirable extension
    that will be added to any future version.

12. RPNDEMO does not use "synthetic instructions" that have been discovered
    and used to form language elements not intended to be part of the
    original HP-41 instruction set.

13. The conditional comparison operators of RPNDEMO are an extension of those
    found on the HP-41.  You can make any comparison directly between any two
    registers.


A complete summary of all of the functions available in RPNDEMO appears on
the HELP screens.  If you can't find a function on the HELP screens then it
wasn't implemented.  The syntax of each command should closely match that of
regular HP-41 commands as they would be printed on the HP-82143A Peripheral
Printer in its MANUAL mode.  See also the syntax summary lists on page 35 and
page 73.


                                                                       page 68


                 RDEMO1 - A First Sample Program

001 LBL PROGRAM          This first demonstration program
002 PI                   consists of elementary instructions.
003 STO 25
004 X<>Y                 The first instructions enter the
005 X<> T                number PI and store this number in
006 X<> IND 25           register R25.  Then a few stack
007 5                    manipulations are executed.
008 LBL 00
009 STO IND X            Lines 8-12 form a loop which stores
010 SF IND X             the numbers 5,4,3,2,1 in their
011 DSE X                corresponding registers and also set
012 GTO 00               the flags with the same numbers.
013 XEQ 01
014 RTN                  The program ends at line 14 but line
015 LBL 01               13 demonstrates a subroutine which
016 XEQ 02               contains nested subroutine calls and
017 RTN                  as these subroutines are executed
018 LBL 02               you should note the build-up and
019 XEQ 03               break-down of the subroutine return
020 RTN                  stack.
021 LBL 03
022 XEQ 04
023 RTN
024 LBL 04
025 XEQ 05
026 RTN
027 LBL 05
028 RDN
029 X<>Y
030 BEEP
031 RTN




                                                                       page 69


                 RDEMO2 - Prime Number Generator


001 LBL PRIMES       The PRIMES program calculates and stores
002 3                odd prime numbers.  Each time a new prime
003 STO 01           is found the program BEEPS to announce its
004 STO 02           discovery.  Odd primes greater than 3 are
005 LBL 01           stored in registers R03 and up.  The
006 2                program will run continuously until you
007 ST+ 02           press any key to interrupt its execution.
008 RCL 02
009 3
010 XEQ 02           The LBL 01 loop, lines 5-18, will add 2 to
011 X=0?             the odd number in R02 (lines 6-7) to get
012 GTO 01           the next potential odd prime.  Then
013 RCL Z            starting with 3 (line 9) the program will
014 BEEP             try to find the next prime factor of the
015 STO IND 01       number in R02 (line 10).  The LBL 02 sub-
016 1                routine returns 0 if the number in R02 is
017 ST+ 01           not prime and in that case (lines 11-12)
018 GTO 01           the program will branch back to LBL 01.
019 LBL 02
020 RCL Y            If the LBL 02 subroutine returns a nonzero
021 SQRT             number in X then the number in R02 was
022 LASTX            prime and it will be stored in the
023 X<> Z            register pointed to by R01 (line 15).  The
024 LBL 03           pointer in R01 is updated to make room for
025 X>Y?             a new prime (lines 16-17) and a branch
026 RTN              back to LBL 01 (line 18) starts the whole
027 RCL Z            process all over again.
028 X<>Y
029 QR               Lines 19-38 search for the next prime
030 X=0?             factor of an integer.  The square root is
031 RTN              calculated in line 21 and this value is
032 RCL T            used to test when to quit the process,
033 RCL T            since if a number is prime it won't have
034 LASTX            any factors larger than its own square
035 2                root.  So at line 25 a test is made to
036 +                determine whether the square root has been
037 GTO 03           exceeded.  If it has the subroutine ends
038 RTN              there.  If not, the next odd divisor is
                     tried as a factor.  Line 30 is a test for
                     even division.  If the division is even
                     then the routine ends by returning a zero
                     value and otherwise 2 is added (lines
                     35-36) to the last odd divisor and a
                     branch is made back to LBL 03 to try the
                     next odd divisor.

R01 : pointer to register where the next prime will be stored
R02 : odd numbers (potential primes)
R03 : 5
R04 : 7
R05 : 11
R06 : 13
R07 : 17

                                                                       page 70


             RDEMO3 - Selection Without Replacement

001 LBL SWR    The SWR program, Selection Without Replacement,
002 STO 03     is an example of a program that can be used to
003 STO 04     draw numbers out of a hat.  Chosen numbers
004 5          cannot be drawn a second time.  The input to
005 STO 01     the program is a positive number representing
006 +          the number of numbers to be selected from,
007 1          usually a number in the range 5-10.
008 -
009 STO 02     Before running the program you should store a
010 0.65432    small positive integer, say in the range 5-10,
011 STO 00     in the X-register in Manual Mode.
012 5
013 1          When the SWR program is run it will first store
014 LBL 01     your number in R03 and next it will store the
015 STO IND Y  number 5 in R01 and then it will store the
016 1          number of the last used register in R02.  Then
017 ST+ Z      starting in R05 the program will begin loading
018 +          the counting numbers 1,2,3,. . .  etc. up to
019 DSE 04     and including the number you keyed in.
020 GTO 01
021 RCL 03     Once all the counting numbers are stored the
022 STO 04     program will BEEP when it selects each number
023 LBL 02     which will appear in the X-register.  You might
024 R03=0?     write down on a piece of paper each number
025 RTN        selected so you can convince yourself that all
026 XEQ 03     numbers are eventually selected and that no
027 RCL 03     number gets selected twice.
028 *
029 RCL 01     Program lines 14-20 load the registers with the
030 ST+ Y      counting numbers before the selection process
031 DSE 03     starts.
032 NOP
033 RCL 03     Program lines 23-39 are the selection process.
034 +
035 RCL IND X  Program lines 40-48 generate a random number in
036 X<> IND Z  the range 0-1 which eventually gets re-scaled to
037 STO IND Y  determine the random selection number register.
038 BEEP
039 GTO 02     R00 : random numbers seeds (decimal numbers 0-1)
040 LBL 03     R01 : beginning register of selection block
041 RCL 00     R02 : ending register of selection block
042 9821       R03 : the number of items
043 *          R04 : a DSE scratch counter
044 0.211327   R05 : 1
045 +          R06 : 2
046 FRC        R07 : 3
047 STO 00     R08 : 4
048 RTN


                                                                       page 71


     RDEMO4 - Polynomial Evaluation (Synthetic Substitution)


001 LBL POLY      This program performs synthetic substitution
002 LBL 00        (commonly misnamed as synthetic division)
003 ENTER^        which is used to evaluate any polynomial up
004 ENTER^        to degree 9.
005 ENTER^
006 RCL 09        The data registers R00-R09 hold the
007 *             coefficients of the polynomial and these
008 RCL 08        numbers must be stored manually.  For example
009 +             the coefficient on the 4th power of X would
010 *             be stored in R04.  Note that the constant
011 RCL 07        term is stored in R00.  Store 0's in the
012 +             corresponding registers of any missing powers
013 *             of X.
014 RCL 06
015 +             For example, assume the polynomial to be
016 *             evaluated is:
017 RCL 05
018 +                P(X) = 6X^5 - 7X^4 + 4X^3 + 5X^2 - 8X + 3
019 *
020 RCL 04        Store 0's in R06, R07, R08, and R09 because
021 +             the highest power of X is the 5th power.
022 *             Then manually store 6 in R05, store -7 in R04
023 RCL 03        store 4 in R03, store 5 in R02, store -8 in
024 +             R01, and store 3 in R00.
025 *
026 RCL 02        To calculate P(3) key 3 in the X-register and
027 +             run the program which will leave P(3) in the
028 *             X-register when it stops.  For the above
029 RCL 01        polynomial P(3)=1023 and P(-5) = -23457.
030 +
031 *             The program calculates P(X) by first filling
032 RCL 00        the stack with X and then performs a series
033 +             of multiplications and additions, bringing
034 STOP          into play all of the coefficients of P(X) as
035 GTO 00        needed.  Automatic duplication from the
036 RTN           T-register makes multiple copies of X
                  available as needed.  P(X) is the final
                  result left in the X-register.



                                                                       page 72


                     COMMAND/FUNCTION INDEX

The following lists the ASCII order for the beginning syntax of valid
language statements.  The number in parentheses following each partial
syntax is a page reference in this manual for the complete technical details
of the corresponding command.  This table is provided so you can quickly look
up unknown commands in the reference section.  Only the beginning part of the
syntax is given.  See also the syntax summary list on page 35.




                   RPN LANGUAGE SYNTAX TABLE


*  (36)                            L compare  (51)
+  (36)                            NOP  (52)
-  (37)                            PI  (52)
/  (37)                            QR  (53)
0-9 numeric constant  (38)         RAD  (53)
1/X  (39)                          RCL  (54)
10^X  (39)                         RDN  (54)
ABS  (40)                          R00-99 compare  (55)
ACOS  (40)                         RTN  (55)
ASIN  (41)                         R^  (56)
ATAN  (41)                         SF  (56)
BEEP  (41)                         SIGN  (57)
CF  (42)                           SIN  (57)
CHS  (42)                          SQRT  (58)
CLRG  (43)                         ST*  (58)
CLX  (43)                          ST+  (59)
COS  (43)                          ST-  (59)
DEG  (44)                          ST/  (60)
DSE  (44)                          STO  (60)
ENTER^  (45)                       STOP  (61)
E^X  (45)                          TAN  (61)
FC?  (46)                          T compare  (62)
FRC  (46)                          X<>Y  (62)
FS?  (47)                          X<>  (63)
GTO  (47)                          XEQ  (63)
INT  (48)                          X^2  (64)
ISG  (48)                          X compare (64)
LASTX  (49)                        Y^X  (65)
LBL  (50)                          Y compare  (65)
LN  (50)                           Z compare  (66)
LOG  (51)



                                                                       page 73


                             INDEX


absolute value 16,25,40                natural logarithm 16,25,50
alpha register 67                      negative exponent 12
angle mode 18,44,53                    negative numbers 11,42
animation speed 30                     nomenclature 34
arccosine 16,25,40                     NOP 22,52
arcsine 16,25,41                       number building keys 19,20
arctangent 16,25,41                    number terminating keys 19,20
automatic stack drop 21                numeric labels 50,67
automatic stack lift 20
                                       One-number operations 16,25
bank switching 9                       Overwrite X 10,12,13,35

cautions 34                            PI 9,25,35,38,52,69,73
chain arithmetic 19,21                 polynomial evaluation 72
change sign 16,25,42                   power of e 16,25,45
Clear X 10,26,43                       power of ten 16,25,39
clearing a program 27                  prime number generator 70
common logarithm 16,25                 program editor 31-33
constants 21,38                        Program Mode 23,27
cosine 16,25,43
cosine inverse 16,25,40                Quitting the program 24

degrees 18,44                          radians 18,53
delay time 30                          random number generator 71
display formats 10,68                  recalling 12,54
Display Screen 8                       reciprocal 16,25,39
division 15,25                         restrictions 34
                                       RETURN key 6
editing a program 31-33                Reverse Polish Logic 3
END instruction 68                     RGB Monitor 4
entering numbers 11                    roll down 10,26,54
ENTER^ function 13,26,45               roll up 10,26,56
error messages 17                      RPN philosophy 14
examples (syntax) 35                   RPN Summary 21
                                       running a program 24,30
Fast Mode 30
flags 42,46,47,56,67                   saving a program 29
                                       scientific notation 10,38
going to any line 32                   sine 16,25,57
                                       sine inverse 16,25,41
Help 26,27                             SIZE instruction 67
HP-41 4,67                             specification 35
                                       square 16,25,64
inserting instructions 32              square root 16,25,58
                                       stack lift 11,12,13,14,20,35
Jan Lukasiewicz 3                      stack operations 9,10
                                       stack order (-,/) 15
Key assignments 16,23,25,26            storing 12,60
keyboard commands 22                   subroutine levels 55,63,67
                                       subtraction 15,37
LASTX 17,26,49                         syntax 34
line numbers 5,33                      syntax summary 35,73
loading a program 28                   synthetic substitution 72

Manual Mode 8                          tangent 16,25,61
Manual Mode Summary 24-26              tangent inverse 16,25,41
merging a program 28                   text labels 50,67
MOD function 53,68                     Two-number operations 18,25


                                                                       page 74

word processor 5,31

X-register 8,64
X<>Y 9,22,62

                                                                       page 75