You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nuttx.apache.org by Gregory Nutt <sp...@gmail.com> on 2022/03/12 00:51:32 UTC

Pascal

Now that I am not longer on the critical path for NuttX support, I am much
less involved in the RTOS.  I thought, perhaps, people might be interested
in what I have been up to.

I have spent the last 6 months or so working on that Pascal compiler that I
used to use with NuttX a few years ago. This is just fun stuff; I don't
think it has has any applicability to businesses at all.

I have basically done these things:

- I have upgraded the language definition to state of most current desktop
Pascal compilers (FreePascal, Lazarus, GNU Pascal) but avoiding the trend
to make it object-oriented Pascal.  Pascal with classes, exceptions, etc.
doesn't feel right to me.

- I have ported the toolchain and P-Code VM to run on NuttX again.  The
toolchain is rather large, but not so large that you could not use it on
some MCUs with more resources.  For more resource constrained platforms,
the VM alone is pretty small and perfectly usable.

- I have a VM start-up C task that can boot the OS into Pascal (for
example, the Pascal shell).

- There is the beginning of a Pascal shell that supports a few commands.
In particular, it supports running multiple Pascal threads (by spawning
multiple copies of the VM).

- Currently it runs on Linux and NuttX.  But I would like to get the VM
running on near-bare metal too.

- I would like to see the compiler work JIT so that I could send Pascal
source to the target and it just runs.

- And lots of other fun ideas.

You can see the code here:  https://github.com/patacongo/Pascal and there
is a WIP document with some history and language specifics here:
https://github.com/patacongo/Pascal/blob/main/doc/PascalNotes.md

The code is pretty stable but still not too difficult to produce compile
errors, although those are getting rarer and rarer.

Greg

Re: Pascal

Posted by Sebastien Lorquet <se...@lorquet.fr>.
Hi,

It's great to get a compiler for a mainstream programming language 
inside NuttX!

I will try to get a look at this.

Thank you!

Sebastien

Le 12/03/2022 à 01:51, Gregory Nutt a écrit :
> Now that I am not longer on the critical path for NuttX support, I am much
> less involved in the RTOS.  I thought, perhaps, people might be interested
> in what I have been up to.
>
> I have spent the last 6 months or so working on that Pascal compiler that I
> used to use with NuttX a few years ago. This is just fun stuff; I don't
> think it has has any applicability to businesses at all.
>
> I have basically done these things:
>
> - I have upgraded the language definition to state of most current desktop
> Pascal compilers (FreePascal, Lazarus, GNU Pascal) but avoiding the trend
> to make it object-oriented Pascal.  Pascal with classes, exceptions, etc.
> doesn't feel right to me.
>
> - I have ported the toolchain and P-Code VM to run on NuttX again.  The
> toolchain is rather large, but not so large that you could not use it on
> some MCUs with more resources.  For more resource constrained platforms,
> the VM alone is pretty small and perfectly usable.
>
> - I have a VM start-up C task that can boot the OS into Pascal (for
> example, the Pascal shell).
>
> - There is the beginning of a Pascal shell that supports a few commands.
> In particular, it supports running multiple Pascal threads (by spawning
> multiple copies of the VM).
>
> - Currently it runs on Linux and NuttX.  But I would like to get the VM
> running on near-bare metal too.
>
> - I would like to see the compiler work JIT so that I could send Pascal
> source to the target and it just runs.
>
> - And lots of other fun ideas.
>
> You can see the code here:  https://github.com/patacongo/Pascal and there
> is a WIP document with some history and language specifics here:
> https://github.com/patacongo/Pascal/blob/main/doc/PascalNotes.md
>
> The code is pretty stable but still not too difficult to produce compile
> errors, although those are getting rarer and rarer.
>
> Greg
>

Re: Pascal

Posted by MIGUEL ALEXANDRE WISINTAINER <tc...@hotmail.com>.
Yes,
I programmed pascal on CP/M on z80 and late on 8086 Borland pascal, 1987
I hope to try to compile the .pas on our u-blox modules w106 and b302, that are esp32 and nrf52 core

Nice job

Enviado do meu iPhone

