Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Porting modern scripting language to Neo #3

Open
lykahb opened this issue Aug 9, 2021 · 7 comments
Open

Porting modern scripting language to Neo #3

lykahb opened this issue Aug 9, 2021 · 7 comments

Comments

@lykahb
Copy link

lykahb commented Aug 9, 2021

It would be great to run a modern language on Neo. Compiled Micropython takes about 50-60kb so it should fit. Alas, the project does not officially support m68k but there is an experimental branch with it https://github.com/mmicko/micropython/tree/mc68000/ports/rosco-m68k. It has some parts irrelevant to Neo like UART and I doubt that printing strings works the same way on Rosco and Neo.

Depends on #4 (custom toolchain)
May depend on #5 (file management functions)

@isotherm isotherm changed the title Porting MicroPython to Neo Porting modern scripting language to Neo Aug 9, 2021
@isotherm
Copy link
Owner

isotherm commented Aug 9, 2021

Thanks for your interest!

One of the general obstacles right now to porting code is that the Neo has a special global data pointer (similar to but not the same as PalmOS had), and right now I have a hack in place that requires declaring all of the global data in a struct. This works ok for simple apps or those ported from assembler, but it can become quite a headache for porting C. The first task for porting any modern language will be a custom gcc build for the Alphasmarts, or otherwise some smart trick to make the compiler do what we need to do.

Looking specifically at MicroPython, its Kickstarter page indicates rough requirements to be 64kB+ RAM, 256kB ROM, and 70MHz CPU. We can have a 256kB smart applet, though it would be quite large. Consuming 64kB RAM is what EhBASIC does right now, though I hope to change that once I can figure out the structure of the Neo's file table and creating/loading/saving files. The CPU also seems it could be quite slow. There was a port of Python 1.5 to PalmOS that would be closer in terms of hardware, but it is nearly 20 years old.

I won't categorically exclude MicroPython at this juncture, but I think we could consider the following as potential languages that could be suitable for on-device compilation or interpretation:

  • eLua or similar
  • Free Pascal
  • Simple C compiler
  • MicroPython?

@lykahb
Copy link
Author

lykahb commented Aug 9, 2021

Thanks for explaining the scope. Making a custom GCC looks like a large challenge. Nearly everything that seems to be interesting to port is written in C.

Micropython has many build flags, I cannot find where I saw 50kb anymore. There is a discussion about small boards here. They got it down to 150kb.

I am not too attached to Python. But I think that a language with REPL would be the best fit for Neo. Without a fast feedback loop Free Pascal or C would be more painful to use. eLua looks nice.

There are also two JS engines: JerryScript and Espruino. They need even less ROM than Python.

@isotherm
Copy link
Owner

isotherm commented Aug 9, 2021

The lack of toolchain was a primary reason for starting with EhBASIC, since it is assembler and doesn't assume anything about the system it's running on.

I created issue #4 to track a custom toolchain, which this task will depend on.

@isotherm
Copy link
Owner

I did update EhBASIC in the recent 0.2 release. It only requires 4kB of RAM now, and doesn't stop scrolling after 16 lines. I know it's not great, but it does have floating point and isn't too bad if you enable Caps Lock. 😄

A very early attempt to compile MicroPython resulted in about a 200kB applet, which isn't too bad. However, there is a long way to go to get to a point where we can build an applet that can actually run - still depending on #4.

@isotherm
Copy link
Owner

Per the changes referenced in #4, I now got a MicroPython applet compiled and even running (gives Python prompt and takes input), but it then crashes because the structures aren't initialized up properly.

@TheTechRobo
Copy link

TheTechRobo commented Dec 19, 2022

A very early attempt to compile MicroPython resulted in about a 200kB applet, which isn't too bad.

Would gzip'ing the applet (or similar) (and adding gzip to the applet to decompress it, of course) shrink the size down or is the NEO not powerful enough/would bundling gzip negate the size difference?

@isotherm
Copy link
Owner

Would gzip'ing the applet (or similar) (and adding gzip to the applet to decompress it, of course) shrink the size down or is the NEO not powerful enough/would bundling gzip negate the size difference?

Neo could handle gzip, however, it has plenty of ROM and not much RAM. Compressed code in ROM would have to be decompressed to RAM in order to run, so this wouldn't help much.

The general problem with 200kB is that the M68000 processor in the Neo can only reference +/- 32K compared to a pointer. I did work around that, though, in one of the recent commits. But I'm still a ways off because of the need to initialize pointers to relocatable data and code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants