7

Does any Python port run on any Speccies or Commodores? I am hopeful about QL, since:

Based on a Motorola 68008 processor clocked at 7.5 MHz, the QL included 128 KB of RAM, which was officially expandable to 640 KB and in practice, 896 KB. Memory: 128 KB (896 KB max.)

That's plentiful and there's MicroPython.

Yet it is compact enough to fit and run within just 256k of code space and 16k of RAM.

But a fully expanded QL could even run JS code, I believe.

EDIT: one way to achieve this would be cheating like Doom running on the c64 RAD project, or by using an 8-bit computer as a terminal.

8
  • 11
    But to truly be retro shouldn't you run Forth instead?
    – Jon Custer
    Commented Feb 8, 2022 at 14:45
  • 3
    I created a MicroPython port to run on a Tube-interface connected ARM CPU (actually, RPi Zero) for the BBC Micro a couple years ago. It seemed promising.
    – Brian H
    Commented Feb 8, 2022 at 15:37
  • 3
    @user1095108 I doubt that you can write a web server in a few lines in a Python implementation running on such limited hardware. You need to distinguish the language Python and the seemingly omnipresent libraries. Commented Feb 9, 2022 at 9:04
  • 3
    The problem is that the libraries you think of will not fit into the limited resources, depending on the expectations. A library for a super simple server providing a handful of HTML-only files and some images might work. People have done this, even not in Python. Anyway, someone needs to write or incorporate the hardware drivers to access the specific network hardware. This is a far from simple task. -- I'm afraid that you never tackled such a task and therefore you are kind of blinded by the simplicity of Python on modern desktops. Commented Feb 10, 2022 at 7:01
  • 3
    Sure. And where are the Python libraries that know how to access them? Or at least Python wrappers for the existing drivers? -- Oh, and I did not say that it is impossible. It is just hard. Commented Feb 10, 2022 at 15:04

3 Answers 3

17

Python 2.4 runs on 68000 Commodore Amigas.

The actual port relies on a Unix emulation library called ixemul. This should allow it to run equally well with accelerated Amigas (68020/68030/68040/68060).

12
  • 1
    Not sure if I really like it, Brian, but it's kind of today's BASIC, so there is a usefulness when it comes to old(er) hardware any a young(er) audience.
    – Raffzahn
    Commented Feb 8, 2022 at 16:12
  • 2
    Python is a Bad Programming Language Commented Feb 9, 2022 at 5:08
  • 14
    @BruceAbbott the article itself is bad and sounds like a personal rant. Python is good for many purposes and won't fit for everything. C#, Java, Basic and Matlab languages are also good for many purposes but not fit for everything. They are all just for different use cases and purposes - you would not move a piano with a bicycle or use a long haul truck as a taxi either.
    – Justme
    Commented Feb 9, 2022 at 10:29
  • 1
    @Tommy ixemul docs say: "The library itself needs about 200 Kb, but if you want to do some useful work, such as compiling programs (with gcc), I advise at least 4 Mb." So, maybe, MicroPython as smaller, cleaner, newer, more portable option...
    – Brian H
    Commented Feb 10, 2022 at 16:23
  • 2
    @Tommy "Would the Amiga port run in the QL's limit of 896kb?" - No. Python 2.4 takes 2MB to run a trivial script. Commented Feb 12, 2022 at 3:15
16

Python, and even MicroPython, needs a modern C compiler to target the host processor. Such a thing does not exist for the Z80 or 6502. Sure, there are C compilers for those processors, just not ones that have the language features that MicroPython needs.

This is a fairly common trope on the MicroPython forum: someone shows up, says "I'm going to port MicroPython to the (insert name of 8-bit computer)!", posts a couple of times, fails to find a decent C compiler, and is never heard from again.

Even Snek - the smaller Python than MicroPython - relies on avrgcc to target 8-bit micro-controllers.

Another reason is that - while MicroPython might appear to run in tiny amounts of memory - it usually needs substantial flash/ROM (> 128 K) and at least 32 K of contiguous RAM. Most home computers didn't have that.

