Shop OBEX P1 Docs P2 Docs Learn Events
P2ASM documentation: Common Idioms and Tricks — Parallax Forums

P2ASM documentation: Common Idioms and Tricks

A new page has been added to p2docs: https://p2docs.github.io/idiom.html

Some common and useful patterns in assembly. If you can think of any more like that (that you actually use), post them here or send a pull request.

Comments

  • evanhevanh Posts: 16,128

    The link doesn't load for me. Browser times out.

  • Loads on my iPad

  • Yeah idk, I just host it on github, if it doesn't load, that's probably a problem on your end.

  • RaymanRayman Posts: 14,864

    This is nice thanks @Wuerfel_21
    Wish there was more on assembly instruction usage like there is for P1…

    Maybe getting two 64 bit counter values and calculating the difference could be added? Don’t think I’ve done that yet, but want to eventually…

  • RaymanRayman Posts: 14,864
    edited 2024-12-26 14:37

    Some more detailed info on how to move blocks of memory around in assembly would be awesome.

    The docs describe this but the examples are very sparse…

    I’m needing to figure out (again probably) how to move block of words stored in long registers from cog ram to sequential words in hub ram…

  • RaymanRayman Posts: 14,864

    Is there anything in the docs about self modifying code? I’m thinking not..

  • @Rayman said:
    This is nice thanks @Wuerfel_21
    Wish there was more on assembly instruction usage like there is for P1…

    Maybe getting two 64 bit counter values and calculating the difference could be added? Don’t think I’ve done that yet, but want to eventually…

    Oh, I was assuming that basic 64 bit operations are obvious (with all the "extend" instructions)

    @Rayman said:
    Some more detailed info on how to move blocks of memory around in assembly would be awesome.

    The docs describe this but the examples are very sparse…

    I’m needing to figure out (again probably) how to move block of words stored in long registers from cog ram to sequential words in hub ram…

    I don't think there's a trick to help with that, need to just write them in a loop.

  • evanhevanh Posts: 16,128

    @evanh said:
    The link doesn't load for me. Browser times out.

    I'm using a different ISP during xmas (Lugged the desktop with me) and funnily that link above works now. I'll check it again when I get home.

  • evanhevanh Posts: 16,128

    @Rayman said:
    ... registers from cog ram to sequential words in hub ram…

        setq #<longword count> - 1
        wrlong <first register>, ##<hubRAM start address>
    
  • RaymanRayman Posts: 14,864

    Thanks @evanh
    Seems that doesn't work with words, but rewrote to pack words into longs and code is faster now.

  • @rosco_pc said:
    There used to be this thread: https://forums.parallax.com/discussion/169069/p2-tricks-traps-amp-differences-between-p1-reference-material-only

    Anything worth to include?

    Ah, forgot about that one. Added the fast cogRAM clearing trick, which really should've been there from the beginning.

  • Would it be an advantage in the long term to have these hosted on obex? Perhaps as part of chips tips, or something like that? The site search would touch everything, and the dream is to end up with all resources in one place…?

    I can get permissions to interested contributors!

  • @VonSzarvas said:
    Would it be an advantage in the long term to have these hosted on obex? Perhaps as part of chips tips, or something like that? The site search would touch everything, and the dream is to end up with all resources in one place…?

    IDK. Feel free to copy any advice I give, that's what it's there for.

  • @VonSzarvas said:
    Would it be an advantage in the long term to have these hosted on obex? Perhaps as part of chips tips, or something like that? The site search would touch everything, and the dream is to end up with all resources in one place…?

    I can get permissions to interested contributors!

    Please!
    Obex is where I would look first if I hadn't gone through the painful process of finding these scattered resources. Ada did a fine job of collecting this cache of vital info, but it would probably be nice if she weren't distracted from doing big magic stuff just to manage the nuts and bolts of sharing it.

Sign In or Register to comment.