Shop OBEX P1 Docs P2 Docs Learn Events
Is there any Spin compiler written in Pascal? — Parallax Forums

Is there any Spin compiler written in Pascal?

pik33pik33 Posts: 2,366
edited 2018-02-18 10:16 in Propeller 1
There is an Ultibo environnment for bare metal Raspberry Pi written in Pascal (fpc). Having a Spin compiler in Ultibo would allow to connect P1 to Ultibo running on Pi and using this Pi to compile and upload programs to the Propeller.

There is an OpenSpin repository; the code is in C/C++ but then there are comments that this is a translation from Pascal. It can be of course translated backward but if there is a Pascal code hidden somewhere, this could save several hours of work.

I am posting this after several failed attempts to find this: maybe I am searching for what is not hidden but I can't see it.

Comments

  • Heater.Heater. Posts: 21,230
    The original Spin compiler built into the Parallax Prop tool was written in Intel x86 assembler, as it says in the github repository, no mention of Pascal there. Crazy but true. Chip Gracey can write assembler in his sleep. The Prop Tool wrapped that compiler and was written in Pascal. None of this has ever been open sourced.

    Open Spin is a C++ recreation of the compiler. I'm not sure if the x86 assembler source was made available to the author, Rot Eltham, to enable this.

    There is the BST Spin compiler that was written in Pascal: http://www.fnarfbargle.com/bst.html BradC did not open source that either.

    As far as I know you are out of luck in the Pascal department.

  • pik33pik33 Posts: 2,366
    Then translating will be needed. Not the first time, not the last, if I want to connect my 2 most preferred environments (Ultibo and P1) in one system :)
  • Heater.Heater. Posts: 21,230
    I do understand the desire to combine our two favorite platforms, Propeller and Raspberry Pi. I do it my compiling openSpin on on the Pi under Raspbian. Works a treat.

    I'm crazy enough to have translated OpenSpin from C++ to JavaScript so that one could compile Spin code in a web browser. But I cheated and used the Emscripten compiler to do that.

    Translating OpenSpin to some archaic language for a OS that no one uses would be a bit too crazy for me. But I do see the motivation.

    Presumably there is a way build and run assembler language programs on Ultibo. Or assemble them into a library that can be used from Pascal.

    In which case perhaps one could compile OpenSpin into assembler. Then use Free Pascal to incorporate that assembler into a program or library.

    Of course OpenSpin depends on the standard C library which you don't have. That was true for the Javascript translation. One just has to find all the places this happens and provide the feature required. It's not much, open, close, read, write, etc.
  • pik33pik33 Posts: 2,366
    edited 2018-02-18 13:23
    there is a way build and run assembler language programs on Ultibo.

    Of course yes :) I wrote a SID emulator for Ultibo in asm, as well as the noise shaping audio driver. Both inspired by P1 programs (SidCOG and audio driver)

    If it depends on standard C library (and not C++), then we have it and no translation will be needed, only compiling into the static library. This is supported by Ultibo. That way I have an Amiga module and mp1-2-3 player added to my Ultibo based audio player
  • Heater.Heater. Posts: 21,230
    Sounds like the job is as good as done :)
  • AleAle Posts: 2,363
    edited 2018-03-19 14:01
    BST (and bstc the standalone compiler), Brad Spin Tool was written in what was it again, OpenPascal + the Lazarus library. Sadly the code got lost at some point due to corrupted backups, if I'm not mistaken, very unfortunate. No idea if anything of it has been recovered. You could try to contact BardC on the eevblog forums, I have seen him posting from time to time. He seems to post there from time to time.

    Maybe actual compilers superseded it, no idea.
  • jmgjmg Posts: 15,173
    There is PropBASIC,written in FPC, so that should compile on the Pi?
  • jmg wrote: »
    There is PropBASIC,written in FPC, so that should compile on the Pi?
    PropBASIC does compile under Raspbian Jessie on the Pi 3B using Free Pascal Compiler 3.1.x and seems to work correctly. I don't think that's going to help as PB generates Spin/PASM code from PB source.

  • This is a very cool discussion. I did some early testing with Ultibo back when it was still early, and was very impressed. The Pi would boot within about 2 seconds or so. Having that as a development too with a monitor would be neat. I think it would even be a good complementary component in a design with a prop. I kicked around an idea with a web based controller hosted in the Pi that could talk to the Prop over I2C. I would love to see this get further.
  • Heater,
    Chip did provide the source for the x86 asm for me to reference when building OpenSpin. (Also, are you trying to imply something by calling me Rot? ;)

  • Roy Eltham wrote: »
    Heater,
    Chip did provide the source for the x86 asm for me to reference when building OpenSpin. (Also, are you trying to imply something by calling me Rot? ;)
    Too bad Chip didn't make the x86 code open source. I've heard that he writes beautiful assembly code. It would be nice to be able to see it.
  • fixmaxfixmax Posts: 91
    edited 2018-03-19 18:44
    Heater. wrote: »
    I do understand the desire to combine our two favorite platforms, Propeller and Raspberry Pi. I do it my compiling openSpin on on the Pi under Raspbian. Works a treat.

    I'm crazy enough to have translated OpenSpin from C++ to JavaScript so that one could compile Spin code in a web browser. But I cheated and used the Emscripten compiler to do that.

    Translating OpenSpin to some archaic language for a OS that no one uses would be a bit too crazy for me. But I do see the motivation.

    Presumably there is a way build and run assembler language programs on Ultibo. Or assemble them into a library that can be used from Pascal.

    In which case perhaps one could compile OpenSpin into assembler. Then use Free Pascal to incorporate that assembler into a program or library.

    Of course OpenSpin depends on the standard C library which you don't have. That was true for the Javascript translation. One just has to find all the places this happens and provide the feature required. It's not much, open, close, read, write, etc.

    One big thing for me is the Pi booting in 2 seconds. There is no operating system so, it's pretty much instant. I did a little test here with it: fixstuff-thots.blogspot.com/2016/03/very-interesting-new-project-on-pi.html

    edit: Lol. We even had this discussion a while back.. https://forums.parallax.com/discussion/163686/interesting-concept-for-baremetal-pi
  • jmgjmg Posts: 15,173
    pmrobert wrote: »
    jmg wrote: »
    There is PropBASIC,written in FPC, so that should compile on the Pi?
    PropBASIC does compile under Raspbian Jessie on the Pi 3B using Free Pascal Compiler 3.1.x and seems to work correctly. I don't think that's going to help as PB generates Spin/PASM code from PB source.
    Fair point, there are also x86 emulators, which might work ok on a command line file to file tool, such as Assemblers/Compilers ?
    As well as some Prop tools, there is fasmg (advanced Macro Assembler) in x86 assembler, & I played about with PASM in that.

    I believe the PropBASIC Spin is limited to launch wrappers for the PASM, so that shifts the problem to finding an assembler - either modify an existing one, or expand PropBASIC to emit located HEX ?

  • pmrobertpmrobert Posts: 673
    edited 2018-03-19 19:41
    jmg wrote: »
    I believe the PropBASIC Spin is limited to launch wrappers for the PASM, so that shifts the problem to finding an assembler - either modify an existing one, or expand PropBASIC to emit located HEX ?
    It's been a while but I believe I was using openspin to assemble the emitted PASM. This doesn't address the OP's query but thought I'd mention it.

  • Heater.Heater. Posts: 21,230
    Roy Eltham,
    Chip did provide the source for the x86 asm for me to reference when building OpenSpin. (Also, are you trying to imply something by calling me Rot?
    Having once, twenty years ago, taken on a project to reverse engineer 10's of thousands of lines of x86 assembler, figure out what it does, with no documentation and few comments in the code, and recreate it's functionality in C, I totally appreciate your achievement with OpenSpin.

    I am very impressed.

    It's even more weird that the original x86 assembler ended up as Javascript with OpenSpin.js

    It's totally the wrong way to build a compiler or any other software but never mind.

    Sorry about the "Rot" thing. Just a typo. Or is it a contraction of Roy elTham ?


  • jmgjmg Posts: 15,173
    pik33 wrote: »
    There is an Ultibo environnment for bare metal Raspberry Pi written in Pascal (fpc). Having a Spin compiler in Ultibo would allow to connect P1 to Ultibo running on Pi and using this Pi to compile and upload programs to the Propeller.

    Does the FPC Exec command still work in Ultibo ? (calls a command line executable with params)

    https://www.freepascal.org/docs-html/rtl/dos/exec.html

  • Heater,
    I knew it was just a typo, but I had to poke at it, for fun.

    Chip's x86 asm is pretty clean and reasonably well commented. That made it a LOT easier to do, than if I had disassembled the binary and reversed it.

    David Betz,
    I bet if you asked Chip he would share it with you. I was asked not to share it, but that was ages ago. They've opened the P1 and gone heavy on Open Source since then. Who knows, maybe they'll release the x86 asm source for all?
    It's not usable on it's own, you have to wrap it with a bunch of code , but you can see OpenSpin for a rough idea on that (although I have evolved things a bit since the original port).
  • Cluso99Cluso99 Posts: 18,069
    IMHO the big problem is a lack of a good IDE (as I said elsewhere).

    We could get by with using an Editor such as NotePad++ or similar on various platforms.

    SimpleIDE stared out with great enthusiasm by jazzed. Unfortunately development faltered and it seems its not in a usable form any more.

    I am not sure if PropLoader works on all platforms, nor if it is reliable anyway. Something like this is required.

    There are Terminal Programs that work on different platforms.

    But these 4 pieces need to be tied together for each platform. Don't hold your breath - we have been waiting for a decade now :(

    bst was the closest and it worked reliably at the time. There was absolutely no support from Parallax. It's a real shame.
  • Cluso99 wrote: »
    II am not sure if PropLoader works on all platforms, nor if it is reliable anyway. Something like this is required.
    What problems have you had with PropLoader? I've tested it on the Macintosh, Linux, and Windows and it seems to work.

  • Cluso99Cluso99 Posts: 18,069
    David Betz wrote: »
    Cluso99 wrote: »
    II am not sure if PropLoader works on all platforms, nor if it is reliable anyway. Something like this is required.
    What problems have you had with PropLoader? I've tested it on the Macintosh, Linux, and Windows and it seems to work.
    Great news David. As I said, I just didn't know.
    So the basics are there. Just need to tie the pieces together on each platform.
  • Cluso99 wrote: »
    David Betz wrote: »
    Cluso99 wrote: »
    II am not sure if PropLoader works on all platforms, nor if it is reliable anyway. Something like this is required.
    What problems have you had with PropLoader? I've tested it on the Macintosh, Linux, and Windows and it seems to work.
    Great news David. As I said, I just didn't know.
    So the basics are there. Just need to tie the pieces together on each platform.
    Well, I'm not saying for sure that there are no problems. I just don't know of any. Please let me know if you find some.
  • Cluso99Cluso99 Posts: 18,069
    Unfortunately I only run Windoze 10. I have a Ubuntu laptop but haven't done much with it yet.
Sign In or Register to comment.