Some 30b Routines Message #1 Posted by Jeff O. on 20 Aug 2010, 1:02 p.m.
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
Complex numbers and Rectangular to Polar functions are based on the (old) paradigm of representing a complex number in rectangular form with the real in stackx and the imaginary in stacky. Stackz and stackt hold the second complex value for add, subtract, multiply and divide, with the 4level real stack considered a 2level complex stack. Complex invert preserves the stackz and stackt values. The polar to rectangular routine also preserves the stack so you can enter a complex rectangular value, then enter a complex polar value, convert it to rectangular form and then add, subtract, multiply or divide with the first value. R>P and P>R work in both radians and degrees mode. All programs display a message when complete to announce the function just executed. I also put the same message as step 1 to act as a program label for several of the routines, but did not have enough room to do so for all. I did not really attempt to optimize the programs  once I got them working with all routines fitting in memory, I stopped. I'm sure there is room for improvement. I'd like to have enough room to add the program labels to all programs, but I'll leave that as an exercise for the reader.
I wish the 30b had 10 more program slots and maybe double the memory so I could move a few more functions to the keyboard and create some additional routines.
Prgm 0
Program Description: Arc Sine
bytes and checksum: 18.057
Step function comments
0 SH7 assign to shifthold 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 Input execute SIN^{1} function
6 message SIN^{1} displays SIN^{1} upon completion
7 Stop
Prgm 1
Program Description: Arc Cosine
bytes and checksum: 13.253
Step function comments
0 SH8 assign to shifthold 8
1 Math execute COS^{1} function
2 Input execute COS^{1} function
3 Up execute COS^{1} function
4 Up execute COS^{1} function
5 Input execute COS^{1} function
6 message COS^{1} displays COS^{1} upon completion
7 Stop
Prgm 2
Program Description: Arc Tangent
bytes and checksum: 12.009
Step function comments
0 SH9 assign to shifthold 8
1 Math execute TAN^{1} function
2 Input execute TAN^{1} function
3 Up execute TAN^{1} function
4 Input execute TAN^{1} function
5 message TAN^{1} displays TAN^{1} upon completion
6 Stop
Prgm 3
Program Description: Add two rectangular form complex numbers
bytes and checksum: 24.218
Step function comments
0 SH+ assign to shifthold +
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+ displays 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 shifthold 
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 displays CPLX upon completion
12 Stop
Prgm 5
Program Description: Multiply two rectangular form complex numbers
bytes and checksum: 49.254
Step function comments
0 SH* assign to shifthold x
1 message CPLX* Program label
2 Lbl 04 Program label for call from divide routine
3 STO 1
4 STO 3
5 (Rv Roll down
6 STO 2
7 STO 4
8 ( Rv Roll down
9 STO * 1
10 STO * 4
11 ( Rv Roll down
12 STO * 2
13 STO * 3
14 RCL 4
15 +
16 RCL 1
17 RCL  2
18 message CPLX* displays CPLX* upon completion
19 RTN Return for Call
Prgm 6
Program Description: Divide two rectangular form complex numbers
bytes and checksum: 20.047
Step function comments
0 SH/ assign to shifthold /
1 message CPLX/ Program label
2 Call03 execute complex invert routine
3 Call04 execute complex multiply routine
4 message CPLX/ displays CPLX/ upon completion
5 Stop
Prgm 7
Program Description: Invert a rectangular form complex number
bytes and checksum: 47.060
Step function comments
0 NPV assign to the NPV key
1 message CPLX x^{1 }Program label
2 Lbl 03 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 }displays CPLX x^{1} upon completion
22 RTN Return for Call
Prgm 8
Program Description: Rectangular to Polar Conversion (by Thomas Klemm)
Bytes and checksum: 55.134
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 02 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 01 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 halfangle: y / (r + x)
18 Math execute TAN1 function
19 Input execute TAN1 function
20 Up execute TAN1 function
21 Input execute TAN1 function
22 Gto 02 branch to end
23 Lbl 01 Routine to handle magnitude + real component = 0 part
24 Math execute COS1 function to obtain 180 (or Pi)
25 Input execute COS1 function to obtain 180 (or Pi)
26 Up execute COS1 function to obtain 180 (or Pi)
27 Up execute COS1 function to obtain 180 (or Pi)
28 Input execute COS1 function to obtain 180 (or Pi)
29 Lbl 02 Label for branch in steps 11 and 22
30 2 enter two
31 * multiply halfangle by 2 to get angle
32 RCL 3 recall magnitude
33 message R>P displays R>P upon completion
34 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 displays P>R upon completion
11 Stop
^{edited to use much better R>P routine by Thomas Klemm and add more program labels.}
Edited: 24 Aug 2010, 8:23 p.m. after one or more responses were posted
