Shop OBEX P1 Docs P2 Docs Learn Events
P1 Spin for P2 — Parallax Forums

P1 Spin for P2

I am thinking about how to make the P1 Spin Interpreter work on P2 with the least number of changes.

This means keeping the 64KB limit (16-bit addressing) and basically just using the compatible PASM instructions, at least for now.

There are a few gotchas...
The need for the lower 16 or so bytes/longs in Hub RAM

I know there will be others. Just cannot think of them atm.

Comments

  • Cluso99 wrote: »
    I am thinking about how to make the P1 Spin Interpreter work on P2 with the least number of changes.

    This means keeping the 64KB limit (16-bit addressing) and basically just using the compatible PASM instructions, at least for now.

    There are a few gotchas...
    The need for the lower 16 or so bytes/longs in Hub RAM

    I know there will be others. Just cannot think of them atm.
    Why bother when there is FastSpin available already?

  • Cluso99Cluso99 Posts: 18,069
    Because I think it would be good to be able to run most spin1 programs on the P2. Fastspin, while excellent, doesn't do the same thing. It takes a lot more Hub space which will surely be exhausted soon enough. Some spin programs won't require the speed gain of fastspin. I don't know how long spin2 will be, and how source compatible it will be with P1.

    What would be really nice is PropTool or OpenSpin taking a P1 spin and PASM program and compiling to P2. Not sure how we can combine Fastspin and P2ASM to achieve this. Certainly the grass roots are there.
  • I wrote a P1 Spin bytecode interpreter for the P2 about 3 years ago. The most used bytecodes execute from cog memory, and the lesser used bytecodes run from the hub. I haven't touched the code for a few years, but I got it to assemble with the latest version of PNut and p2asm. The code is in the attached zipfile with a sample P1 Spin program that runs the Dhrystone benchmark. It uses the SimpleSerial object to print at 19200 baud.
  • Cluso99 wrote: »
    Because I think it would be good to be able to run most spin1 programs on the P2. Fastspin, while excellent, doesn't do the same thing. It takes a lot more Hub space which will surely be exhausted soon enough. Some spin programs won't require the speed gain of fastspin. I don't know how long spin2 will be, and how source compatible it will be with P1.
    fastspin compiled programs are only about twice as big as openspin compiled ones. The P2 has 16x the memory of P1, so realistically any P1 sized Spin program can easily be moved over to P2 with fastspin (assuming it compiles, of course... and I do plan to fix any bugs people discover).

    In the long run I agree that having some kind of bytecode interpreter would be a good option. I suspect Chip has something in mind for this.

    Eric
  • msrobotsmsrobots Posts: 3,709
    edited 2018-06-02 20:29
    @Heater. could write a P1 emulator like he did for the Z80, but it is impossible, because he stated to not write emulators never ever again, or something along that line. :depressed:

    But as @ersmith said, with much more HUB in the P2 any P1program should fit.

    And for the whole 'Blockly Universe' I am quite sure a transition to generating P2 code out of the created C will be done quite fast.

    Mike
  • Cluso99Cluso99 Posts: 18,069
    Over the w/e I dug out my attempt to convert my Faster Spin1 Interpreter on P1 to P2. The last date I worked on it was March 2009.

    Anyway, I've been some checking and fixing some of what I've done to use xbyte/skip. I want to use my python program to create the skip bitmaps too.

    I had already verified the register conversion to use the new locations for DIR/IN/OUT A & B, PTR, CNT etc. Of course there is no Video registers etc.

    Probably will not get time to look at this until next w/e now.
  • msrobots wrote: »
    And for the whole 'Blockly Universe' I am quite sure a transition to generating P2 code out of the created C will be done quite fast.
    Mike

    I realize this post is two years old. At the moment we're not planning any Blockly ports for P2, from Spin or C. Blockly could the fastest way to make a simple series of getting-started type demonstrations, but this approach isn't necessary to start product developers in the right direction. At the moment, our efforts are on Spin2 and the MicroPython ports we're seeing from down under and Eric.

    Once Chip verifies the final P2 silicon (maybe tomorrow, or Tuesday) we will start to get our act together with a more visible plan. Until that time, all internal beings are focused on revenue-generating activities so we can get to the next step.

    Ken Gracey
  • @"Ken Gracey"
    I have started on porting Simple Libraries stuff over to ersmith's FlexC, so eventually you will be able to take BlocklyProp Generated C code and compile it with FlexGui to get P2 binaries.
    People will also be able to this to take C stuff they have in SimpleIDE and get it running on P2 with FlexGui (with maybe some minor adjustments for multi C file projects.

    I've got the simplei2c stuff already in there, Eric accepted the pull request, so it may be in the next FlexGui update.

Sign In or Register to comment.