Shop OBEX P1 Docs P2 Docs Learn Events
P2 Spin + creating P1 standalone objects — Parallax Forums

P2 Spin + creating P1 standalone objects

Cluso99Cluso99 Posts: 18,069
edited 2012-12-23 02:55 in Propeller 2
I have my DE0nano working and my faster interpreter modified so that it compiles for p2 with pnut.exe.

Now i need to create some simple standalone spin objects because presently pnut cannot compile spin yet. So i need to just include the bytecodes into pnut with the interpreter (SP2).

I know a number of you have experimented with making spin standalone objects. What is the simplest/best way?

BTW I intend to just make p1 spin work without any new features. So for example coginit will just perform a setcog and then coginit in sp2.

Comments

  • Bill HenningBill Henning Posts: 6,445
    edited 2012-12-21 14:13
    Nice work!

    Maybe you can modify the dynamic object loader?

    ie relocate the spin file based on the first $20 bytes of the eeprom file; I recall a dynamic object loader. You will probably have to do the relocation in pasm...
  • Dave HeinDave Hein Posts: 6,347
    edited 2012-12-21 20:27
    The first 16 bytes of Spin program contain the Spin state variables PBASE, VBASE, DBASE, PCURR and DCURR. The are located in the words at $06, $08, $0A, $0C and $0E. You can relocate a Spin program to a different address than $0000 by adding the base address to these 5 values in the Spin header. The offset must be long-aligned. As an example, if the Spin program is loaded at location $1234, you would add $1234 to word[$1234+$06], word[$1234+08], ... word[$1234+$0E]. You would start up the Spin interpreter with a PAR of $1234+$04.
  • nutsonnutson Posts: 242
    edited 2012-12-22 03:00
    Great work, Cluso, would be a great step in discovering PII features if you could make PII execute Spin programs.
  • potatoheadpotatohead Posts: 10,261
    edited 2012-12-22 09:46
    This is excellent Cluso! Am I correct in understanding the intent here is to run the P1 tool, generate SPIN, relocate the binary file, upload into P2 and go? Seems to me, a package could be made with the modified SPIN tacked onto the beginning, followed by the SPIN bytecode. "squirt" it in via monitor and give it a go at a minimum, on a multi-cog emulation. I'm eager to test that, just let me know after Xmas. (my turn at free time is the new year break)
  • Cluso99Cluso99 Posts: 18,069
    edited 2012-12-23 02:55
    My intention is to generate a P1 spin file and run this under my spin2. I am not adding any more functionality to spin P1 as I will leave that until Chip has time to discuss it. For now, I just wanted to compile a P1 spin program as an object and then cut and paste the byte codes into my spin interpreter. Since the P2 does not clear the hub ram, it would probably also be quite easy to load the object into a higher hub location and then reboot and download the spin interpreter and use the fixed hub start address.

    Unfortunately my DE0 has been wrapped as my Xmas pressie - havent mentioned that I have unpacked it and run it already ;)

    I have been looking at my interpreter version and preping some easy test code to try out the basics of the interpreter. I just have a couple of long[hub]:=$xxxx statements and a coginit to restart the monitor rom. Once this works I think I will get the I/O working DIR/IN/OUT. I am only intending to use the PORTA pins.

    I am not sure which program to use as the base for compiling the P1 spin object - PropTool, bst or homespun. bst and homespun can produce a listing which is quite useful.

    BTW it is pcurr (the base + 4 words) for the pointer to the start of the spin bytecodes. The 5 words in order are: pbase, vbase, dbase, pcurr, dcurr.
Sign In or Register to comment.