Post Reply 
DB48X: HP48-like RPL implementation for DM42
07-17-2023, 06:27 AM
Post: #22
RE: DB48X: HP48-like RPL implementation for DM42
(07-16-2023 09:36 AM)Gilles Wrote:  Very promising and complementary to newRPL! That could make me buy a DM42 ;D

The work remains immense, but I suggest if possible integrating the local variables with the LSTO command as in newRPL, in complement of the syntax -> << >>

I've not looked in details at the implementation of local variables in newRPL, but I'm afraid I won't implement LSTO as described in their manual. You can, however, `STO` in an existing local.

The reason is that local variables in db48x are designed to be as efficient as the stack. Internally, they are like numbered registers. Each local access is a two-bytes opcode.

For example, << -> A B << B A >> >> will create two local names A and B. The two references that you see in the inner block are then turned into local(0) and local(1) respectively (so two bytes, one for 'ID_local", one for the index, which is one byte unless you declare more than 127 local variables in a single block, something that should work but that I frankly have not tested yet...). This means that evaluating local(0) is just an array index, there is no name lookup (name lookup was done at parsing time). Note that the index of a 'for' loop is also a local.

You can "simulate" the effect of LSTO with something like << 0 -> X << do-something 'X' STO do-something-else >> >>. In other words, you *can* store to a local variable, and it's much faster than store to a global variable, again because it's just an array access.

But this optimization, which I believe is really important, also means that the parser and renderer need to be aware of local names, so you cannot declare them anywhere.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: DB48X: HP48-like RPL implementation for DM42 - c3d - 07-17-2023 06:27 AM
DB48X v0.4.8 is out - c3d - 10-22-2023, 11:31 PM
Release v0.5.0: Statistics and flags - c3d - 11-20-2023, 08:57 AM
v0.6.5: Minor bug fixes - c3d - 02-11-2024, 11:23 PM
Release 0.7.1 "Whip" - Bug fixes - c3d - 03-04-2024, 12:46 AM
DB48X v0.7.4 release is out - c3d - 04-14-2024, 03:05 PM
DB48X v0.7.6: Solving menu - c3d - 05-13-2024, 12:04 AM



User(s) browsing this thread: