Converting Spin P1 Interpreter to run on P2
Cluso99
Posts: 18,069
Just thought I'd give conversion a go for my Faster Spin P1 Interpreter.
Here are things I've found I need to fix/change just to get it to compile with pnut...
Here are things I've found I need to fix/change just to get it to compile with pnut...
'easy fix ' labels :xxx --> .xxx ' wc,wz/wz,wc --> wcz ' movs/movd --> sets/setd ' disable (will need further review)... ' jmpret ' jmp/tjz/djnz xxx wz/wc ' movi ' waitcnt/waitpeq/waitpne/waitvid ' clkset/coginit/cogstop ' locknew/lockset/lockclr/lockret ' max/min ' absneg/rev ' ,par
Comments
To run compiled spin P1 code on P2 (which is the aim) I am going to need the low Hub to be the same as P1. i will fill in the clockfreq at hub $00000 (long) but the clockmode at $00004 (byte) needs to be looked at so I'll ignore it for now. I think the easiest way to start will be to load up the lower 64KB of Hub similar to P1 and P1V.
I'll be using the same P1 limitations such as 8 cogs, 8 locks, 32 I/O (yes I know it was supposed to work for 64), Hub 64KB. I'll probably move my vector table from hub to LUT.
Obviously we don't have the same counters as P1, and no WAITVID.
What I am wanting to run is my Prop P1 OS on P2. This is mainly spin as is Kye's FAT32.
I did think it would be nice to be able to run P1 compiled spin on P2. Of course there are a number of things it's not going to do, but thought I'd give it a go anyway.
Guess it will come down to trying different ways to find the better approach.
The P1 registers are remapped to the P2 values, and CNT is handled by some P2 code. When I detect that location zero is being read I just return a value of 50_000_000, which was the FPGA frequency at the time.
Not doing any speed up with new P2 instructions yet, though I can see lots of little opportunities to do so
My bytecode decoder uses a long per
Bytecode which has 3 x 9bit call addresses and 5 special bits. So each bytecode has a possible 3 subroutines which can be common to other bytecodes.
This conversion is at least giving me experience with pasm conversion and I am documenting this to put up on the forum for others. I want to get the whole FAT32 file support completed. Then I can convert the OS command files and we'll have an OS for P2 (not OS2 though )
I also need to look at other ways for converting P1 code, such as spin to pasm etc.