The Museum of HP Calculators

HP Forum Archive 13

[ Return to Index | Top of Index ]

(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 register---because 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


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

A small clue...
Message #2 Posted by Vieira. Luiz C. (Brazil) on 17 June 2003, 5:12 p.m.,
in response to message #1 by bill platt

Hey, Bill;

try something like:


I have no manuals in hands, but what you should take much care is to make sure LAST ARGUMENT is set ON or you'll lost the arguments when STO+ (or any storage operation) fails. Also, storage arithmetic allows variable name in level 1 or 2; in my example, the variable name should bve in level 1.

If my example fails, let me know. I read your post now and I know this is one possibility, but I'm in a rush. I have to teach classes in about five minutes... Gosh!


Luiz C. Vieira - Brazil

Re: (long) Storage Register Math in 48GX
Message #3 Posted by R Lion (Espaņa) on 17 June 2003, 6:18 p.m.,
in response to message #1 by bill platt

Well, as Luiz said, one way is the IFERR...THEN...END, but the easiest way (IMHO) is define the variables we are going to use at the begining of the program. Why don't do it?

I'll try to convert these prgs to RPL, but, please, help me with a good description of what is exactly you want in my email.


Re: (long) Storage Register Math in 48GX
Message #4 Posted by bill platt on 17 June 2003, 7:16 p.m.,
in response to message #3 by R Lion (Espaņa)

Raul and Luiz,


I tried both your respective ideas the first time around----but I'm sure I did not understand the command order quite right but will try a bit now and get back to you-all.

Thanks again,

best regards,


[ Return to Index | Top of Index ]

Go back to the main exhibit hall