Some 30b routines, revisited



#6

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 add

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
Step function comments
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
Step function comments
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
Step function comments
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
Step function comments
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
Step function comments
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
Step function comments
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
Step function comments
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
Step function comments
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
Step function comments
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
Step function comments
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.


#7

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.


#8

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.


#9

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

#10

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.


Possibly Related Threads...
Thread Author Replies Views Last Post
  17BII & 17BII+ Discounted Payback Period Revisited Tom Neudorfl 8 1,083 11-25-2013, 10:28 AM
Last Post: Don Shepherd
  Touch periodic table on HP Prime - revisited Terje Vallestad 2 482 11-23-2013, 11:47 AM
Last Post: Mic
  Flashing cable for HP 20 / 30B Stefan Koenig 3 659 09-19-2013, 05:53 AM
Last Post: Marcus von Cube, Germany
  Any 30b cables left? patryk 7 852 09-16-2013, 02:54 PM
Last Post: Marcus von Cube, Germany
  HP-30B (WP-34S) Technical Documentation Barry Mead 3 599 09-09-2013, 03:07 PM
Last Post: Harald
  HP's thinking behind the 20b/30b? John Ioannidis 3 536 09-07-2013, 10:21 AM
Last Post: Tim Wessman
  30b/34s interfacing? ross sponholtz 5 690 06-26-2013, 01:41 AM
Last Post: Walter B
  A slide rule to conquer the moon revisited Palmer O. Hanson, Jr. 12 1,307 06-19-2013, 03:05 PM
Last Post: Ken Shaw
  Inexpensive HP 30b Matthew Richards 23 2,010 05-22-2013, 10:10 AM
Last Post: Dave
  HEPAX Revisited: Revision 1E available Ángel Martin 4 595 05-03-2013, 01:57 PM
Last Post: Diego Diaz

Forum Jump: