Global Numbered Registers - Hewlett Packard

This is a discussion on Global Numbered Registers - Hewlett Packard ; FOR THE 48 SERIES ONLY! The following programs provide a user-defined number of global, numbered memory registers. I submiited them to hpcalc, but that site hasn't been updated in months. EXAMPLES: "ABCDE" 2 TSTO @ Store "ABCDE" in register 2 ...

+ Reply to Thread
Results 1 to 10 of 10

Thread: Global Numbered Registers

  1. Global Numbered Registers

    FOR THE 48 SERIES ONLY!

    The following programs provide a user-defined number of global, numbered
    memory registers. I submiited them to hpcalc, but that site hasn't been
    updated in months.

    EXAMPLES:

    "ABCDE" 2 TSTO @ Store "ABCDE" in register 2
    5 TRCL @ Recall the value stored in register 5

    Any type of object can be stored in these registers. Complete type
    checking is performed; objects that can't be dealt with are passed to
    the built-in functions for handling.

    TSTO and TRCL are designed to be direct key replacements for STO and RCL
    respectivly.

    STACK DIAGRAMS:

    obj any object
    % real number

    TSTO ( obj % -> obj ) or ( obj % -> )
    If obj is library data or % is not a real, passes arguments to the
    built-in STO routine. Otherwise, stores obj in register % and leaves obj
    on the stack. Only the integer part of % is used and numbers outside the
    legal range will throw a "Bad Argument value" error.

    TRCL ( % -> obj )
    If % is not a real, passes argument to the built-in RCL routine.
    Otherwise, recalls the obj stored in register %. Only the integer part
    of % is used and numbers outside the legal range will throw a "Bad
    Argument value" error.

    TVIEW ( -> obj ) or ( -> )
    Shows a standard choose box listing the register numbers and what they
    contain. Use up/down keys to move selection. Pressing enter copies the
    selected register's contents to the stack. ON cancels.

    TSIZE ( % -> )
    Sets the number of registers to use. The registers are numbered from 0,
    so 10 TSIZE would give ten registers numbered 0-9 (the default).
    WARNING: Using TSIZE will clear all the temporary registers.

    TPUR ( -> )
    Purges the variable used to store the registers. Use this before
    uninstalling TMEM

    @ TSTO
    \<<
    IF
    OVER TYPE 16 == @ If lvl 2 is library data
    OVER TYPE OR @ or lvl 1 is not real
    THEN
    STO 0 DOERR @ Use normal STO comand
    END

    IF
    # 64037h SYSEVAL VARS @ Recall VARS of hidden dir
    'STRG' POS NOT @ If 'STRG' is not present
    THEN
    10 TSIZE @ Allocate new 'STRG'
    END

    IP 'STRG' # 64023h SYSEVAL DROP @ Recall 'STRG' from hidden dir
    IF
    DUP2 OVER 0 < @ If index < 0
    ROT ROT SIZE \>= OR @ or index >= size of list
    THEN
    DROP # 203h DOERR @ Throw "Bad Value" error
    END

    SWAP 1 + 3 PICK PUT @ Finally PUT value in list
    'STRG' # 64078h SYSEVAL @ and STO it in hidden dir
    \>>

    @ TRCL
    \<<
    IF
    DUP TYPE @ If lvl 1 is not real
    THEN
    RCL 0 DOERR @ Use normal RCL comand
    END

    IF
    # 64037h SYSEVAL VARS @ Recall VARS of hidden dir
    'STRG' POS NOT @ If 'STRG' is not present
    THEN
    1 ALOG TSIZE @ Allocate new 'STRG'
    END

    IP 'STRG' # 64023h SYSEVAL DROP @ Recall 'STRG' from hidden dir
    IF
    DUP2 OVER 0 < @ If index < 0
    ROT ROT SIZE \>= OR @ or index >= size of list
    THEN
    DROP # 203h DOERR @ Throw "Bad Value" error
    END

    SWAP 1 + GET @ Finally get the value
    \>>

    @ TVIEW
    \<<
    IF
    # 64037h SYSEVAL VARS @ Recall VARS of hidden dir
    'STRG' POS NOT @ If 'STRG' is not present
    THEN
    1 ALOG TSIZE @ Allocate new 'STRG'
    END

    "Items in storage"
    'STRG' # 64023h SYSEVAL DROP @ Recall 'STRG' from hidden dir
    1
    \<<
    RCLF 0 FIX NSUB @ Build list entries for CHOOSE
    1 - " " + SWAP STOF
    OVER \->STR + SWAP 2
    \->LIST
    \>>
    DOSUBS 1 CHOOSE DROP
    \>>

    @ TSIZE
    \<<
    1 2 \->LIST 0 CON @ Build constant array
    OBJ\-> @ Decompose array
    HEAD \->LIST @ Build list
    'STRG' # 64078h SYSEVAL @ Store in hidden dir
    \>>

  2. Re: Global Numbered Registers

    On Thu, 21 Jun 2007 11:06:06 -0500:

    Why not allow both real and complex numbers?
    (like the 15C, 42S, or the non-existent 35s

    Or even storing arbitrary object types?

    > FOR THE 48 SERIES ONLY!


    The following works on all series 48/49/50
    (use "list" form on 48 to allow arbitrary objects)

    @ Create list of 10 items (can be arbitrary types)
    0 10 NDUPN \->LIST 'A' STO

    @ Or, create array of numeric/complex/algebraic items
    @ (only real/complex in 48S[X]/G[X/+])
    0 10 NDUPN \->ARRY 'A' STO

    @ Store
    123 'A(5)' STO
    'COS(X+8)' 'A(3)' STO

    @ Evaluate (usually just recalls)
    'A(5)' EVAL
    'A(3)' EVAL

    @ Recall without evaluating
    @ (shorter than above, actually)
    A 3 GET

    @ Another way to store
    'A' 2 'X+Y' PUT

    For NDUPN on HP48S[X]/G[X/+], see:
    "UserRPL commands from 49/50 for 48[S/G]"
    http://groups.google.com/group/comp....66a46c7ad0ad34

    [r->] [OFF]

  3. Re: Global Numbered Registers

    John H Meyers wrote:
    > Why not allow both real and complex numbers?
    > (like the 15C, 42S, or the non-existent 35s
    > Or even storing arbitrary object types?


    Huh? You can store anything you like in the registers. There are no type
    restrictions. I wanted to model these after the way that the 15C and
    other calcs of this ilk stored things.

    >> FOR THE 48 SERIES ONLY!


    The only reason for this is the SYSEVALs. Equivalent entry points in the
    49/50 series could be used.

    > @ Store
    > 'COS(X+8)' 'A(3)' STO
    > @ Evaluate (usually just recalls)
    > 'A(5)' EVAL
    > @ Recall without evaluating
    > A 3 GET
    > @ Another way to store
    > 'A' 2 'X+Y' PUT


    Obviously this is the correct way to do this in a *program*, however my
    routines are designed to be run from the *keyboard*. 123 5 STO is alot
    faster to type than 123 'A(5)' STO (I have TSTO assigned to the STO key).

  4. Re: Global Numbered Registers

    Hi Robert,

    "Robert Ryan" schrieb im Newsbeitrag
    news:SqKdnSqft5fhcufbnZ2dnUVZ_tSunZ2d@giganews.com ...
    > John H Meyers wrote:
    > [..]
    > Obviously this is the correct way to do this in a *program*, however my
    > routines are designed to be run from the *keyboard*. 123 5 STO is alot
    > faster to type than 123 'A(5)' STO (I have TSTO assigned to the STO key).
    >

    With some effort, you could even make the assigned key
    prompt for digits like in the HP-41 ;-)

    Raymond



  5. Re: Global Numbered Registers

    On Thu, 21 Jun 2007 16:36:53 -0500, Robert Ryan wrote:

    > You can store anything you like in the registers.
    > There are no type restrictions.


    Sorry -- I misread in haste.

    > I wanted to model these after the way that
    > the 15C and other calcs of this ilk stored things.


    Indeed you did; I basically thought to just illustrate
    some lesser known abilities of the built-in
    STO and EVAL (but alas not RCL),
    which can accept 'A(n)' on level 1;
    also GET and PUT, which can accept a global name,
    in place of a list or array,
    to perform in storage the same as could be done
    with the list or array on the stack.

    > "For the 48 series only!" -- for the SYSEVALs.
    > Equivalent entry points in the 49/50 series could be used.


    You might like to use an independently called handy program
    which can be defined once, then used repeatedly, e.g.

    Hidden STO, Hidden RCL, Hidden VTYPE, Hidden EVAL, etc.,
    where 'Hidden' is a program which performs the next command
    in the context of the "Hidden directory,"
    where you keep your register list.

    Universal (all-model) UserRPL versions of 'Hidden' and 'Here'
    (the latter to restrict commands to operate in the
    current directory, without the default "upward searching"
    for variable names in higher directories) may be found at
    http://groups.google.com/group/comp....188c83a07445bd

    SysRPL versions would be :: COLA WithHidden ;
    and :: COLA DoHere: ;

    > I have TSTO assigned to the STO key.


    I see; that's why you needed to distinguish other args
    from numeric args, and treat libraries differently
    ("library data" is actually yet another object type 26)

    One could also try something like the following,
    which first try normal STO/RCL, and then try
    "register" STO/RCL only if that fails
    (which it will if level 1 is numeric
    and level 2 is not a library for STO):

    @ obj num [store]
    \<< -55 CF IFERR STO THEN 'REGS' SWAP ROT Hidden PUT END \>>
    'RSTO' STO

    @ num [recall]
    \<< -55 CF IFERR RCL THEN 'REGS' SWAP Hidden GET END \>>
    'RRCL' STO

    @ value numregs [create] (persists even after warmstart)
    \<< NDUPN \->LIST 'REGS' Hidden STO \>> 'RMAKE' STO

    @ "Any calc" HP48/49/50
    \<< RCLF SIZE 3 < #64037h #370C3h IFTE
    #6FD1h SYSEVAL SYSEVAL \>> 'Hidden' STO

    The usual cautions apply (the exact hex values
    and correct program entry are critical;
    make a memory backup before use, in case of crash).

    [r->] [OFF]

  6. Re: Global Numbered Registers

    [continuing some alternative programs]

    > @ obj num [store]
    > \<< -55 CF IFERR STO THEN 'REGS' SWAP ROT Hidden PUT END \>>
    > 'RSTO' STO


    If you want to keep a copy on the stack (for manual use)
    of an item stored in a numbered "register,"
    insert OVER SWAP after THEN

    @ Display "registers" (optionally returning one to stack)
    \<< "'REGS'" DUP STR\-> Hidden RCL
    1 \<< NSUB R\->I ": " + OVER \->STR + SWAP 2 \->LIST \>>
    DOSUBS 1 CHOOSE DROP \>> 'RVIEW' STO

    In my 48G, I use STD for the non-existent 'R\->I'
    but for this particular function,
    to preserve any original display modes,
    one could use RCLF SWAP STD ": " + SWAP STOF
    in place of R\->I ": " +

    Yes, there was no "register zero" in this set of programs
    (but you can offset every numeric arg by 1, if you like,
    after THEN, to acccept zero as a register number)

    [r->] [OFF]

  7. Re: Global Numbered Registers

    \<< 'REGS' Hidden PURGE \>> 'RPURG' STO

  8. Re: Global Numbered Registers

    John H Meyers wrote:
    > also GET and PUT, which can accept a global name,


    This brings up a misnomer that has always irritated me - 'global names'
    are NOT global! This was one of the motivations for these routines, I
    wanted some truly global storage locations.

    > Universal (all-model) UserRPL versions of 'Hidden' and 'Here'
    > (the latter to restrict commands to operate in the
    > current directory, without the default "upward searching"
    > for variable names in higher directories) may be found at
    > http://groups.google.com/group/comp....188c83a07445bd


    Thanks for the link

    > One could also try something like the following,
    > which first try normal STO/RCL, and then try
    > "register" STO/RCL only if that fails
    > (which it will if level 1 is numeric
    > and level 2 is not a library for STO):


    The trouble with doing it that way is if args are passed that aren't
    valid for either option, e.g.

    "foo" "bar" TSTO

    Which would leave garbage on the stack and throw a PUT error instead of
    a STO error. I'd want to do the 'argument out of bounds' check anyway,
    so the code savings would be minimal in any case.

  9. Re: Global Numbered Registers

    On Fri, 22 Jun 2007 10:26:24 -0500, Robert Ryan:

    > This brings up a misnomer that has always irritated me -
    > 'global names' are NOT global!


    Everything is in regard to a context;
    here it means "global" in the sense that
    all program levels have access to the same,
    more permanent, stored variables,
    whereas "local" variables exist only in a smaller context,
    within the scope of a particular "temporary environment."

    > This was one of the motivations for these routines,
    > I wanted some truly global storage locations.


    Variables in HOME (if named uniquely) are also "globally"
    accessible, and "system-level" STO commands will actually
    manage to store into an existing variable in HOME,
    even if executed in a lower directory,
    but of course the "hidden directory"
    (also requiring some system-level help to access)
    is yet another place which can be used globally.

    Any "global" reference of course also requires one
    to be on the alert for possible name conflicts --
    an issue avoidable through use of multiple directories --
    which highlights the ever present potential conflict
    between local vs. global issues, just as also comes up
    in regard to all situations in life.

    > The trouble with [IFERR STO THEN special sto END]
    > is if args are passed that aren't valid for either option, e.g.
    > "foo" "bar" TSTO, it would leave garbage on the stack

    [only the name of the variable holding the "registers"]
    > and throw a PUT error instead of a STO error.


    So you wouldn't know what was wrong
    with what you just manually invoked, nor that UNDO
    would restore the original args anyway?

    > I'd want to do the 'argument out of bounds' check anyway


    The user-level PUT command certainly does check by itself,
    and gives "Bad Argument Value" for it,
    which can only mean an "out of bounds" error.

    By the way, Raymond, how would you know,
    if STO or RCL were pressed with a 'name' on the stack,
    whether to perform a built-in immediate STO/RCL,
    or to prompt the user for a not-yet-supplied register number?

    Overloading the STO/RCL keys with mixed "postfix" and "prefix"
    operations could thus require a bit of psychic effort, too

    [r->] [OFF]

  10. Re: Global Lettered Registers

    "Variety's the very spice of life
    That gives it all its flavor"
    http://en.thinkexist.com/quotes/william_cowper/

    "And now for something completely different"
    [Monty Python]

    The following puts storage registers on menu labels,
    rather than as numbers, and opens up the ability
    to perform "storage register arithmetic"

    It creates a global temporary directory,
    or re-uses one that has already been created.

    You can use the VAR menu for normal STO & RCL
    (left-shift does STO and right-shift does RCL),
    or you can do the same with the optional "custom" menu,
    which also contains the "storage register arithmetic"
    commands (press NXT); unshifted menu keys in the VAR menu
    will evaluate the given variable, but unshifted keys
    in the "custom" menu instead put the variable's name
    on the stack, as needed for "storage arithmetic" commands.

    To review the contents of all variables at once,
    press VAR then right-shift, cursor-down ("Review").

    On "ARM series" HP48/49/50, you may insert PUSH
    at the very beginning, to remember your original
    directory path, then perform POP to return to that path.

    On your HP17B (or similar type) financial calc with solver,
    you can create a set of independent storage variables,
    to which storage register arithmetic can be applied,
    just by entering a simple formula,
    such as: A*B*C*D*E*F*0 [try it!]

    But on HP48/49/50:

    \<< { A B C D E F G H } 'Temp'
    DUP VTYPE 15 \=/ { HOME DUP CRDIR } IFT EVAL {
    { A { \<< 'A' \>> \<< 'A' STO \>> \<< 'A' RCL \>> } }
    { B { \<< 'B' \>> \<< 'B' STO \>> \<< 'B' RCL \>> } }
    { C { \<< 'C' \>> \<< 'C' STO \>> \<< 'C' RCL \>> } }
    { D { \<< 'D' \>> \<< 'D' STO \>> \<< 'D' RCL \>> } }
    { E { \<< 'E' \>> \<< 'E' STO \>> \<< 'E' RCL \>> } }
    { F { \<< 'F' \>> \<< 'F' STO \>> \<< 'F' RCL \>> } }
    { G { \<< 'G' \>> \<< 'G' STO \>> \<< 'G' RCL \>> } }
    { H { \<< 'H' \>> \<< 'H' STO \>> \<< 'H' RCL \>> } }
    STO+ STO- STO* STO/ } MENU -55 CF IFERR ORDER
    THEN 0 OVER STO ORDER END \>> HOME 'REGS' STO

    "Roger, Wilco, Over & Out" [WWII film script mistake]

    http://en.wikipedia.org/wiki/Voice_procedure
    http://www.airsoftretreat.com/radiocomm.asp

    [r->] [OFF]

+ Reply to Thread