The Museum of HP Calculators

HP Forum Archive 17

[ Return to Index | Top of Index ]

HP35s meaning of indirect address 0/hp32sii keyboard
Message #1 Posted by Peter Niessen on 18 Aug 2007, 4:38 p.m.

Hi Forum,

proud owner of the new 35s since a few days, I'm a bit puzzled by the indirect variables 0-800. I came accross the VIEW(I)/VIEW(J) bug, but that was already described earlier in

the 48g forum

I'd also like to apologize if this has been brought up before, but I could not find it back in the forum. It seems that some editing took place, e.g.

for this message.

Now, I wrote the little program to delete all indirect variables

Length=30, CHKSM=EE33

C001 LBL C
C002 0.800
C003 STO I
C004 0
C005 STO (I)
C006 ISG I
C007 GTO C004
C008 RTN

to obey the point 2. on page 14-24 of the manual. However, after runnung the program, the number of variables is still > 700 according to the MEM menu, and only after saying

0
STO I
STO (I)

(which takes .5 seconds or so) the memory used by indirect variables is gone. (memo to HP: in the HP35Sii, there should be a CLR INDIRECT or so in the MEM menu.)

So, is there a special meaning for (0)?

On another point: I bought the 35s, which appeard at the right moment, as a replacement for my 32Sii, whose keys started to fail. I took it apart following

these instructions

an will glue in a little slice of rubber to make the case press against the board.

On that occasion, I noticed that the 32S can also display messages using equations and flag 10. Was this a documented feature?

Thanks for reading this up to here,

yours sincerely, Peter.

      
Re: HP35s meaning of indirect address 0/hp32sii keyboard
Message #2 Posted by Reth on 18 Aug 2007, 5:33 p.m.,
in response to message #1 by Peter Niessen

I made that point (about clearing indirect registers) before, but the post seems to disappeared... Assuming we've got 50 in reg 50 that makes MEM to report 51 indirect regs. As you've noticed those can be cleared and memory reclaimed at once only if you did store 0 in reg 0 *after* doing so for the rest of them ???


This works:

U001 LBL U
U002 50
U003 STO I
U004 CLSTK
U005 STO(I)
U006 DSE I
U007 GTO U005
U008 STO I
U009 STO(I)
U010 RTN

Cheers,
Reth
            
Re: HP35s meaning of indirect address 0/hp32sii keyboard
Message #3 Posted by Gerson W. Barbosa on 18 Aug 2007, 9:16 p.m.,
in response to message #2 by Reth

Quote:
I made that point (about clearing indirect registers) before, but the post seems to disappeared...

It will show up again. Meanwhile, Google cache has it, or most of it:

http://64.233.169.104/search?q=cache:c6RWHlRT3awJ:www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/forum.cgi%3Fread%3D120509+site:hpmuseum.org+Reth+%2B+%22INPUT+(I)+bug%22&hl=en&ct=clnk&cd=2

Regards,

Gerson.

                  
Re: HP35s meaning of indirect address 0/hp32sii keyboard
Message #4 Posted by Reth on 18 Aug 2007, 9:32 p.m.,
in response to message #3 by Gerson W. Barbosa

Thanks Gerson, now I saw it there. Cheers, Reth

      
Re: HP35s meaning of indirect address 0/hp32sii keyboard
Message #5 Posted by Dave Johnson on 18 Aug 2007, 5:35 p.m.,
in response to message #1 by Peter Niessen

p 1-5 CLVARx to clear indirect bank.

            
Re: HP35s meaning of indirect address 0/hp32sii keyboard
Message #6 Posted by Reth on 18 Aug 2007, 5:42 p.m.,
in response to message #5 by Dave Johnson

I've missed that, thanks; MEM still reports 1 indirect register available - the *0* one :) so - back to
0
STO I
STO(I)
Cheers,
Reth

and also CLVARx does not work in a program... so - back to the above :)

Edited: 18 Aug 2007, 5:46 p.m.

                  
Re: HP35s meaning of indirect address 0/hp32sii keyboard
Message #7 Posted by Gene Wright on 18 Aug 2007, 5:49 p.m.,
in response to message #6 by Reth

Yes, CLVARx clears the indirect registers GREATER than the number given to it as an argument.

So, give it a 0 and it clears 1 and up.

It is mentioned on page two of the indirect register learning module found here:

Indirect register learning module for the 35s

                        
Re: HP35s meaning of indirect address 0
Message #8 Posted by Reth on 18 Aug 2007, 6:24 p.m.,
in response to message #7 by Gene Wright

