The Museum of HP Calculators

HP Forum Archive 21

[ Return to Index | Top of Index ]

HP 34S integration
Message #1 Posted by Richard Berler on 18 Feb 2013, 1:37 a.m.

I notice on a 4 level stack, the integration function fills all of the stack levels with an initial "x". It appears that the 8 level stack does not fill all 8 levels with the initial value. By adding the "fill" command at the beginning of my instructions, the integration worked in an identical manner as the 4 stack problem (I used a rolls up in my procedure). Was the difference in behavior intentional...what is the advantage?

Thanks.

      
Re: HP 34S integration
Message #2 Posted by Paul Dale on 18 Feb 2013, 2:12 a.m.,
in response to message #1 by Richard Berler

The integrator fills x, y, z & t with the current value. This is regardless of stack size. It is intentional. There isn't really an advantage, although registers a, b, c & d are preserved between calls to the function so stuff can be safely placed there.

- Pauli

      
Re: HP 34S integration
Message #3 Posted by Walter B on 18 Feb 2013, 2:31 a.m.,
in response to message #1 by Richard Berler

The integration routine is based on an earlier program from a time when only 4 stack levels were available (i.e. from the dark ages before the WP 34s ;-) ). Hence ...

d:-)

            
Re: HP 34S integration
Message #4 Posted by Gerson W. Barbosa on 18 Feb 2013, 7:17 a.m.,
in response to message #3 by Walter B

Quote:
(i.e. from the dark ages before the WP 34s ;-) )

Or from the dark ages before 1987, when the HP-28C with stack size limited only by the available memory hadn't been introduced yet :-)

                  
Re: HP 34S integration
Message #5 Posted by Walter B on 18 Feb 2013, 7:24 a.m.,
in response to message #4 by Gerson W. Barbosa

Please keep RPL out of this thread :-)

      
Re: HP 34S integration
Message #6 Posted by Paul Dale on 18 Feb 2013, 4:25 a.m.,
in response to message #1 by Richard Berler

I can change how solve loads the stack easily enough. Is it desirable? What advantages are there for filling all eight levels?

- Pauli

            
Re: HP 34S integration
Message #7 Posted by Walter B on 18 Feb 2013, 4:58 a.m.,
in response to message #6 by Paul Dale

Well, an obvious advantage is you can benefit from top stack level repetition. But is that worth sacrificing the contents of four stack levels?

d:-/

            
Re: HP 34S integration
Message #8 Posted by Gerson W. Barbosa on 18 Feb 2013, 7:02 a.m.,
in response to message #6 by Paul Dale

Quote:
What advantages are there for filling all eight levels?
If for nothing else, at least for backward compatibility with the program at page 205 of the original HP-34C manual:
Keystrokes                 Display
h LBL 1                    001-25, 13, 1         Begin subroutine with a
                                                 LBL instruction.
f SIN                      002-    14  7         Calculate sin theta.
-                          003-       41         Since a value of theta will be
                                                 placed into the Y-register by
                                                 the integration algorithm before 
                                                 it executes this subroutine, 
                                                 the [-] operation at this point
                                                 will calculate (theta - sin theta).
f cos                      004-    14  8         Calculte cos(theta - sin theta).
h RTN                      005-    25 12
Gerson.
                  
Re: HP 34S integration
Message #9 Posted by Walter B on 18 Feb 2013, 7:22 a.m.,
in response to message #8 by Gerson W. Barbosa

Page 204 would have been even better:

"Before calling the subroutine that evaluates f(x), the [integral] algorithm - just like the [SOLVE] algorithm - places the value of x in the X-, Y, Z-, and T-registers. Because every stack register contains the x value, your subroutine can calculate with this number without having to recall it from a storage register."

That's what I meant with "an obvious advantage is you can benefit from top stack level repetition" in my post above.

d:-)

            
Re: HP 34S integration
Message #10 Posted by David Hayden on 18 Feb 2013, 7:44 a.m.,
in response to message #6 by Paul Dale

Quote:
I can change how solve loads the stack easily enough. Is it desirable? What advantages are there for filling all eight levels?
As the original poster said, the would mean that a rolldown (or rollup) in the function would work correctly regardless of stack mode.

But it seems to me that this is just a symptom of the larger issue that rolldown and rollup depend on the stack mode. It might make sense to add functions that do "roll 4" and "roll 8" so a program can be explicit about what it wants without having to change the stack mode.