> Em 12 de mar. de 2022, à(s) 00:30, Gregory Nutt <sp...@gmail.com> escreveu:
> 
> 
>> 
>> Will Embedded Pascal open /dev/  files ?
>> 
> 
> Yes.  The Pascal I/O run-time is a portability layer. Ffor Linux and NuttX
> it uses standard C library calls.  It does use C buffered  I/O  (fopen,
> fread, fwrite, etc.) which may not be ideal for some kinds of device I/O.
> An alternative I/O run-time based on non-buffered I/O (open, read, write,
> etc.) would probably be better and not difficult to do at all.
> 
> 
> 
> That run-time code is here:
> https://github.com/patacongo/Pascal/blob/main/insn16/libexec/libexec_sysio.c#L1298
> 
> 
> 
> I haven't considered hard-realtime with an interpreter.  t I think this
> effort is more in line with a hobbyist's interests.  Performance on a
> desktop, even under the simulator, is really very good and appears to be on
> par with native code; but I assume there could be performance issues when
> it runs on a lower performance platform.
> 
> 
> 
> Calling it "interpreted" is misleading.  The source code is compiled,
> optimized, and linked into an ELF-like executable format.  So what is
> interpreted is machine language for a made up CPU.  I have other emulated
> machine architectures that are not in the repository currently (too much to
> maintain).  Translating the code to run natively on ARM or RISC-V is
> possible, just not as interesting to me.
> 
> 
> 
> The history of Pascal is interesting.  Invented by Niklaus Wirth
> https://en.wikipedia.org/wiki/Niklaus_Wirth it became widely popular until
> destroyed by Brian Kernighan
> https://www.cs.virginia.edu/~evans/cs655/readings/bwk-on-pascal.html .
> Modern Pascal has resolved all of these issues, but it is no longer a
> language in wide use.  It was widely used not too long ago with Borland
> Turbo Pascal and Delphi.  There is a modest following for contemporary
> FreePascal/Lazarus.  Then there is GNU Pascal, but I haven’t heard any kind
> words for GNU Pascal.

Re: Pascal

Posted by Gregory Nutt <sp...@gmail.com>.
> Will Embedded Pascal open /dev/  files ?
>

Yes.  The Pascal I/O run-time is a portability layer. Ffor Linux and NuttX
it uses standard C library calls.  It does use C buffered  I/O  (fopen,
fread, fwrite, etc.) which may not be ideal for some kinds of device I/O.
An alternative I/O run-time based on non-buffered I/O (open, read, write,
etc.) would probably be better and not difficult to do at all.



That run-time code is here:
https://github.com/patacongo/Pascal/blob/main/insn16/libexec/libexec_sysio.c#L1298



I haven't considered hard-realtime with an interpreter.  t I think this
effort is more in line with a hobbyist's interests.  Performance on a
desktop, even under the simulator, is really very good and appears to be on
par with native code; but I assume there could be performance issues when
it runs on a lower performance platform.



Calling it "interpreted" is misleading.  The source code is compiled,
optimized, and linked into an ELF-like executable format.  So what is
interpreted is machine language for a made up CPU.  I have other emulated
machine architectures that are not in the repository currently (too much to
maintain).  Translating the code to run natively on ARM or RISC-V is
possible, just not as interesting to me.



The history of Pascal is interesting.  Invented by Niklaus Wirth
https://en.wikipedia.org/wiki/Niklaus_Wirth it became widely popular until
destroyed by Brian Kernighan
https://www.cs.virginia.edu/~evans/cs655/readings/bwk-on-pascal.html .
Modern Pascal has resolved all of these issues, but it is no longer a
language in wide use.  It was widely used not too long ago with Borland
Turbo Pascal and Delphi.  There is a modest following for contemporary
FreePascal/Lazarus.  Then there is GNU Pascal, but I haven’t heard any kind
words for GNU Pascal.

Re: Pascal

Posted by MIGUEL ALEXANDRE WISINTAINER <tc...@hotmail.com>.
Greg

Will Embedded Pascal open /dev/  files ?

Miguel

Enviado do meu iPhone

> Em 11 de mar. de 2022, à(s) 21:51, Gregory Nutt <sp...@gmail.com> escreveu:
> 
> Now that I am not longer on the critical path for NuttX support, I am much
> less involved in the RTOS.  I thought, perhaps, people might be interested
> in what I have been up to.
> 
> I have spent the last 6 months or so working on that Pascal compiler that I
> used to use with NuttX a few years ago. This is just fun stuff; I don't
> think it has has any applicability to businesses at all.
> 
> I have basically done these things:
> 
> - I have upgraded the language definition to state of most current desktop
> Pascal compilers (FreePascal, Lazarus, GNU Pascal) but avoiding the trend
> to make it object-oriented Pascal.  Pascal with classes, exceptions, etc.
> doesn't feel right to me.
> 
> - I have ported the toolchain and P-Code VM to run on NuttX again.  The
> toolchain is rather large, but not so large that you could not use it on
> some MCUs with more resources.  For more resource constrained platforms,
> the VM alone is pretty small and perfectly usable.
> 
> - I have a VM start-up C task that can boot the OS into Pascal (for
> example, the Pascal shell).
> 
> - There is the beginning of a Pascal shell that supports a few commands.
> In particular, it supports running multiple Pascal threads (by spawning
> multiple copies of the VM).
> 
> - Currently it runs on Linux and NuttX.  But I would like to get the VM
> running on near-bare metal too.
> 
> - I would like to see the compiler work JIT so that I could send Pascal
> source to the target and it just runs.
> 
> - And lots of other fun ideas.
> 
> You can see the code here:  https://github.com/patacongo/Pascal and there
> is a WIP document with some history and language specifics here:
> https://github.com/patacongo/Pascal/blob/main/doc/PascalNotes.md
> 
> The code is pretty stable but still not too difficult to produce compile
> errors, although those are getting rarer and rarer.
> 
> Greg