HP Forums
Help with 42S Programming - Printable Version

+- HP Forums (https://archived.hpcalc.org/museumforum)
+-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html)
+--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html)
+--- Thread: Help with 42S Programming (/thread-54686.html)



Help with 42S Programming - Bill (Smithville, NJ) - 04-02-2004

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 - Vieira, Luiz C. (Brazil) - 04-02-2004

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 [1×3] 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 - Bill (Smithville, NJ) - 04-03-2004

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