Shop OBEX P1 Docs P2 Docs Learn Events
Spin2 interpreter Source Code? — Parallax Forums

Spin2 interpreter Source Code?

lozinskilozinski Posts: 76
edited 2021-07-14 21:00 in Propeller 2

It turns out that Taqoz has just a 64Kbit address space (16 bit addresses).
Pity.
https://docs.google.com/document/d/18xYTNLDq2bTbcepN93p9n0ytnncQ3dFioFkmdD6k2_8/edit

Python has its limitations.
So next I am taking a closer look at Spin2.

It looks like the source code is not available.
https://github.com/parallaxinc/Propeller-Tool

Is that correct?
Would it be possible to get a copy of just the Byte Code Interpreter?

I believe @Cluso99 has also written a Spin1 Byte Code interpreter. Should I be reading that instead?

Chris

Comments

  • The Spin2 interpreter source comes with PNut, which you can get here: https://forums.parallax.com/discussion/171196/pnut-spin2-latest-version-v35n-plot-sprites-and-repeat-var-post-fix/p1

    The official Spin2 compiler annoyingly doesn't have source available, but me and @ersmith have been working on bytecode compilation for flexspin. It doesn't support P2 yet though (in bytecode mode. Machine code mode works)

  • Thank you. You are all so great at answering questions.
    I try to ask as few as possible.

    For newbies who come after me, the file you want is
    Spin2_interpreter.spin2
    Although it says it is a spin 2 file, it is all written in assembler, so it can run without a spin interpreter.
    It is only 2000 lines of code, but understanding it is at this point beyond my abilities.
    I wonder if there is a spin design document, or an architecture document.
    Otherwise it is back to the assembly documentation.

    In contrast, it was quite easy to understand much of the Taqoz Source code. First of all I know some Forth, so I kind of know what is going on. So for any Taqoz word definition.I often know what it does. That makes it easy to figure out what the assembly code does. Secondly, there is a culture in the Forth community of documenting every word, and its stack effects. They have to do that, or they could never figure it out later, but whatever the reason, the Taqoz source code was very well documented and understandable. Thank You Peter.

    Which means that it would be quite easy to work with the Taqoz source, and modify it.

  • Yeah, understanding what the interpreter does and how it relates to an actual Spin2 prgram is a bit tricky.

    Some Spin bytecode basics (that apply to both Spin1 and Spin2):

    On the bytecode level, Spin uses a stack very similar to Forth. The compiler simply rearranges an expression like 3 * (1 + x) into a bytecode sequence like constant 3, constant 1, read x, add, multiply

    Spin has three memory bases, to which all memory access (except explicit pointer access like long[something]) is relative to. PBASE ("program base"?) points to implementation of the current object, containing its methods and DAT section data. VBASE points to the current object, it's VARiable data, that is. DBASE points into the current stack frame, at the first local variable.

    For Spin2, one needs to understand the XBYTE mechanism that accelerates bytecode exec.

  • Cluso99Cluso99 Posts: 18,069

    Moderators, could you please move this thread to the P2 group thanks.

  • Cluso99Cluso99 Posts: 18,069

    You may find the docs in my P1 faster spin interpreter easier to understand. This will give the basics for understanding the P2 spin2 interpreter.

  • @Cluso99 said:
    Moderators, could you please move this thread to the P2 group thanks.

    Moved to P2

  • @Wuerfel_21 That helps enormously. I was not even sure if it is a Byte Code language, or stack based.
    There was a recent thread about XByte.
    https://forums.parallax.com/discussion/comment/1525145#Comment_1525145
    I should add that I do not know of any other chip with explicit support for Byte Code interpreters.
    I am in the right place.

    @Cluso99 Thank you for the great advice.
    Here is a thread about your Spin1 interpreter.
    https://forums.parallax.com/discussion/169861/p1-spin-interpreter-for-p2

    Copies of the software are uploaded there. Is that the best place to find the current docs?

    Chris

  • Cluso99Cluso99 Posts: 18,069

    @lozinski said:
    @Wuerfel_21 That helps enormously. I was not even sure if it is a Byte Code language, or stack based.
    There was a recent thread about XByte.
    https://forums.parallax.com/discussion/comment/1525145#Comment_1525145
    I should add that I do not know of any other chip with explicit support for Byte Code interpreters.
    I am in the right place.

    @Cluso99 Thank you for the great advice.
    Here is a thread about your Spin1 interpreter.
    https://forums.parallax.com/discussion/169861/p1-spin-interpreter-for-p2

    Copies of the software are uploaded there. Is that the best place to find the current docs?

    Chris

    Yes. The docs for each bytecode should be at the end of the source file.

Sign In or Register to comment.