Post Reply 
newRPL - build 1255 released! [updated to 1299]
12-27-2019, 05:32 PM
Post: #633
RE: newRPL - build 1255 released! [updated to 1299]
I updated all ROMs to build 1323.
It fixes a few bugs and introduces 2 new assembly-like commands:
SGET and SPUT (as in Stack GET and Stack PUT).

Playing with the N-queens benchmark I realized access to the stack was always in hard-coded terms (using the pseudo registers S1..S7) and there was no indexed access to the stack.
SGET/SPUT use the stack as a vector of objects:

SGET.lvl --> Reads the stack at level lvl, where 'lvl' can be a register, a literal or a stack reference to an index number.
SPUT.lvl.A --> Stores A into stack level 'lvl'. Both A and 'lvl' can be anything.

With these 2 commands, indirect access to the stack is provided.

I used it to code one more example:
Code:

«
:CLR.A.8
:PUSH.A.8

:CMP.B.8
:LOOP.NE
::
    :B+=1
    :SPUT.B.8
    :CMP.2.1
    :LOOP.NE
    ::
        :A+=1
        :C=B
        :CMP.C.1
        :LOOP.GT
        ::
            :C-=1
            :D=SGET.B
            :D-=SGET.C
            :CMP.D.0
            :E=CHK.EQ
            :F=B-C
            :G=ABS.D
            :CMP.G.F
            :F=CHK.EQ
            :OR.E.F
            :SKIP.EQ
            ::
                :C=0
    
                :F=SGET.B
                :F-=1
                :SPUT.B.F
    
                :CMP.F.0
                :LOOP.EQ
                ::
                    :B-=1
                    :F=SGET.B
                    :F-=1
                    :SPUT.B.F
                    :CMP.F.0
                ;
            ;
            :CMP.C.1
        ;
    ;
    :CMP.B.8
;

:POP.1.7
:S1=A

»

The code above is the N-queens benchmark, verbatim translation of the Pascal sample code.
Interestingly enough (and sort-of expected), the RPL solution using stackrobatics is slightly faster than this one (106 ms vs. 114 ms).
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: newRPL - build 1001 released! - pier4r - 12-16-2017, 08:03 AM
newRPL - on Hp 39gs - Martin Hepperle - 06-05-2019, 06:51 AM
RE: newRPL - build 1001 released! - pier4r - 12-23-2017, 10:16 AM
RE: newRPL - build 1001 released! - pier4r - 01-01-2018, 09:42 AM
t - Claudio L. - 01-01-2018, 03:06 PM
RE: newRPL - build 1001 released! - pier4r - 01-01-2018, 03:41 PM
RE: newRPL - build 1001 released! - pier4r - 01-02-2018, 04:54 PM
RE: newRPL - build 1001 released! - pier4r - 01-02-2018, 06:58 PM
newRPL - brickviking - 10-05-2018, 06:01 AM
How to participate? - erazor - 12-13-2019, 07:12 AM
RE: newRPL - build 1255 released! [updated to 1299] - Claudio L. - 12-27-2019 05:32 PM



User(s) browsing this thread: 6 Guest(s)