Thanks, Gene, but that's not the point; The point is (given we have 50 in reg 50) - after :

Q001 LBL Q
Q002 0.05
Q003 STO I
Q004 CLSTK
Q005 STO(I)
Q006 ISG I
Q007 GTO Q005
Q008 RTN
MEM reports 50 regs and :

49
STO I
RCL (I)
doesn't give an error messsage

Regards, Reth

Edited: 18 Aug 2007, 6:30 p.m.

                              
Re: HP35s meaning of indirect address 0
Message #9 Posted by Will Hartung on 18 Aug 2007, 6:48 p.m.,
in response to message #8 by Reth

To be fair, having the calculator report 50 registers makes complete sense.

When you store a value in to a register, the indirect register memory block is essentially a contiguous array of values.

If you stored a value in register 50, the calc allocates a block of memory up to and including 50. That's why you don't get an error for accessing register 49 -- it's already there (I dunno if you would get an error for 51, I've not played with a 35s).

Otherwise it would have to keep track of not just stored values, but "dirty" values, which would simply consume yet more memory, and access would be even slower than it may be now.

If the calculator kept track of individual registers, it would need to track their number and their location in memory. If you wanted to fetch the value, the calculator would then have to look up the list of "used" registers for the register you wanted, and look up it's actuall address, and finally the value. That's a lot of looking up!

Instead, HP traded memory for speed, being conscious of the fact that most folks would be doing most of their register dancing at the lower limits (who uses register number 743 in normal work anyway?), and that they'd most likely use contiguous blocks of registers (since they're easily leveraged as arrays).

This technique simply gives better performance, a reasonable trade off, and makes overall memory management much easier.

                                    
Re: HP35s meaning of indirect address 0
Message #10 Posted by Reth on 18 Aug 2007, 6:55 p.m.,
in response to message #9 by Will Hartung

You've missed the point - 0 has been stored in all indirect registers and still the system reports their existence. Storing 0 in I and 0 in (I) fixes it, system reports 0 indirect registers.

                                          
Re: HP35s meaning of indirect address 0
Message #11 Posted by Gene Wright on 18 Aug 2007, 7:47 p.m.,
in response to message #10 by Reth

Hmm. Yes, I had seen the point you were making. I was just commenting on the CLVARx portion. :-)

Try this...do the loop counting down rather than up and see if that does it differently.

                                                
Re: HP35s meaning of indirect address 0
Message #12 Posted by Reth on 18 Aug 2007, 8:01 p.m.,
in response to message #11 by Gene Wright

I did, just look a few posts up; Looping down lives 1 register intact - reg 0; Looping up leaves all 50; In both cases if you don't store 0 in I and then indirectly 0 in (I) *at the end of the process* you don't get the expected 0 indirect regs. That makes me and the original poster to think about "special" meaning of the 0 register, features, bugs, misprints etc, etc, etc... :)
cheers,

reth

            
Re: HP35s meaning of indirect address 0/hp32sii keyboard
Message #13 Posted by Peter Niessen on 18 Aug 2007, 6:36 p.m.,
in response to message #5 by Dave Johnson

Thanks! And thank you for not posting RTFM!

Cheers, Peter.

      
Re: HP35s meaning of indirect address 0/hp32sii keyboard
Message #14 Posted by Vincze on 20 Aug 2007, 9:41 a.m.,
in response to message #1 by Peter Niessen

I have question about indirect variables. I read manual, but I little confused. It say it variable that not defined beforehand. Is this like temp variable in programming that only there when program run and gone after. Or is this like not declaring a variable? Then further in manual it say is useful for controlling loops. So is it like array?

I guess I just not understand what I and J be. Can someone give me simple explanation and why I might use it.

            
Re: HP35s meaning of indirect address 0/hp32sii keyboard
Message #15 Posted by Don Shepherd on 20 Aug 2007, 9:55 a.m.,
in response to message #14 by Vincze

Vincze, refer to the link in Gene's post in this thread. You really need to be looking at those training modules since he has already done the work of explaining these topics to those who do not understand them.

                  
Re: HP35s meaning of indirect address 0/hp32sii keyboard
Message #16 Posted by Vincze on 20 Aug 2007, 10:15 a.m.,
in response to message #15 by Don Shepherd

Thank you my friend, I will do.

                  
Re: HP35s meaning of indirect address 0/hp32sii keyboard
Message #17 Posted by Vincze on 20 Aug 2007, 10:53 a.m.,
in response to message #15 by Don Shepherd

