P2ASM documentation: Common Idioms and Tricks
Wuerfel_21
Posts: 5,140
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
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.
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…
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…
Is there anything in the docs about self modifying code? I’m thinking not..
Oh, I was assuming that basic 64 bit operations are obvious (with all the "extend" instructions)
I don't think there's a trick to help with that, need to just write them in a loop.
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.
Thanks @evanh
Seems that doesn't work with words, but rewrote to pack words into longs and code is faster now.
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!
IDK. Feel free to copy any advice I give, that's what it's there for.
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.