Hi all,
I am looking for an implementation of the HP-41 Advantage Pac AIP function that I can use without the need to have the Advantage Pac installed? Is the code available?
Related question: what is the most efficient (synthetic) way to save and restore the current FIX decimal setting an an HP-41 if I want to implement this function myself?
Regards,
Arne
Hi, Arne:
I don't recall the exact specifics of how AIP works with all kinds of values in the X register, but some modification of this simple code I wrote for your sake will probably be what you need:
Stack contents
----------------------
X Y Z T L
----------------------
X Y Z T L
RCL d d X Y Z L recall all flags
X<>Y X d Y Z L bring back the former value in X
FIX 0 X d Y Z L specify no decimals
CF 29 X d Y Z L supress decimal point showing
INT IX d Y Z X truncate X to its integer part
ARCL X IX d Y Z X append it to the alpha register
Rdown d Y Z IX X bring back the flags
STO d d Y Z IX X restore all flags
X<> L X Y Z IX d restore the initial value of X
This code preserves the values in stack registers X,Y,Z that are there upon entry and leaves the integer part of the X value appended to the ALPHA register, without decimal point. Only T and LastX are lost and the display mode and number of decimal places are fully restored upon exit.
Best regards from V.
Edited: 7 Sept 2006, 9:36 a.m.
Valentin,
thanks a lot for your quick response and code! I suspected that a synthetic instruction or two would do the trick!
-- Arne
If you have the HP-41CX you can simply use RCLFLAG and STOFLAG to save and restore the FIX/SCI/ENG settings, along with a number of other settings as well. I believe these functions operate on flags 0 thru 43 which include the display setting.
Tom,
I just checked your method and it works like a champ. To display integers in the alpha registers you can use RCLFLAG and STOFLAG:
RCLFLAG
"N="
FIX 0
CF 29
ARCL Y
STOFLAG
RDN
PROMPT
The above code works using the stack to store the states of the flags.
Here is a version as a subroutine that preserves the stack using the LastX register as a temporary storage:
LBL "SHOWINT
RUP
STO ST L
RDN
RCLFLAG
FIX 0
CF 29
ARCL Y
STOFLAG
X <> ST L
RDN
PROMPT
RTN
Here is an example that uses the above code:
...
"N=
XEQ "SHOWINT
...
Namir
Edited: 8 Sept 2006, 2:10 a.m.