Dave

                  
Re: HP 34S integration
Message #11 Posted by Walter B on 18 Feb 2013, 8:09 a.m.,
in response to message #10 by David Hayden

Quote:
... rolldown and rollup depend on the stack mode.
Not true. As can be seen on pp. 20 and 31, Rv and R^ affect all stack levels in either case. And what you call 'stack mode' is actually 'stack size', isn't it?

Quote:
It might make sense to add functions that do "roll 4" and "roll 8" so a program can be explicit about what it wants without having to change the stack mode.
I'd vote for "roll full" and "roll half" if we'd need that. The latter would equal x<>y in a 4-level stack. But I don't think these functions are required.

d:-)

                        
Re: HP 34S integration
Message #12 Posted by Richard Berler on 18 Feb 2013, 11:32 a.m.,
in response to message #11 by Walter B

Of course, any problem/inconvenience caused by initial values only filling the first 4 stack levels would appear in the solve application on an 8 stack size.

                        
Re: HP 34S integration
Message #13 Posted by David Hayden on 18 Feb 2013, 12:27 p.m.,
in response to message #11 by Walter B

Hi Walter,

Quote:
Not true. As can be seen on pp. 20 and 31, Rv and R^ affect all stack levels in either case.
My point is that if you explicitly want to roll the X, Y, Z and T registers, you'd have to ensure that the stack size is 4.
Quote:
I'd vote for "roll full" and "roll half" if we'd need that. The latter would equal x<>y in a 4-level stack. But I don't think these functions are required.
"Roll full" and "roll half" might be useful, but they wouldn't solve the issue here (a program executes Rv and mistakenly assumes that the stack size is 4 instead of 8). One can certainly argue that a program that uses Rv and R^ should set the stack size ahead of time (and restore it upon exit), but I think it would be more convenient to give programmers commands to explicitly roll 4 registers or 8.

Hmm, here's something to consider, though maybe not for the 34S. What if the stack size only affected the automatic push and drop that occur with LASTx, and 1 or 2 number functions (the last 3 columns on page 20). ENTER, FILL, DROP, Rv and R^ would have 4- and 8- register versions. In fact, there would be ONLY the 4- and 8-register versions of the commands (e.g., ENTER4 and ENTER8, but no ENTER). Pressing the ENTER, Rv or R^ keys would execute either the 4- or 8-register version of the command, depending on the current stack size.

The idea behind this would be to minimize the chances of programming errors related to assuming a particular stack size, while still maintaining the advantages of two possible stack sizes.

Dave

                              
Re: HP 34S integration
Message #14 Posted by Richard Berler on 18 Feb 2013, 2:14 p.m.,
in response to message #13 by David Hayden

I was perhaps naively thinking that the filling of the x,y,z,t stack levels with x was a quirk of the solve and integration applications alone. If so, a fix i.e., incorporating a proper "fill" into the start of those routines would be necessary for just those 2 items? Otherwise, as long as the user is aware (put it in the manual just like the instructions for using radians were given for complex # functions), it certainly is easy for me to include the fill command in my use of solve and integrate.

                                    
Re: HP 34S integration
Message #15 Posted by Walter B on 18 Feb 2013, 3:41 p.m.,
in response to message #14 by Richard Berler

It affects more than just SLV and [integrate] ... f', f", [Pi], and [Sigma] are also touched. Anyway, it's in now - any such command will fill the complete stack with x before calling the user function.

d:-)

                              
Re: HP 34S integration
Message #16 Posted by Walter B on 18 Feb 2013, 3:50 p.m.,
in response to message #13 by David Hayden

Hi David,

WP 34S is a single-user system. I sincerely hope the user knows what stack size (s)he set (psst: find out with SSIZE?). So I won't do any extra gymnastics for people being ... ummh ... memory-challenged. KISS, although YMMV.

d;-)

                              
Re: HP 34S integration
Message #17 Posted by Marcus von Cube, Germany on 18 Feb 2013, 4:42 p.m.,
in response to message #13 by David Hayden

Quote:
My point is that if you explicitly want to roll the X, Y, Z and T registers, you'd have to ensure that the stack size is 4.

The shuffle command [<->] is designed for this:

R^4 is [<->] TXYZ
Rv4 is [<->] YZTX

We had a discussion about extending the command to eight registers but this will not easily fit in the internal command structure. So you will have to be content with four stack registers by now.

Edited: 18 Feb 2013, 4:43 p.m.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall