Help with 42S Programming



#4

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


#5

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)


#6

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


Possibly Related Threads...
Thread Author Replies Views Last Post
  HP 42s programming help for novice Carl D (new) 4 1,148 02-02-2013, 11:39 PM
Last Post: Mike Morrow
  Re: RPN Programming exercise (HP-42S) Gerson W. Barbosa 1 748 02-27-2012, 05:51 PM
Last Post: Marcus von Cube, Germany
  RPN Programming exercise (HP-42S) Gerson W. Barbosa 71 8,752 02-26-2012, 11:48 AM
Last Post: Valentin Albillo
  42s questions and 42s vs 35s snaggs 13 3,384 09-19-2011, 02:44 AM
Last Post: snaggs
  Programming HP-42S Howard Jones 2 735 10-17-2009, 06:47 PM
Last Post: Howard Jones
  HP 42S Programming Howard Jones 3 883 10-08-2009, 11:21 AM
Last Post: Vieira, Luiz C. (Brazil)
  Book for learning 41/42s programming? Keith Beyer 8 1,590 11-14-2008, 09:12 AM
Last Post: Nigel J Dowrick
  HP-42S, 41CX and synthetic programming thoughts Vincent Weber 0 602 06-25-2008, 09:13 AM
Last Post: Vincent Weber
  Re: 42S programming ECL 5 1,110 02-24-2007, 01:09 AM
Last Post: ECL
  42s programming tech alum 2 730 02-21-2007, 12:40 AM
Last Post: Karl Schneider

Forum Jump: