Shop OBEX P1 Docs P2 Docs Learn Events
Anyone for Pascal ? — Parallax Forums

Anyone for Pascal ?

hippyhippy Posts: 1,981
edited 2008-02-02 16:02 in Propeller 1
Having implemented a good chunk of the Javelin VM ( see other thread ) and while up against the wall reading JVM specifications to get a better understanding of Java runtimes, it occurred to me that what I'd done amounted to what's needed for a Pascal implementation which would be much simpler than Java; Pascal := Java - Classes, ish.

So for 'light entertainment'; Pascal P4 for the Propeller.

The P4 compiler is open-source so can be modified and tailored to make it more Propeller Chip friendly and useful. It's not a complete Standard / ISO 7185 Pascal but a reasonable implementation.

I've found a Pascal P4 compiler executable, have a 'linker' written to convert P4 p-code to P4 VM bytecode and most of the VM implemented and running. A few (major) bugs stopping a public release but that should arrive soon. I'll post it here, and have created a Wiki page for the project in the meantime ...

propeller.wikispaces.com/Programming+in+Pascal

Comments

  • RaymanRayman Posts: 14,162
    edited 2008-01-29 20:36
    I already feel like I'm programming in Pascal...
  • Mike GreenMike Green Posts: 23,101
    edited 2008-01-29 20:41
    Hippy,
    I'm a real supporter of an extended Pascal for systems programming. It's specific for the 68000 and ARM processors, but Palm Pascal is a great example of the kinds of extensions needed (see www.ppcompiler.org/?lng=en). It's written in a mixture of Palm C and Palm Pascal and runs on the Palm itself.

    Post Edited (Mike Green) : 1/29/2008 9:29:19 PM GMT
  • hippyhippy Posts: 1,981
    edited 2008-01-29 20:59
    I've always had a soft spot for Pascal. I suppose that's because it was [noparse][[/noparse] puts flame-proof underwear on ] the first 'real language' I ever used after Fortran and Cobol and the joys of actually having to punch my own punch-cards. I ported and extended PL/0 and Pascal-S, but that was some decades ago smile.gif

    The advantage of P4 is that I am relatively familiar with it, there was a ready-built compiler executable, but more importantly it generates p-code which is both simple and very well documented ( as is the entire code generation process ). That means it's just a case of writing the linker/assembler and the VM so it's not an overly onerous task I've set myself.
  • Nick MuellerNick Mueller Posts: 815
    edited 2008-01-29 21:19
    > I've always had a soft spot for Pascal. I suppose that's because it was [noparse][[/noparse] puts flame-proof underwear on ] the first 'real language' I
    > ever used ...

    ... after having been forced to use BASIC for a few months. At least in my case.
    Albeit I like (or liked Pascal), I wouldn't use it for µC-programming. Not dirty enough. smile.gif


    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • AleAle Posts: 2,363
    edited 2008-01-30 07:19
    Pascal is great ! and the info you provided, very complete.
  • JoergJoerg Posts: 91
    edited 2008-01-30 08:49
    And i would just love MODULA2!!!

    Saluti Joerg
  • deSilvadeSilva Posts: 2,967
    edited 2008-01-30 08:51
    Oh, you SWISS!
  • Nick MuellerNick Mueller Posts: 815
    edited 2008-01-30 10:23
    Oh, when we can vote for our most liked language:
    Objective-C!

    <http://en.wikipedia.org/wiki/Objective-C&gt;
    <http://www.gnustep.org/resources/ObjCFun.html&gt;
    <http://gcc.gnu.org/&gt;

    Does what C can do, not the bloat of C++, almost dynamic object model, a bit slower when dealing with objects (compared to C++), GCC supports it.
    Haven't used it since some years. :-(


    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • hippyhippy Posts: 1,981
    edited 2008-01-30 10:47
    I'm surprised no one has ported Brainf**k to the Propeller yet smile.gif

    After Spin, Java and Pascal I might head in the opposite direction ...

    en.wikipedia.org/wiki/One_instruction_set_computer

    I'll write the Virtual Machine if someone else writes a HLL compiler.
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-01-30 11:21
    Nick, once we have a c compiler, it is simply needs a good pre-processor to us Objective C. I believe that this is the way that Objective C was originally implemented.

    Steven
  • AleAle Posts: 2,363
    edited 2008-01-30 11:57
    I'd give the HLL compiler a shot, with the info provided it can be done.
    But nifty would be to have it running in the propeller. A PC can do almost anything.... (anybody remember the C compiler for Z80 CP/M ?)
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-01-30 17:17
    Hippy,

    'Don't know how BF escaped me all these years. Thanks for mentioning it. Despite the unfortunate name and obvious impracticality, it's gotten some surprisingly serious attention. Looking at the BF interpreter written in BF (!), one is reminded immediately of DNA. Ignoring, for the moment, the syntax requirement for balanced brackets, it might be considered a candidate language for genetic optimization. (I'm not seriously thinking of pursuing it, though!)

    -Phil
  • hippyhippy Posts: 1,981
    edited 2008-02-01 16:34
    One provisionally implemented Pascal P4 for the Propeller Chip. Not exhaustively tested but what has been seems to work.

    If you want to compile programs to test, you'll need to download the 'pcom.exe' compiler ( into the directory the attached is extracted to ) ...

    www.moorecad.com/standardpascal/pcom.exe

    Then from that directory edit 'test.pas' as desired, then run "MAKE test". After successful compilation, switch to the PropTool, download the AiChip_P4_001.spin and you should see the bytecode being interpreted on an attached TV.
  • BEEPBEEP Posts: 58
    edited 2008-02-01 23:10
    I tried to run "MAKE test" in the command prompt but I get an error message --> "Unable to find procedurestartadress GetProcessId in the DLL-file KERNEL32.dll" confused.gif
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-02-01 23:18
    hippy, the amount of work is amazing. Do you ever sleep?

    Steven
  • hippyhippy Posts: 1,981
    edited 2008-02-02 01:45
    @ steven : No time for sleep; far too many exciting things to do ! My body clock has been out of kilter for years; I think I'm on a 26 hour day at present. I've never synched to dusk/dawn. I love garlic so that's vampirism discounted smile.gif

    @ BEEP : I get the same error message under Win 98SE but it works under my XP, so assumed it was 32-bit only. I've no idea what's missing or is need to make Pcom.exe work. Sorry.

    I've tried many compilers to re-compile the Pcom source but no luck so far ( major issues, not just changing compile settings and variable names etc ). It's going to be impossible to handle strings in the constant pool and arrays of char unless I can - or every string constant has to be 200 words/longs due to lack of context information [noparse]:([/noparse]

    Looks like Pascal has hit a brick wall. Pointless to go backwards to PL/0 or Pascal-S as they don't implement enough Pascal to make it worthwhile. Same problems with Modula, Oberon and Ada bytecode generating compilers I've looked at in the other direction.

    C-Flea looked very promising to have a C up and running in a week or two, but commercial and very draconian licensing. So looks like it's back to Java/Javelin, although I have one other compiler / language ( not Lua ) which I'm looking at. Don't want to get bogged down with having to code a whole compiler if I can help it.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-02-02 03:36
    hippy said...
    ... although I have one other compiler / language ( not Lua ) which I'm looking at.
    Um, Squeak/Smalltalk, perhaps? (If so, you could call it "P'pSqueak", a contraction of "PropSqueak". smile.gif )

    -Phil
  • rjo_rjo_ Posts: 1,825
    edited 2008-02-02 14:34
    The answer is yes and no... I have a few hundred thousand lines of code in Pascal. So, I'm interested in someone else having Pascal available... that I could hire to massage my legacy code onto a Prop.

    BUT by the time you get it done... I might already have translated my code into Spin/ASM.

    I don't know how much legacy code is around... but I'll bet it is everywhere. When Apple dropped Pascal, I dropped Apple... went to Java and haven't been truly happy since[noparse]:)[/noparse] Pascal was the last language that I was happy with.

    In my opinion the greatest virtue of the Prop is that we can touch the processor with as little or as much of an operating system in between us and the machine as we choose.

    BUT I also don't think that developing Pascal could possibly be a mistake.
  • hippyhippy Posts: 1,981
    edited 2008-02-02 16:02
    @ rjo_ : There seems to be enough interest in Pascal that it's still supported for micro development.

    The nice thing about a Pascal compiler source is that by taking a few liberties ( get lax with semicolon checking, allow { } for begin end, int for integer etc, add a few context sensitive parsing routines ) one can produce a compiler which accepts Pascal but allows C-like programming and also VB-like, of which ...

    @ Phil : I'm not familiar with SmallTalk so wouldn't want to get into something which were such unknown territory. I think the JVM/Javelin experience has also revealed just how much more complicated real object handling and garbage collection makes things over a traditional procedural language.

    What I was thinking of was Visual Basic(R), or more accurately a VB-subset as used by Basic-X ( NetMedia Inc ) and Basic-ZX/ZBasic ( Elba Corp ). The ZBasic and C-Flea compilers are licensed only for use to generate code for their own target products, but Basic-X tools don't appear to have that licensing restriction.

    I know the mere thought of VB will cause some people to shudder but it's viable enough that at least two embedded companies are built upon its use and, IMO, most procedural programming languages are the same except for the distinct syntax forced upon programmers.
Sign In or Register to comment.