HP Forums
41CL function request - is this possible? If so, how? - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: Not HP Calculators (/forum-7.html)
+--- Forum: Not quite HP Calculators - but related (/forum-8.html)
+--- Thread: 41CL function request - is this possible? If so, how? (/thread-1990.html)



41CL function request - is this possible? If so, how? - Gene - 08-18-2014 08:43 PM

Here’s what I’d like to see how to do on the 41CL. Not sure it can be done? Ha ha.

I have one or more ROMs plugged into port 4, upper, lower or one in both ports (i.e., an 8K, two page rom). I’m using port 4 as an example. Ideally, it could work anywhere.

1) I want to be able to programmatically unplug whatever is in port 4.
2) I want to plug another ROM in and execute a function in that newly plugged in ROM.
3) And then I want to have the program restore whatever was plugged in before.

And, I’d really like to have this occur without the program having to be aware of what is presently in port 4.

For example, I like the RF (Reset Flags) routine in the PPCM rom. It allows me to clean up the

I’d like a program to do something like this:

01 LBL Blah
02 SAVEPG4
03 ALPHA PPCM
04 PLUG4
05 XEQ RF
06 RETPG4

which would leave the 41CL in exactly the original state, whatever that was. Essentially, it would unplug whatever was in there, allow you to execute a function, subroutine, etc., in a newly plugged in ROM image, and then restore whatever was plugged in previously.

Alternatively, some function could save ALL pages from 8 to F someplace, and another function could then plug them all in again.

Does what I hope to do make sense?

If so, the next question then … Is this possible?


RE: 41CL function request - is this possible? If so, how? - Ángel Martin - 08-19-2014 05:02 AM

yes it's possible, even relatively simple:

1. YFNP setup. Using PLUGG? in the PowerCL to retrieve the ROM id# (or location address if it's in sRAM) to ALPHA. This you'd need to save it for later (the final re-plug step). It requires that you know if the currently plugged module is 4k or 8k though, as PLUGG? works at the page level. If the initial module was in RAM the last plug step needs to use the retrieved address and the "-RAM" token in alpha as syntax. For that final step it's probably better to use PLUGG (in the PowerCL) with the page# as parameter, instead of the port-dependent PLUG1/2/3/4/U/L functions.

2. YFNX setup. Using PLUG with the string "?xxx - pg#" retrieves the ROM id# plugged to the port (even if it's an 8k and that's the upper page). Much easier this way, as it works on the mnemonic rather than the location addresses.

Depending on how general-purpose you want this to be the logic would need to deal with the few scenarios - like 4k, 12k, or even bigger for both the current ROM and the one you want to use only temporarily. Like-to-like's would be easy, but if the "guest" module has a bigger footprint it may displace some others in the original configuration...

Another approach is using the alternate MMU configurations - you have three setups or "personalities", with functions STOCFG, RCLCFG and EXCFG to control the active one.


RE: 41CL function request - is this possible? If so, how? - Ángel Martin - 08-19-2014 11:08 AM

Well, I didn't remember that PLUGG? is non-programmable so the above description for the YFNP case is obviously wrong. To redeem myself here's a short routine to accomplish the task in such case:

Since TF in the AMC_OS/X does the same as IF and I know you have it permanently on your system, let's assume we want to use a function from the 4TBX module, which will temporarily be plugged in page 14 (E). Put the pg# in X and run:

01 LBL "GENE1"
02 4
03 WSIZE - sets word size as single char
04 X<>Y - bring pg# back to X
05 "8040" - start building the syntax
06 ARCLH - append page# in hex
07 "|-0-0000" - complete syntax for YPEEK
08 YPEEK - read MMU entry
09 ASHF - clean the address up
10 ATOX
11 ATOX
12 ADRID - get ROM id# (if in flash)
13 ASTO 00 - save ROM id# for later
14 "4TBX"
15 RCL Z - bring pg# back to X
16 PLUGG - toolbox4 is now plugged
17 ..... - execute your functions, leaving pg# in x at end .....
18 CLA - clear alpha
19 ARCL 00 - recall ROM id# (assumed in Flash)
20 PLUGG - plug it back
21 END


Compared to this, the YFNX scenario is a vast improvement:

01 LBL "GENE2"
01 "?XXX E"
02 PPLUG
03 ASTO 00
04 "4TBX E"
05 PPLUG
06 ..... - do your busines as above...
07 CLA
08 ARCL 00
09 PPLUG
10 END.

Here you go, no limitation as to the module footprints (with the caveats mentioned in the previous post), nor do you have to worry about the stack contents at all.

Sorry about the glitch, hope this clarifies anyway.

Edited to reflect Monte's comment below.


RE: 41CL function request - is this possible? If so, how? - Monte Dalrymple - 08-19-2014 02:20 PM

(08-19-2014 11:08 AM)Ángel Martin Wrote:  ...
Compared to this, the YFNX scenario is a vast improvement:

01 LBL "GENE2"
01 "?XXX E"
02 PLUG
03 ASTO 00
04 "4TBX E"
05 PLUG
06 ..... - do your busines as above...
07 CLA
08 ARCL 00
09 PLUG
10 END.

Here you go, no limitation as to the module footprints (with the caveats mentioned in the previous post), nor do you have to worry about the stack contents at all.

Sorry about the glitch, hope this clarifies anyway.

One correction:
Steps 2, 5 and 9 should use PPLUG, the programmable version of the Plug function.

Monte