(long) Storage Register Math in 48GX Message #1 Posted by bill platt on 17 June 2003, 3:07 p.m.
I couldn't decide whether to post here or in comp.sys.hp48, but since I am including an RPN program, decided to post here.
(I think Raul Lion will find this question easy to answer).
My problem is (and this will show me to be a real RPL neophyte) that I have not found a clean and easy way to do storage register math with RPL. Perhaps it is just that the "STO + x" mentality is just so engrained, but when I try various combinations of local and global variables in RPL, I keep ending up with problems trying to add a value to an old registerbecause if the register is not defined, then I cannot add to it! I am not clever enough to figure out a flag or loop control to say, "if the register x does not exist, then make it, else recall it, act on it with the stack, and store the result back in x".
The specific RPN programs which I was trying to convert are shown below. Being a mechanical type of engineer (actually ships and boats etc) I often solve weight and moment computations, and a handy way of doing this repetitively (like when checking a spreadsheet, or on a ship in the bilge, adding up lead ingots or something) is to use the following programs:
Programs for summing moments about the w,x,y axes and finding the arms and total masses.
Will find intermediate summations and allow for continuation.
first, enter data int stack this way:
Mass <ent> arm w <ent> arm x <ent> arm y <ent>, leaving the stack as such:
T z (mass)
z w (arm)
y x (arm)
x y (arm)
01 LBL w (Program for taking mass and arm input, and producing running sum of moments)
02 R ^
03 STO s (stores currently entered mass for temp use)
04 STO + z (stores currently entered mass for summation)
05 X (multiplies the "y" {from orig reg. "t"} arm by the mass
06 STO + y (stores the y moment for summation)
07 R down
08 RCL s
09 X (multiplies the "x" {from orig reg. "z"} arm by the mass)
10 STO + x
11 R down
12 RCL s
13 X
14 STO + w
15 RTN
checksum AD51 022.5 bytes
view any mass or moment sum by reviewing the appropriate register
01 LBL T (program to take sums of moments in w,x,y axes and sum of mass, and finds arms.
02 0
03 ENTER
04 ENTER (clearing stack)
05 RCL y ("y" moment sum)
06 RLC z (mass moment sum)
07 / (solve "y" arm)
08 STO v (store "y" arm)
09 RCL x ("x" moment sum)
10 RCL z
11 / (solve "x" arm)
12 STO u
13 RCL w ("w" moment sum)
14 RCL z
15 /
16 STO t (store "w" arm)
17 RTN
check 089E 025.5 bytes
Note that the w,x,y arms are in the (x,y,z) stack registers and may be viewed with Rdown.
Besr regards,
Bill Platt
