Free42 with big stack, test version
|
01-30-2021, 01:18 AM
Post: #1
|
|||
|
|||
Free42 with big stack, test version
I finished implementing the big stack logic in Free42. This isn't an official release; depending on the feedback I get, additions and changes to the instruction set are still possible. But I think this is useful enough as it is to share it around. Comments welcome!
https://thomasokken.com/free42/download/...indows.zip I made some changes to the FCN catalog: because the number of additional functions in Free42, compared to the HP-42S, keeps getting larger, the FCN catalog became more and more messy. Because what to do: keep it strictly alphabetic, or group the new functions logically, but if the latter, how is that grouping obvious? So I split off the extensions into sections of their own, which are in a new row at the top level of the CATALOG menu. The new functions in the STK section are: NSTK N-level Stack. Turns on big stack mode. 4STK 4-level Stack. Turns off big stack mode, returning to the TZYX stack. LNSTK and L4STK Local N-level / 4-level Stack. These switch to N-level or 4-level stack mode, respectively, but in addition, they automatically restore the previous stack mode when the current function returns. Further, L4STK saves levels 5 and up in a hidden list, and also restores them when the previous stack mode is restored. (The non-local 4STK function simply discards levels 5 and up.) All of these functions are no-ops when the selected stack mode is already active. DEPTH Returns the current stack depth. DROP and DROPN n Drops level 1, or levels 1..n. In 4-level mode, the stack is replenished with zeroes from the top. DUP and DUPN n Duplicates level 1, or levels 1..n. In 4-level mode, n must be 2 or less. R↓N n and R↑N n Rolls levels 1..n down or up. Note that the standard R↓ and R↑ are equivalent to R↓N depth and R↑N depth. PICK n and UNPICK n Gets the object from level n, or puts an object into level n. Note that UNPICK consumes the contents of level 1, unlike STO, and n refers to the stack level number after X has been dropped. The effect is that you can modify an object at level n by doing PICK n, <modify the object>, UNPICK n, without having to add 1 to the level number for UNPICK. Also note that this is similar to the behavior of PICK and UNPICK in RPL. Here's a fairly useless but hopefully enlightening example: Code: 00 { 31-Byte Prgm } This uses the big stack to implement the factorial recursively, and because of how it uses LNSTK, you can call it even if you're in 4-level mode. Although not shown here, the big stack is compatible with FUNC as well. Further, it is possible to combine FUNC and LNSTK or L4STK in one function; the only restriction is that FUNC must be called before LNSTK / L4STK. |
|||
01-30-2021, 02:13 AM
(This post was last modified: 01-30-2021 04:35 PM by Gene.)
Post: #2
|
|||
|
|||
RE: Free42 with big stack, test version
Nice enhancements, thanks for these Thomas.
Although historically pure RPN, Free42 is moving between RPL and RPN. Is this RPM ? --Bob Prosperi |
|||
01-30-2021, 07:37 AM
Post: #3
|
|||
|
|||
RE: Free42 with big stack, test version
Do the commands that take an argument work with IND etc., too? (Can’t test)
Werner 41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE |
|||
01-30-2021, 12:23 PM
Post: #4
|
|||
|
|||
RE: Free42 with big stack, test version
Yes, they do.
|
|||
01-30-2021, 01:40 PM
Post: #5
|
|||
|
|||
RE: Free42 with big stack, test version | |||
01-30-2021, 01:58 PM
Post: #6
|
|||
|
|||
RE: Free42 with big stack, test version
Added builds for Android, Linux, and MacOS.
https://thomasokken.com/free42/download/test/ |
|||
01-30-2021, 02:04 PM
Post: #7
|
|||
|
|||
RE: Free42 with big stack, test version
Hi Thomas,
As you know, this feature was not on my wishlist, i think 4-level RPN with automatic T replication is fine as it is, so I'm rather indifferent, and much, much more looking forward to seeing the equations feature This being said, I welcome the new CATALOG to group the new features by category. This is a great idea which integrates fine the 42S without breaking anything. Just one point, when you select 4-level or N-STACK, I think it could be good to have a toggle square to see what it is the current setting, just like the "MODE" switches, and to put them next to each other. My 2 cents. Cheers, Vincent |
|||
01-30-2021, 02:11 PM
Post: #8
|
|||
|
|||
RE: Free42 with big stack, test version
(01-30-2021 02:04 PM)Vincent Weber Wrote: As you know, this feature was not on my wishlist, i think 4-level RPN with automatic T replication is fine as it is, so I'm rather indifferent, and much, much more looking forward to seeing the equations feature I feel the same way, but the big stack is an important step on the way to implementing the other advanced features on my to-do list. (01-30-2021 02:04 PM)Vincent Weber Wrote: Just one point, when you select 4-level or N-STACK, I think it could be good to have a toggle square to see what it is the current setting, just like the "MODE" switches, and to put them next to each other. My 2 cents. I will definitely make NSTK and 4STK display that way if I add them to the MODES menu, but in CATALOG, there is no provision for that kind of behavior, that's really just a list of functions. I'm even considering adding an annunciator for big stack mode, because it is such an important setting and because knowing which mode is in effect is so important because it breaks backward compatibility with a lot of programs. But at least you can tell at a glance just by looking how the X register is labeled! |
|||
01-30-2021, 02:20 PM
Post: #9
|
|||
|
|||
RE: Free42 with big stack, test version
Something just occurred to me - are the Stack Mode commands programmable, and if so, I presume the same rules (e.g. auto-populating the stack values, etc.) are followed?
--Bob Prosperi |
|||
01-30-2021, 02:25 PM
Post: #10
|
|||
|
|||
RE: Free42 with big stack, test version
(01-30-2021 02:20 PM)rprosperi Wrote: Something just occurred to me - are the Stack Mode commands programmable, and if so, I presume the same rules (e.g. auto-populating the stack values, etc.) are followed? All the new functions are programmable, but I don't understand the second part of your question... |
|||
01-30-2021, 02:32 PM
Post: #11
|
|||
|
|||
RE: Free42 with big stack, test version
(01-30-2021 02:25 PM)Thomas Okken Wrote:(01-30-2021 02:20 PM)rprosperi Wrote: Something just occurred to me - are the Stack Mode commands programmable, and if so, I presume the same rules (e.g. auto-populating the stack values, etc.) are followed? Great, thanks for confirming. The second part was rather dumb on my part, I was thinking of behavior of DROP, but not really related to my question. Postfix RPL commands feel strange... --Bob Prosperi |
|||
01-30-2021, 03:04 PM
Post: #12
|
|||
|
|||
RE: Free42 with big stack, test version | |||
01-30-2021, 08:42 PM
(This post was last modified: 01-30-2021 08:43 PM by Steve Simpkin.)
Post: #13
|
|||
|
|||
RE: Free42 with big stack, test version
This is freaking amazing! You have managed to implement the elegance of RPN key-step programming with one of the best features (and my favorite) of RPL, an unlimited stack. Thank you Thomas!
:O [attachment=9056] |
|||
02-03-2021, 01:01 PM
Post: #14
|
|||
|
|||
RE: Free42 with big stack, test version
will DROP and UNPICK save the X-reg (stack level 1) to LASTX?
Werner 41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE |
|||
02-03-2021, 01:25 PM
Post: #15
|
|||
|
|||
RE: Free42 with big stack, test version
(02-03-2021 01:01 PM)Werner Wrote: will DROP and UNPICK save the X-reg (stack level 1) to LASTX? Ahhh... really good questions Werner! I hadn't thought about interaction between RPL-type commands and LASTX. I guess one could make a case for multiple kinds of behavior here; CLX does not affect LASTX, but DROP does (via UNDO). Which do you think is "right", freely admitting there can be no correct answer since this new behavior is unprecedented. Do you lean towards RPN or RPL behavior? --Bob Prosperi |
|||
02-03-2021, 01:44 PM
(This post was last modified: 02-03-2021 01:46 PM by Thomas Okken.)
Post: #16
|
|||
|
|||
RE: Free42 with big stack, test version | |||
02-03-2021, 02:17 PM
Post: #17
|
|||
|
|||
RE: Free42 with big stack, test version
Maybe not, but I just encountered a situation that needed to 'DROP' X and save it in L ;-)
I think it's ok the way it is: DROP and UNPICK should be regarded as stack-only commands that do not affect LASTX, like DUP and PICK etc. After all, if you do need to save X to L, it is but a simple matter of doing a STO ST L before the command. More questions..: Can you, in unlimited mode, still refer to the first 4 levels with the regular XYZT commands? What if there are only 2 levels and you do STO ST T? Does ENTER still work as before? does DUP disable stack lift? (probably not, judging from your example) (my only means of running Free42 is under iOS, and DM42 ;-) Thanks for your reply, Werner 41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE |
|||
02-03-2021, 02:27 PM
Post: #18
|
|||
|
|||
RE: Free42 with big stack, test version
My opinion is just that...
I like Werner's idea of RPL style behavior that the USER can override with RPN commands if desired. If you want an RPL command to affect LASTX, then the STO ST L is a great thing to execute on the line before the RPL style command. |
|||
02-03-2021, 02:43 PM
Post: #19
|
|||
|
|||
RE: Free42 with big stack, test version
I think "no" is better too. Although one can think of scenarios where this could be useful (Werner already has!) I think keeping FREE42 RPN-like in all other ways makes the most sense. RPL-like behavior (e.g. full UNDO) can't realistically be implemented anyhow, without inventing a whole bunch of new cases and rules.
--Bob Prosperi |
|||
02-03-2021, 03:28 PM
(This post was last modified: 02-03-2021 03:32 PM by Thomas Okken.)
Post: #20
|
|||
|
|||
RE: Free42 with big stack, test version
(02-03-2021 02:17 PM)Werner Wrote: Can you, in unlimited mode, still refer to the first 4 levels with the regular XYZT commands? Yes. (02-03-2021 02:17 PM)Werner Wrote: What if there are only 2 levels and you do STO ST T? Then levels 3 and 4 will be created, level 3 being filled with 0. If you do RCL ST T when there are only 2 levels, you'll get Nonexistent. (02-03-2021 02:17 PM)Werner Wrote: Does ENTER still work as before? Yes. Or rather, the ENTER function still works as before. In big stack mode, the ENTER key behaves differently: if pressed while entering a number, it terminates number entry but doesn't duplicate anything; when not entering a number, it performs DUP. (02-03-2021 02:17 PM)Werner Wrote: does DUP disable stack lift? No. If fact, the only difference between ENTER and DUP is the state of the stack lift flag after they execute. (02-03-2021 02:17 PM)Werner Wrote: (my only means of running Free42 is under iOS, and DM42 ;-) Whoa! Not even an old PC running Linux? |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 4 Guest(s)