Shop OBEX P1 Docs P2 Docs Learn Events
Simple Spin to PASM converter? — Parallax Forums

Simple Spin to PASM converter?

PhilldapillPhilldapill Posts: 1,283
edited 2008-06-16 14:13 in Propeller 1
I'm great on Spin, but have no experience on PASM. I'm not sure if it's been done before, but is there a fairly simple spin to PASM converter software? I'm not sure how hard it would be to do, but could a pre-interpreter be made that would turn spin code into assembly BEFORE it's loaded? this way, it seems the spin code that is written would run faster(maybe not as fast as specific assembly) once it's loaded into ram?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-06-16 02:32
    Spin isn't converted into PASM. It's compiled into byte codes which are interpreted by a program included in the ROM of the Propeller.

    You'll have to learn PASM. There are some tutorials. Look in the "sticky threads" at the top of the Propeller forum.

    You could try ImageCraft's C compiler. It includes an assembler. Demo mode allows you to compile small programs (up to 4K) after the 45 day demo period is up. The C is compiled into specialized assembly code called LMM (large memory model) code which does require a small interpreter in the active cogs, but it is much faster than the Spin interpreter.

    Post Edited (Mike Green) : 6/16/2008 2:38:47 AM GMT
  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-06-16 02:59
    Thanks Mike. I do need to learn PASM, but I've been putting it off for about 6 months. I'm great at C, however. Does this compiler allow you to write programs purely in C(well, for the most part), and it turns it into LMM? If that's the case, I might just write all my programs that way. C is more natural for me than spin, AND it's faster you say. Sounds great!

    However, I still wonder - would it be impossible to make a spin to PASM converter?
  • Mike GreenMike Green Posts: 23,101
    edited 2008-06-16 03:03
    What you're asking for is a Spin compiler that produces PASM. It's possible, but it's a lot of work to do a decent job.
    It's also possible to convert Spin byte codes to PASM. Again, it's a lot of work to do a good job.
    Neither of these are easy projects.
  • hippyhippy Posts: 1,981
    edited 2008-06-16 14:13
    Being interpreted, Spin bytecode ( what Spin compiles to ) is a sort of RISC instruction set, but each would expand to quite a lot of PASM in many cases, especially given that Spin supports things like objects, stack variables and recursion which doesn't match well with what native PASM has ( no single instruction indirect addressing for a start ).

    LMM is a half-way house, quickly interpreting most PASM opcodes, but taking longer over other 'virtual opcodes' which are interpreted like Spin bytecodes are to deliver object and stack handling without bloating the program size. Just as C can be converted to LMM so too can Spin if someone were to take on the effort to do that.

    To compile to pure PASM would not really make as much sense unless it were to compile a very limited sub-set of Spin and then you'd lose most benefits which make Spin attractive in the first place, and not least you'd be limited to just 496 generated PASM instructions. If you need more than that you have to go to LMM anyway.
Sign In or Register to comment.