Real Program Examples - HP -42S Manual

An alternative: hp-42s calculator and free42 simulator for palmos
Hide thumbs Also See for HP-42S:
Table of Contents

Advertisement

Example: A kind of "timer"
01 LBL A
02 1
03 –
04 X=0?
05 STOP (Enter R/S)
06 GTO A
07 RTN
In this program you first enter a big integer number and then press XEQ "A". The program will
subtract 1 from this number until it gets to zero. Of course the bigger the number the bigger the time
the program will spend. The Emu42 program (yes, I use it too) in my laptop using "Authentic
Calculator Speed" option takes about 37s for the number 1000. Without this option, or using Free42,
it is too much faster!

6.4 Real program examples

Here is one of my favorite programs. It just see if a number is prime. (With a small change this works
in the 33S too).
01 LBL "PRIME"
02 STO 00
03 2
04 STO 01
05 MOD (Rmdr in HP-33S)
06 X=0?
07 GTO F
08 3
09 STO 01
10 RCL 00
11 SQRT
12 STO 02
13 LBL B
14 RCL 00
15 RCL 01
16 MOD
17 X=0?
18 GTO F
19 2
20 STO + 01
21 RCL 02
22 RCL 01
23 X≤Y?
24 GTO B
25 RCL 00
26 STO 01
27 LBL F
28 RCL 01
29 RTN
Because the HP 42S programming format is a superset of that of the immensely popular HP 41C and
HP 41CX calculators, there is a huge library of programs that can be used directly by the HP42S or
readily adapted. A big collection can be found at http://www.hpmuseum.org/software/soft41.htm.

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

42sFree42

Table of Contents