RPN-like STO/RCL on RPL calculator David Hayden Senior Member Posts: 528 Threads: 40 Joined: Dec 2008 11-13-2009, 10:07 PM One thing I missed when moving from a 41CV to a 50G was the ease of storing and recalling variables. To store 123 in register 01 on the 41CV you just type "123 STO 01" (6 keystrokes). You can even use the top two rows of keys as shortcuts for registers 01-10 so the keystroke count is really 5 (1 2 3 STO SIGMA+). On the 50G, the variables are named and they have to be quoted, so the same thing would be something like 1 2 3 ' alpha R 0 1 STO - a whopping 9 keys. Now it's true that once you've defined a variable, it's accessible from the VAR menu with one key to recall it and 2 keys to store into it (LS followed by the key for the variable), but if you aren't actually IN the VAR menu, then you add 3 keystrokes to get to the VAR menu and back (VAR to get there, LS (hold) PREV to get back). To get around this, I created the following UserRPL programs STOn and RCLn. If you type "123 1 STOn" then it stores 123 into variable R1. Similarly "1 RCLn" will recall variable R1. If you type "123 'myvar' STOn" then it behaves just like STO, storing 123 in 'myvar'. More specifically, STOn/RCLn examine the value on level 1 of the stack. If it's a positive integer or a real number greater than zero with no fractional part, then STOn/RCLn will store/recall the variable Rn where "n" is the value on level 1. If there are fewer than 2 values on the stack or if the conditions above aren't met, then STOn/RCLn just call STO/RCL. With this behavior, you can assign the programs to the STO and RCL keys and your calculator will behave the way I want it to... :) Here are the programs: ```« @ STOn/RCLn RPN-like STO and RCL functions @ If the stack depth is 2 or more @ and level 1 is a positive integer or real @ with no fractional part, then store @ level 2 in variable Rn where "n" is the @ integer on level 1. Pop 2 levels @ @ If the conditions aren't as mentioned above, then @ call STO. C-like pseudo code is: @ if (depth > 1 && @ (type == 0. && fractionalPart == 0 && value >= 0|| @ type == 028&& value >= 0) { @ construct string "Rn"; @ convert it to an identifier @ store it. @ } else { @ STO @ } @ The pseudo code relies on C's short-circuit @ "and" operation. I'll do short-circuit AND @ like this (for 'A == 0 && B == 1"): @ A 0 == @ IF DUP THEN @ B 1 == AND @ END DEPTH 1 > IF DUP THEN OVER TYPE 0. == @ Is it REAL? IF DUP THEN 3. PICK FP 0. == AND 3. PICK 0. Š AND END IF DUP NOT THEN DROP OVER TYPE 28. == IF DUP THEN 3. PICK 0 Š AND END END END AND IF THEN RI STR "'R" SWAP + "'" + OBJ END STO » 'STOn' STO @ Here is RCLn « DEPTH 0. > IF DUP THEN OVER TYPE 0. == @ Is it REAL? IF DUP THEN 3. PICK FP 0. == AND 3. PICK 0. Š AND END IF DUP NOT THEN DROP OVER TYPE 28. == IF DUP THEN 3. PICK 0 Š AND END END END AND IF THEN RI STR "'R" SWAP + "'" + OBJ END RCL » 'RCLn' STO ``` Stuart Sprott Junior Member Posts: 36 Threads: 7 Joined: Sep 2007 11-14-2009, 06:15 AM David, I have done much the same thing. I created a matrix called "Regs", it is a 32*1 matrix. That means there are 32 registers. You can make it whatever you like. When created it was full of zeros. Then I wrote two programs, STOi and RCLi. If you want to say store 2.5 into register 6, then key in 2.5 then enter 6 and run program STOi. If you want to recall the number in register 9, enter 9 press RCLi. These two programs are assigned to to keys I normally dont use. The two programs are listed below. STOi << > a b << Regs b a PUT 'Regs' STO >> >> RCLi << > a << Regs a GET >> >> Gerson W. Barbosa Posting Freak Posts: 2,761 Threads: 100 Joined: Jul 2005 11-14-2009, 07:17 AM A similar approach, from the HP-28S Owner's Manual, page 300: -------------------------------------------------------------------------------- Registers Versus Variables Fixed-stack calculators can deal efficiently only with real, floating-point numbers for which the fixed, seven-byte register structure of the stack and numbered data register memory is suitable (the HP-41 introduced a primitive alpha data object constrained to seven-byte format). The HP-28S replaces numbered data registers with named variables. Variables, in addition to having a flexible structure so that they can accomodate different object types, have names that can help you remember their contents more readily than can register numbers. If you want to duplicate numbered registers on the HP-28S, you can use a vector: `{ 50 } 0 CON 'REG' STO` creates a vector with 50 elements initialized to 0; `<< 'REG' SWAP GET >> 'NRCL' STO` creates a program NRCL that recalls the nth element from the vector, where n is a number in level 1; `<< 'REG' SWAP ROT PUT >> 'NSTO' STO ` creates the analogous store program NSTO. -------------------------------------------------------------------------------- David Hayden Senior Member Posts: 528 Threads: 40 Joined: Dec 2008 11-14-2009, 09:24 AM Quote: I have done much the same thing. I created a matrix called "Regs", it is a 32*1 matrix. That means there are 32 registers. You can make it whatever you like. When created it was full of zeros. Stuart, I considered this approach, but the values in a matrix must all be the same type, so you can't, for example, store a list in one position and a program in another. I could have gotten around this by using a list, but I thought that would be somewhat slower if the list was very large. Also, if you wanted to store in R100-R120, you'd have to create items 1-99 in the list anyway. Quote: Then I wrote two programs, STOi and RCLi. ... These two programs are assigned to to keys I normally don't use. I did something similar in an earlier version, but then it occurred to me that with a little extra code, the program could determine if it should do its thing or just call STO/RCL. Then I could assign it to the STO and RCL keys Obviously a lot of the code is in this functionality, so removing it will greatly reduce the size of the program. Paul Dale Posting Freak Posts: 3,229 Threads: 42 Joined: Jul 2006 11-14-2009, 06:29 PM How about a sysRPL version that takes the number as a postfix argument to STO & RCL? I.e. 123 STO 0 will store 123 in register 0. Then allow programs and algebraics after the STO & RCL :-) - Pauli « Next Oldest | Next Newest »

 Possibly Related Threads... Thread Author Replies Views Last Post Writing RPL programs on OS X Sean Freeman 18 2,451 11-30-2013, 03:59 PM Last Post: Sean Freeman 48G vs 49G+ User RPL Speed Comparison John Colvin 7 1,119 11-16-2013, 10:07 PM Last Post: Han RPL 32 David Hayden 4 936 11-11-2013, 11:34 AM Last Post: David Hayden [PRIME] RPN: another attempt at returning more than one value to the RPN stack Marcus von Cube, Germany 5 1,170 11-05-2013, 02:44 AM Last Post: Marcus von Cube, Germany HHC / HP Museum Programming Contest for RPN and RPL machines Gene Wright 18 2,337 09-22-2013, 09:39 AM Last Post: Miguel Toro HP Prime - How to STO in RPN mode? Javier Goizueta 10 1,249 08-18-2013, 10:24 PM Last Post: Xavier A. (Brazil) Another non-HP RPN vintage calculator joins the collection Michael de Estrada 2 934 07-23-2013, 04:10 PM Last Post: Walter B OT: RPN calculator/dmm by ESI Kees van der Sanden 2 793 05-25-2013, 01:38 PM Last Post: Kees van der Sanden "HP RPN Calculator Users" group on LinkedIn Philippe Lasnier 6 1,166 04-27-2013, 03:27 AM Last Post: BruceH RPL long vs. short names peacecalc 5 944 10-30-2012, 01:25 PM Last Post: peacecalc

Forum Jump: