Shop OBEX P1 Docs P2 Docs Learn Events
P2 Taqoz V2.8: How do you use LUT? Some sort of standard needed? — Parallax Forums

P2 Taqoz V2.8: How do you use LUT? Some sort of standard needed?

Christof Eb.Christof Eb. Posts: 1,088
edited 2022-11-02 10:34 in Forth

Hi Taqoz Forthers!

How do you use LUT Ram?

I am now thinking to use this Feature more actively. As a storage that is faster than HUB Ram and private to a cog. For example the variable "toset" for values could reside there or the switch-variable for a modified switch-case. The reason to ask here is because the addresses must be hardcoded to make things fast. I think.

$0 Stack
$20 Loop
$30 If branch
$40 Return
$80 L> Auxiliary stack
.... $1FF End of LUT

Up to now I have hardly used the L stack. Perhaps I could/should use it for the local variables. For this it would be needed to be large.
At the moment I have a LUT table of length $40 starting at $0100. Thinking of it, I should shift it to a higher place.

Perhaps it would be a good idea to have a word like "longs" that can reserve LUT space starting from end of LUT? I will try that "lutLongs", I think.

This is a little bit of brainstorming. Curious about some comments.
Christof

Comments

  • bob_g4bbybob_g4bby Posts: 401
    edited 2022-11-02 15:49

    So up to 383 longs available if you don't use the L stack at all - quite a useful space for special-to-cog variables . The 'lutLongs' idea sounds useful and only needs a 'luthere' pointer to decrement every time you define a fresh variable. 'luthere' could be located at $1ff and be initialised to $1fe maybe?

  • Hi Bob,
    glad that you find the lutLongs useful.
    The pointer is global, because the position is the same for all cogs. It has to be handled by the compiling cog.
    The lutvariables exist in all cogs in parallel.

    long lutOrg \ Pointer to next free pos
    $1ff lutOrg !
    
    pre lutLongs ( n <name> ) \ create n longs private for each cpu in LUT
         create 
             lutOrg @ swap - \ decrement pointer
             dup 1+ [C] ,
             lutOrg !
         does> ( -- address )
            R> @
    ;
    

    The application for the flag, that is set by "to" is very promising, speeds up my value type variables more than factor 2. :-)
    I will have a look into my local variables next.

Sign In or Register to comment.