How to write LUT Exec assembly code?

Maybe I forgot, but how does one write assembly code for LUT exec that PNut can load?

I've got one cog that is full and had to move code to HUB for hubexec.
That's all good and straightforward, but maybe LUT exec code would be faster...
Prop Info and Apps: http://www.rayslogic.com/

Comments

  • 5 Comments sorted by Date Added Votes
  • Just ORG it at $200 and move it into the lut at runtime using SETQ2+RDLONG.
  • RaymanRayman Posts: 8,281
    edited January 21 Vote Up0Vote Down
    Thanks. That sounds simple enough...

    Can I still use "fit" for the cog code?
    I.e., can I put the org $200 after fit $1f5 ?
    Prop Info and Apps: http://www.rayslogic.com/
  • Rayman wrote: »
    Thanks. That sounds simple enough...

    Can I still use "fit" for the cog code?
    I.e., can I put the org $200 after fit $1f5 ?

    Yes. And you can put another fit, like $300, if you want to limit your code to the first half of the lut. Just do a JMP $200 (or, to your label) to execute it.
  • Ok, I just got around to trying this...

    This loads LUT:
    'copy in LUT exec code
                  setq2     #512-1
                  rdlong    0,##@MainLutExecCode
    

    And the code goes here:
    DAT 'Main LUT exec code
    org     $200
    MainLutExecCode
    
    
                  fit       $3FF
    

    Interestingly, this appears to work even if LUT code is above or below $400.

    This is nice. I also like how I can copy this code to hubexec area like this:
    DAT 'Main Hubexec code
                  orgh
                  'org
    

    Not sure why, but using "org" here breaks it.

    I've also found that self-modifying code doesn't work in either LUT or HUB areas. Obvious, I suppose.




    Prop Info and Apps: http://www.rayslogic.com/
  • Yes, the self modify happens in COG registers.

    When in LUT and HUB, it's necessary to think of the COG memory as a bunch of registers.

    When in COG, the code is in the registers, which makes the self modify possible and practical.

    I personally shift gears, from a memory to memory model (COG), to a more traditional load, store model (HUB, LUT)

    Do not taunt Happy Fun Ball! @opengeekorg ---> Be Excellent To One Another SKYPE = acuity_doug
    Parallax colors simplified: http://forums.parallax.com/showthread.php?123709-Commented-Graphics_Demo.spin<br>
Sign In or Register to comment.