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