6
  • 1
    Great point - the curse of a time when the art of porting is reduced to recompile an existing source with the always same (existing) tool set, but noone able to adapt the tools.
    – Raffzahn
    Commented Feb 10, 2022 at 3:19
  • Yes, a great point, but not a sufficient one. clang has (unfinished) backends targeting z80 and 6502. I have no idea why none of these were ever finished. Commented Feb 10, 2022 at 4:16
  • 3
    @user1095108 It might well be that the few souls being capable of doing this don't have time to do so or have too many other things with higher priority on their to-do list. Go ahead, be the first to contribute! Commented Feb 10, 2022 at 7:19
  • 4
    an entirely sufficient one, @user1095108: no toolchain, no python. There's been well thrashed-out discussion here why making good compilers for Z80/6502 is extremely hard: I won't revisit it.
    – scruss
    Commented Feb 10, 2022 at 23:58
  • 3
    68HC11 has a gcc port, Z80 has SDCC which is a very full ANSI compiler if sometimes a little buggy. Compilers are/were not the problem. nor in a way was memory. My Amstrad PCW has 512K of RAM, but the 64K address space kills you because micropython has no notion of banked memory support.
    – Alan Cox
    Commented Feb 22, 2022 at 14:54
4

Officially python was never ported or released on ZX-Spectrum computers, because it was first apperared in February 1991 when most of Speccy publishers moved to another modern hardware platforms. Only LISP which traditions python was based on was released in 1983. This is to image how old Speccy platform for newer technologies is.

As about porting or compiling C sources of python for Zilog Z80 CPU here is two serious problems to release this:

  • Slow CPU. If you use honest math, it will be quite slow. Zilog Z80 CPU has no floating point machine instructions, neither multiply or devide. So you need to emulate them using lower level commands in 3.5MHz only. All CPU commands takes at least 4 CPU tacts. So you need to devide 3.5/4 at least, this is quite slow for mathematics. An example of this is the calculator routines built into ROM. You can also use it no only from BASIC, but from your machine code with RST #28 command to enter 0x0028 address entry point. Let me give you an example of assembler code how to calculate COS table using ROM calculator routines which takes about 14 seconds.

    Yes, there are a lot of nice demos on ZX-Spectrum with quite cool mathematics, but all democoders uses speed-up tricks such as pre-calulated tables to lookup or pre-calculated values, also simplified calculations. For example 'Paranomatic Rotazoomer part' in Echology megademo uses 16 kilobytes of sinus table (1/4 of ZX-Spetrcum 48k memory!) to rotate attribute plasma in 50 FPS. Most of these effects also have stack-based data movement and no-loops output routines, which also take up a lot of memory. It follows that accelerating work with data will take up quite a lot of memory. More complex data structure will need more complex data movement or parsing routines.

  • Small amount of RAM. Let's say, if you have finally compiled C for Z80, then will everything you need for Python fit into 48 or 128 kilobytes? You can forget about dynamic loading, because the fastest thing that is native to the Spectrum is floppy disks. Of course, nowadays it is possible to use an SD card in ZX-Spectrum Next, also some models load files from Wi-Fi, but I’m not sure that we are talking about the Spectrum as is. Some Speccy clones has more than 128 kb of memory, but standards of memory page switching are different. Yes, it's beyond of original Speccy again. And it seems that the garbage collector still needs to be placed somewhere in RAM.

Commodore 64 computer has a lower CPU frequency, but some commands take fewer processor tacts. Therefore, if we talk about comparing the performance of its processor, it is approximately equivalent to the ZX-Spectrum. In some aspects of processor performance, Commodore may even lose, giving a way to make another tricks and optimizations. But Motorola 68008 mentioned in a question is more powerfull because at least this allowes you 1 MB or 4 MB address space. This is quite real to make a main things from python for Motorola 68008.

Now based on this you can imaging how easy to make this and how this is useful, because the most efficient and most performance language for 8 bit computers is assembly.

1
  • I'd be happy if it was running within an emulator supporting arbitrary extensions. I think even so it would be instant hit and you forgot about QL. Commented Sep 22, 2023 at 16:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .