[fpc-devel] FPC and Z80

nickysn at gmail.com nickysn at gmail.com
Mon Apr 20 16:07:11 CEST 2020


On Thu, 2020-04-16 at 11:04 +0200, Guillermo wrote:
> Thanks Swen.
> 
> I see last commit was 2 days ago so it is active.  I would like to
> know
> who is responsible to speak to him. May be I can help with the MSX
> target, but I need gidance about the internals of the compiler (I
> tried
> but it is beyond my comprehension right now).

Hi,

The Z80 branch was started by Florian about 2 years ago, but I've
recently picked it up and I'm working on it. I'm targeting the ZX
Spectrum as a first platform, for no particular reason, other than
that's what I could get a working emulator for. Back in the 8-bit era I
never had a Z80 computer, only 6502, but that is harder to support, so
I decided to work on the Z80 target first, because that was already
started by Florian. And besides, I've recently obtained an 8-bit
computer that has it. It's a Pravetz 8M, that's a dual cpu (6502+Z80)
machine, that is like an Apple II+ clone with a built-in Z80 CP/M card,
so later I'm planning to support CP/M as well. The only reason I'm not
starting with the CP/M target is that I don't have an emulator for it,
and development is much faster when you have an emulator. To run code
on the real Z80 computer, I need to write the program to a floppy disk,
which is tedious and slow if you're doing it constantly.

In theory, any Z80 computer can be easily supported. It's the Z80 code
generator that is the hard part. The MSX should be pretty easy to
support I think.

The current state of the Z80 port is that it's partially working, but
it's not complete enough in order to be able to compile a full RTL.
However, simple stuff like this is working on the ZX Spectrum:

program hello;
var
  i: byte;
begin
  PrintChar('F');
  PrintChar('P');
  PrintChar('C');
  for b := 0 to 255 do
    PrintHexByte(b);
end.

So, it's just getting started to become interesting :)

I you want to help, feel free to try it and ask any questions that you
might have. Just keep in mind it's still very early and immature, so
don't expect it to work for serious and complex code yet. But we'll
eventually get there as well. :)

Btw, I also did the i8086 (i.e. 16-bit x86) port a few years ago and in
a way, it was much more difficult, because, at the time, the compiler
wasn't really designed to target anything with less than a 32-bit CPU
and 32-bit ALU. The 8-bit AVR target had been started, but wasn't
mature enough yet, and wasn't really working. Nowadays, FPC supports 8-
bit (AVR), 16-bit (i8086), 32-bit and 64-bit architectures, so the work
is easier in many ways. However, the Z80 still has some unique
challenges, so we'll see how it works out. :)

Nikolay

> 
> Guillermo M.
> 
> El Tue, 14 Apr 2020 22:46:47 +0200
> Sven Barth <pascaldragon at googlemail.com> escribiĆ³:
> > Am 13.04.2020 um 13:08 schrieb Guillermo:
> > > Hi Pascaloids,
> > > 
> > > I've read in the web forums[1] that FPC may include Zylog Z80 as
> > > target, specifically Sinclair's micro computers, but looking at
> > > the
> > > SVN[2] I don't see any Z80 reference.  
> > It's currently in development in a branch: 
> > https://svn.freepascal.org/cgi-bin/viewvc.cgi/branches/z80/
> > 
> > Regards,
> > Sven
> 
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel



More information about the fpc-devel mailing list