Ok, I read Gene's article, but now I more confused. On page two of Gene's article, it say

Quote:
This becomes very useful is when you need to work with a lot of numbers, often within programs, or or when you may not be able to know in advance where the number you wish to use is stored.

How you not know where to store value? When I write program, I create variables that I name, and I store value there. How someone not know where to store value if you declare variables. I think I missing very fundamental point of this, so please excuse me being ignorant.

                        
Re: HP35s meaning of indirect address 0/hp32sii keyboard
Message #18 Posted by Don Shepherd on 20 Aug 2007, 10:57 a.m.,
in response to message #17 by Vincze

Google "indirect addressing"

                              
Re: HP35s meaning of indirect address 0/hp32sii keyboard
Message #19 Posted by Vincze on 20 Aug 2007, 11:43 a.m.,
in response to message #18 by Don Shepherd

Okay, I say fervent prayer to Saint Google and see what he have to say.

                                    
Re: HP35s meaning of indirect address 0/hp32sii keyboard
Message #20 Posted by Vincze on 20 Aug 2007, 11:53 a.m.,
in response to message #19 by Vincze

Okay, I understand now. It basically an indirection array. That make sense to me now. Not sure when I would use on calculator, but, it nice to have.

                                          
Re: HP35s meaning of indirect address 0/hp32sii keyboard
Message #21 Posted by bill platt on 20 Aug 2007, 12:33 p.m.,
in response to message #20 by Vincze

Vincze,

You might enjoy reading about programming on the HP-41C. There was a link not long aog here to a complete HTML facsimilie of the manual.

The 41 makes large use of "indirection" as it is known. It is useful for more than just getting to the "extra" registers.

Best regards,

Bill

                                                
Re: HP35s meaning of indirect address 0/hp32sii keyboard
Message #22 Posted by Vincze on 20 Aug 2007, 1:01 p.m.,
in response to message #21 by bill platt

My friend Bill, thank you for that suggestion. Yes, I do remember that link, and I shall see if I can track it down and look into that. It would be nice to conceptualize why I might use indirection on calculator. In programming I have used many times, but I just can't grasp why I would use on calculator.

                                                      
Re: HP35s meaning of indirect address 0/hp32sii keyboard
Message #23 Posted by Bill (Smithville, NJ) on 20 Aug 2007, 2:09 p.m.,
in response to message #22 by Vincze

Hi Vincze,

Quote:
It would be nice to conceptualize why I might use indirection on calculator. In programming I have used many times, but I just can't grasp why I would use on calculator.

Indirection is great to use to pass a parameter of several memory locations to a subroutine.

For example:

Several years ago, I was writing a program to calculate the psychometric properties of air. I had several subroutines that would be called for each of the air streams - Outside Air, Room Air and Mixed Air. Instead of trying to pass all the variables on the stack, I would pass only the single index value. For example, 10 for Outside air, 20 for Room Air and 30 for Mixed air.

For each of the air streams, the parametes were stored in sequential memory locations - R11-15, R21-25, and R31-35. The subroutine would then use the index variable to extract and work on the respective air stream. The results could be stored in R16-19, R26-29, R36-39.

A similar method was then used to printout the results - a single subroutine that used the index to determine which air stream to print.

It worked great. Unfortunatelly, I got sidetracked about halfway through the project and never finished the program. Still want to get back to it one of these days.

Bill

                                                            
Re: HP35s meaning of indirect address 0/hp32sii keyboard
Message #24 Posted by Peter Niessen on 20 Aug 2007, 5:14 p.m.,
in response to message #23 by Bill (Smithville, NJ)

Hi Vince,

another use of the indirect variables is to use it as a parameter stack when recursively calling a subroutine. (Like a higher language does for you in the background.) As an example, see

Towers of Hanoi on the HP32s

(I apologise for this self-promotion)

which shifts around the towers of Hanoi using a recursive prescription:

void move (int n, int source, int target) {
  if (1 == n) {
    std::cout << "Move disk from " << source << " to " << " target
       << std::endl;
    return;
  move (n-1, source, 6-target-source);
  move (1, source, target);
  move (n-1, 6-target-source, target);
}

Or, maybe a bit simpler: Factorials: n! = n * (n-1)!

[pre] int factorial (int n) {

if (n <= 1) // we're done and know the answer return 1;

return n * factorial (n - 1); }

Of course, these are more academic examples, in real life things might be done differently.

Other (more down to earth application) could be a chi-square test

(wiki article here)

where you use the indirect variables to represent a histogram with a previously unknown number of bins.

Cheers, Peter.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall