The Museum of HP Calculators

HP Forum Archive 14

[ Return to Index | Top of Index ]

Help with 42S Programming
Message #1 Posted by Bill (Smithville, NJ) on 2 Apr 2004, 1:37 p.m.

I'm trying to write a subroutine that will be called in several locations from the main program loop. There are three basic variables: DBx, WBx and PSx - where the 'x' is a number from 1 to 3 (i.e., DB1, DB2, DB3...)

Each time I call the subroutine, I'd like to place the variable number (1, 2 or 3) in the X register and then have the subroutine perform the calculations based on that set of variables.

How do I go about setting up the RCL instruction so that it would recall the correct varaible set when needed?

I came up with the following brute force method, but there has to be a smaller or more elegant method:

ALL

"DB"

ARCL ST X

ASTO 01

RCL IND 01

FIX 02

Thanks for your help. 12345

      
Re: Help with 42S Programming
Message #2 Posted by Vieira, Luiz C. (Brazil) on 2 Apr 2004, 4:33 p.m.,
in response to message #1 by Bill (Smithville, NJ)

Hi, Bill;

I think that you have at least two alternate methods. I'm just pointing them out now, and I can scratch some steps to perfrom them; just a matter of time right now.

First: consider using ordinary numbered registers instead of ALPHA ones; there is a memory issue (less memory), but the indexes should be restablished;

Second: create three [13] matrices: DB, WB and PS. Whenever you want to use one or another, you simply INDEX it and use [->] or [RCLEL] to recall their contents.

These are the ones I thought about for now. Others surely exist, and someone will probably post about it soon. If you need guidance:

lcvieira@quantica.com.br

Anyway, I'll be back in a couple of hours.

Success.

Luiz (Brazil)

            
Re: Help with 42S Programming
Message #3 Posted by Bill )Smithville, NJ) on 3 Apr 2004, 6:22 a.m.,
in response to message #2 by Vieira, Luiz C. (Brazil)

Hi Luiz,

Thanks for your ideas.

I'm familar with using numbered registers - I usually prefer them over alpha ones. I'm trying to convert a program written for the HP-48GX to the 42S. Was using alpha ones to maintain redibility of the code.

I had totally forgotten about matrices. I seldom have a need to use them and just forget that the 42s can work on them directly. Since I have several subroutines that will need to operate on multiple variable lists, matrices may just be the way to go. I'll have to read up on them in the manual and give it a try. Thanks for reminding me of them.

Bill 12345


[ Return to Index | Top of Index ]

Go back to the main exhibit hall