P1 to P2 Guide needed..
MacTuxLin
Posts: 821
Had been on P1 for so long that now starting with P2, I'm a bit lost...
Spin2 code seems very neat! E.g. this code
debug(`term message pos 2000 200 size 12 4 textsize 40 rgbi8x)
Does "debug" use a cog?
Comments
Debug doesn't use another cog. It is something like a software interrupt instruction, which calls the debug code placed at the last 16 kB of HUB RAM. Normally this code is generated by the compiler.
Thanks.
It won't take long to get used to the P2, but there are differences that you have to account for. I've written a LOT of P1 code (it's my job) over the years, so I have a lot of code to translate. This is my normal process.
PASM code will have to be manually translated. It's worth the effort, though, as PASM for P2 is easier and you can do more work with fewer instructions. This has been my experience, anyway. In some cases where you might be launching a cog for a tiny bit of code, you can sometimes do that inline with the P2. I use this feature a lot.
As I'm working my way through a Python training course I wrote a little program that will read in a P1 file and provide suggestions for changes for porting to the P2. This may help you until you learn the different operators and changes to some others. Make sure you have Python 3 installed and that it's in your path so you can call it from anywhere. Here's what operation looks like on my computer. Note that Python uses \ for escapes so you'll have to change them to / in your path to the P1 program.
The program is very simple: it goes line-by-line looking for text from the P1 dictionary and outputs suggestions from the P2 dictionary. It's not perfect, but it is helpful, and being Python it is very easy to customize for things that you typically do. I've attached the Python (3) file, as well as my P2 template in case that's helpful.
Thanks, Jon, these are very helpful!