Marcin Cieślak is a user on mastodon.social. You can follow them or interact with them if you have an account anywhere in the fediverse. If you don't, you can sign up here.

Wondering if it's crazy to define a language which is almost exactly Z80 assembler but a little more orthogonal, and then write a preprocessor which turns into actual Z80 assembler by inserting stack juggling nonsense to work around the limitations. Would not produce optimally fast or small code but would make writing much easier...

@solderpunk doesn't seem *that* crazy to me although I would expect the resulting code to perhaps be too slow/bulky for use on emulators of 1980s systems at "real speed" (although I'm perhaps thinking here of 8-bit home computers rather than business grade CP/M equipment, which by late 1980s had fast running CPU and often extra (paged) RAM..

@vfrmedia This is for my homebrew machine with 10MHz CPU and half a meg of RAM, I think the performance hit is probably negligible relative to the increased ease of development.

@solderpunk cool 😎 I'd be interested in seeing more of this (had been reading about folk making modern Z80 based computers in recent times, it seems to be still quite popular especially in parts of Europe..)

@vfrmedia Drop me a line (solderpunk@sdf.org) if you would like to know more about my machine.

@solderpunk @vfrmedia what kind of stack juggling do you plan to do? I wish I had a Rockwell R65F11

@saper @vfrmedia Well, suppose you wanted to do a "LD B, (DE)", which is not actually permitted (you can only load into registers other than A from HL). You could work around this by doing a "PUSH AF / LD A, (DE) / LD B, A / POP AF". In general, by backing up some registers on the stack first (probably mostly A and HL) and shuffling things around at the end, you can usually simulate being allowed to do any instruction with any combination of registers you like.

Marcin Cieślak @saper

@solderpunk @vfrmedia Looks like a terrible overhead might occur.

EX DE, HL might be a better and faster solution for this particular one.

If you have a lots of pointers, maybe IX and IY should come to play?

Just found this: righto.com/2014/10/how-z80s-re

· Web · 0 · 2

@saper from memory trying to code games/graphics on ZX spectrum, using IX and IY had a speed hit.

*But* @solderpunk is using a modern 10 MHz CPU and 512 MB of paged RAM, so performance hits may not then be such an issue.

@vfrmedia @solderpunk Register scheduling is a fascinating problem and I think it is the reason we have compilers :)

@vfrmedia @saper Yes, addressing using IX and IY is unfortunately very slow.

@saper @vfrmedia Oh, sure, this will definitely produce larger and slower code than carefully choosing the right registers so that you can do everything within the limitations of the instruction set.

In some cases, the overhead might be worth the increased ease of programming.

And, yes, you're right, I chose a sub-optimal substitution here. But for any illegal combo of registers, there is an optimal workaround, and the tool I envisaged would always insert the optimal code.

@saper @vfrmedia Regarding trading performance overhead for ease of programming, what I'm proposing could perhaps be thought of in loosely the same light as Woz's "SWEET 16" language for the 6502:

en.wikipedia.org/wiki/SWEET16

@solderpunk @vfrmedia Didn't know that one! Thanks!

1/10th ouch...