# HP Forums

Full Version: Some 30b routines, revisited
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

In Some 30b Routines Jeff O presents 10 routines

Quote:
In the absence of a complete repurposing of the 30b, I decided to come up with a set of key reassignments and/or programs to make the 30b more easily useable (to me, at least) as a scientific calculator. I decided to implement the following functions in the 10 available program slots:

SIN-1

COS-1

TAN-1

Complex subtract

Complex multiply

Complex divide

Complex Invert

Polar to Rectangular Conversion

Rectangular to Polar Conversion

Within the message thread program modifications were made so that all programs could have program labels and still fit in the 290 byte program memory of the 30b. Thomas Klemm contributed to the final set of programs.

I wondered if the programs could be shrunk further. Further shrinkage would have no practical purpose since there could be no more than 10 programs therefore no way to use the released program memory. Still, the exercise was enjoyable and successful. The shrunken programs revisited consume 272 bytes of 290 bytes of program memory.

I played with the 30b inverse trig functions sin-1, cos-1, and tan-1. I discovered whether or not the 2nd or final Input is pressed, that when followed by an arithmetic (+, -, X, /) or one-number (x^2, 1/x, e^x, etc.) function the answer is the same. (My calculator's SW version 4 5 2010 1.) The advantage to not pressing the 2nd or final Input is the name of the inverse trig function (sin-1, cos-1, tan-1) remains displayed. This eliminates the need for the 2nd message XXX-1 step, a saving of 18 bytes total. Also, I made COS-1 and TAN-1 callable routines and re-numbered labels.

Here are the ten programs, revisited. Programs 3, 4, and 9 are unchanged from the original message thread.

```Prgm 0
Program Description:	Arc Sine
bytes and checksum: 11.090
0	SH7	        assign to shift-hold 7
1	message SIN-1	Program label
2	Math	        execute SIN-1 function
3	Input	        execute SIN-1 function
4	Down	        execute SIN-1 function
5	Stop
Prgm 1
Program Description:	Arc Cosine
bytes and checksum: 14.118
0	SH8	        assign to shift-hold 8
1	message COS-1	Program label
2	Lbl11		Program label for call from R->P routine
3	Math	        execute COS-1 function
4	Input	        execute COS-1 function
5	Up	        execute COS-1 function
6	Up	        execute COS-1 function
7	RTN		Return for call
Prgm 2
Program Description:	Arc Tangent
bytes and checksum: 13.189
0	SH9	        assign to shift-hold 9
1	message TAN-1	Program label
2	Lbl21		Program label for call from R->P routine
3	Math	        execute TAN-1 function
4	Input	        execute TAN-1 function
5	Up	        execute TAN-1 function
6	RTN		Return for call
Prgm 3
Program Description:	Add two rectangular form complex numbers
bytes and checksum: 24.218
0	SH+	        assign to shift-hold +
1	message CPLX+	Program label
2	) Swap
3	( Rv	        Roll down
4	+
5	( Rv	        Roll down
6	+
7	( Rv	        Roll down
8	( Rv	        Roll down
9	( Rv	        Roll down
10	message CPLX+	display CPLX+ upon completion
11	Stop
Prgm 4
Program Description:	Subtract two rectangular form complex numbers
bytes and checksum: 25.053
0	SH-	        assign to shift-hold -
1	message CPLX-	Program label
2	) Swap
3	( Rv	        Roll down
4	-
5	( Rv	        Roll down
6	) Swap
7	-
8	( Rv	        Roll down
9	( Rv	        Roll down
10	( Rv	        Roll down
11	message CPLX-	display CPLX- upon completion
12	Stop
Prgm 5
Program Description:	Multiply two rectangular form complex numbers
bytes and checksum: 41.251
0       SH*             assign to shift-hold x
1       message CPLX*   Program label
2	Lbl 51	        Program label for call from divide routine
3       STO 1
4       ( Rv            Roll down
5       STO 2
6       ) Swap
7       STO * 1
8       *
9       ( Rv            Roll down
10      STO * 2
11      ) Swap
12      ( Rv            Roll down
13      *
14      +
15      RCL 1
16      RCL - 2
17      message CPLX*   display CPLX* upon completion
18      RTN             Return for Call
Prgm 6
Program Description:	Divide two rectangular form complex numbers
bytes and checksum: 20.194
0	SH/	        assign to shift-hold /
1	message CPLX/	Program label
2	Call71	        execute complex invert routine
3	Call51	        execute complex multiply routine
4	message CPLX/	display CPLX/ upon completion
5	Stop
Prgm 7
Program Description:	Invert a rectangular form complex number
bytes and checksum: 47.204
0	NPV	        assign to the NPV key
1	message CPLX x-1 Program label
2	Lbl 71	        Program label for call from divide routine
3	STO 1
4	( Rv	        Roll down
5	( Rv	        Roll down
6	( Rv	        Roll down
7	STO 2	        Store value that was at top of stack
8	( Rv	        Roll down
9	STO * 1
10	) Swap
11	+/-
12	Input
13	x^2
14	RCL + 1
15	/
16	) Swap
17	Ans
18	/
19	RCL 2
20	( Rv	        Roll down
21	message CPLX x-1 display CPLX x-1 upon completion
22	RTN	        Return for Call
Prgm 8
Program Description:    Rectangular to Polar Conversion
Bytes and checksum: 52.195
0       IRR             assign to the IRR key
1       message R->P    Program label
2       STO 1           store real component
3       x^2             square real component
4       ) Swap          swap squared real component and imaginary component
5       STO 2           store imaginary component
6       x^2             square imaginary component
7       +               add squared imaginary component
8       square root     take square root to calculate magnitude
9       STO 3           store magnitude
10      Input           duplicate magnitude to stack y since GF consumes stack x value
11      GF 82           branch to end if magnitude = 0
12      RCL + 1         add real component: r + x
13      Input           duplicate r + x to stack y since GF consumes stack x value
14      GF 81           branch if magnitude + real component = 0
15      RCL 2           imaginary component: y
16      ) Swap          swap y and r + x
17      /               divide to calculate tangent of half-angle: y / (r + x)
18      Call21          execute TAN-1 function
19      Input           input TAN-1 function
20      Gto 82          branch to end
21      Lbl 81          Routine to handle magnitude + real component = 0 part
22      Call11          execute COS-1 function to obtain 180 (or Pi)
23      Input           input COS-1 function
24      Lbl 82          Label for branch in steps 11 and 20
25      2               enter two
26      *               multiply half-angle by 2 to get angle
27      RCL 3           recall magnitude
28      message R->P    display R->P upon completion
29      Stop
Prgm 9
Program Description:	Polar to Rectangular Conversion
bytes and checksum: 25.058
0	CashFl	        assign to the CashFl key
1	message P->R	Program label
2	STO 1	        store magnitude
3	( Rv	        Roll down to preserve stack
4	Cos	        take cosine of angle
5	Ans	        recall the angle
6	Sin	        take sine of angle
7	RCL * 1	        calculate imaginary component
8	) Swap
9	RCL * 1	        calculate real component
10	message P->R	display P->R upon completion
11	Stop```

Edited: 11 Oct 2011, 4:29 a.m.

Hello Harry,

I did not exect to see that post brought up again :-) The main interest in the 30b nowadays is as a platform for wp34s.

As far as leaving out the INPUT, that does seem to work if your next action is some function. But if you want to key in a new value to operate on the result, you must remember to press INPUT first.

Et tu Jeff?

Did you convert your 30b to a wp34s?

I do use the 30b TVM functions.

About INPUT, you'll notice I left them in program 8 after the call statements. No sweat when using the calculator having to INPUT for some calculations. Easy to remember.

It's curious there's no need to INPUT when followed by Roll Down, Swap, and +/-! The only operations I do which need INPUT are STO and the occasional entry of a new value which (to me) make them the exceptions.

Hi Harry,
These are nice programs. May I suggest to create an article, so they are not lost in the constant flow of posts in the forum?

Regards,

Miguel

Sorry, no betrayal was intended.

I have two 30b calculators - one is converted to wp34s, the other is to be converted, but as yet remains a 30b.