What do people code with when targetting multiple 8-bit machines?

I would like to be able to create code on a modern machine to run on multiple tape-based 8-bit machines (mostly Z80) and was wondering what tools people here use for that?

The programs would be text only, which should make it easier.

So far, using SDCC with Nim is the only successfully tested option I know of.

1 Like

Interesting toolchain! Using C as a universal sufficiently-low-level language is probably a good fit. My own interests tend towards the 6502, but again there are C compilers for that.

Presumably you have written some sort of abstraction library to use the various platforms you want to target, for files, for graphics, for sound, for keyboard or joysticks?

If interpreted languages would suit you, then BBC Basic runs on various 8-bit micros and recent 32 and 64 bit machines. I’m not sure about 68k… oh yes, that too.

And if you want to use the supplied Basic, you might look into
BASICODE 2 unwrapped and for download

Forth usually is a good fit for 8-bit type computers with limited memory.

Honestly the only thing I’ve used to target multiple 8-bit machines was BASIC.

That’s the way I remember; Usborne and Creative Computing published many books/magazines/articles with BASIC listings along with tips/directions on how to convert to the other popular BASIC dialects.

Even a universal BASIC program may be somewhat tricky, as you have to stick with very simple constructs. E.g., Commodore BASIC has no ELSE clause, Sharp’s BASIC for the MZ-machines uses “*” and “+” for logical AND and OR. If you include Apple’s Integer BASIC or things like Tiny BASIC, you can’t take floating point math for granted. Variable names may be limited to a single letter and arrays (if implemented) to a single dimension. Etc, etc. This may render even a simple algorithm quite complex using just basic (well… no pun to be seen here, carry on) building blocks.

1 Like

It would be mildly interesting to get or make a full cross development toolchain that outputs .wav files or sends audio for recording on a tape.

Good thing I wasn’t going for “universal”, since my computers were VIC-20, C64, and C128. ^_^;

Less flippantly, I didn’t have any way to save files to any media that any other computers could read anyway.

But you had a keyboard, and not the worst of them! :slight_smile:

Pascal comes to mind, but that vanished a long time ago for 8 bit micros as virtuai machine. Text games can be ported using the Z-machine.

At this point, I’m just investigating possibilities.

My main focus will be on creating text adventures, so the standard i/o libraries should be good enough.

I would prefer the end result to be compiled, in case I need to use text compression and decompression (which would be slow if interpreted).

Yes, I have owned several more obscure machines and converting from one BASIC to another was often time consuming.

There are utilities available for individual platforms that output .wav or .mpg files for loading via tape or digital recorder, but I haven’t seen any that are more universal.

The only multiplatform Pascal I’ve found so far that can output for several targets is Turbo Rascal SE, but it only caters for more popular machines.

FreePascal compiles to Z80 code, but only Spectrum and MSX machines so far.

The Z-machine needs a disk drive for all but the tiniest of games and is only available on the more popular 8-bit home computers.

Level 9’s A-machine would be a better fit, but the code for that hasn’t been released yet. It is currently being worked on by one of the Austin brothers though.

1 Like

This may sound rather fancy at first glance, but there have been Fortran compilers for most (if not all) of the better known platforms. Fortran tends to be pretty well standardized, but I never had a closer look at any of the 8-bit implementations and the kind of tradeoff that comes with them. Also, these compilers tend to be obscure and code and documentation may not be easily available. Hence, this may be better suited for building an archive of platform-specific binaries, compiled from a common source. It’s probably much like doing it in C, but may be more period correct. – Also, not a serious recommendation.

My main focus would be on less popular computers, such as the Sharp MZ-700, Enterprise 64/128 and Dragon 32 which makes it tougher to find suitable options.

Any other platforms I could target would obviously be a bonus.

If going by cpu’s , the 8080,6809,6502 and the 68008 all come to mind as smallish machines.

For “multiple machines” I’d go for Z88DK Home |z88dk . It compiles for most popular Z80 based machines around.
The problem with the phrase “multiple tape-based 8-bit machines (mostly Z80)” is that key board entry and screen output was far from standardized. Sometimes not even in machines from the same company. Z88DK takes care (or, have taken care of) that problem already.

1 Like

Thanks. I did bookmark that site a while ago, but I haven’t seen any mention of z88dk being used successfully with languages that compile to C.

In theory, it should work, as it includes SDCC as a compiler option and I have heard of that working with Nim.

Nim with a retro C compiler seems to be the simplest option so far and if I do end up using it, I will definitely test it with z88dk.

At this point, I’m mostly checking that there isn’t something else out there that I haven’t found yet.

I’m working disk based but C. ACK for 8080, SDCC for Z80 (Z88DK would probably be easier for many uses), CC65 for 6502/65C816, GCC for 6809, 68HC11, and I have been retargetting CC65 for the 6800 series and writign a proper 8085 C compiler.

Providing you write fairly portable C with some asm bits it seems to work fairly well for anything that’s not performance tight. At that point you do get problems because the video is so different between say MSX (TMS9918 tile based I/O), C64 (slow system dependant on sprites), Spectrum (weird attributes), etc.

The current most extreme portable C library for this is probably Fabrizio’s. It’s at about 200 machines!


Thanks @EtchedPixels for mentioning my project!

Indeed Cross-Lib allows to use the very same code to build games for about 200 targets with no need to adapt the code. Even the graphics assets are shared.
Cross-Lib is not a compiler, though. It is an abstraction layer library coupled with a set of build and graphics tools. It requires compilers such as CC6303 (by EtchedPixels), Z88DK, CC65, CMOC, LCC1802, GCC, etc. It supports a dozen compilers.

1 Like

I have Cross-Lib bookmarked, although I do have a lot of sites in my “retro” list.

I will likely take a closer look at it if I can find a language that compiles to ANSI C, as I dislike C syntax and don’t really want to deal with low level code.

One thing that has put me off trying it out is that there are a lot of prerequisites for Windows. Since I first looked at the project I have installed some of those to use other software though.

Would MinGW work instead of Cygwin? I already have the former installed to use Nim and z88dk.