Recent

Author Topic: Status of Z80 cross compiler?  (Read 5705 times)

Wysardry

  • Jr. Member
  • **
  • Posts: 69
Status of Z80 cross compiler?
« on: December 20, 2022, 08:18:57 pm »
Can anyone point me to documentation on the current status of the Z80 cross compiler and what the roadmap might be?

The Z80 wiki page doesn't have much info on it yet.

I'm particularly interested in knowing which compile modes it supports (and will support), whether compiled programs will be able to read and write to files on tape and disk, and what would be involved in adding new platforms.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5469
  • Compiler Developer
Re: Status of Z80 cross compiler?
« Reply #1 on: December 20, 2022, 09:33:34 pm »
I'm particularly interested in knowing which compile modes it supports (and will support),

All compile modes are supported, however not all units might be as they might be larger than what the system supports (e.g. the SysUtils unit is not compiled by default for the supported Z80 platforms, because it's larger than 64k).

whether compiled programs will be able to read and write to files on tape and disk

That depends upon the RTL support. At least for MSX-DOS reading/writing files is supported.

, and what would be involved in adding new platforms.

Check the commits that added MSX-DOS support then you know essentially what needs to be done.

Wysardry

  • Jr. Member
  • **
  • Posts: 69
Re: Status of Z80 cross compiler?
« Reply #2 on: December 21, 2022, 09:15:45 pm »
Thanks. Do you happen to know if everything I would need (on Windows) can be installed and set up with fpcupdeluxe or would I need to do it manually?

I noticed on the FP site that Z80 support is now in trunk.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5469
  • Compiler Developer
Re: Status of Z80 cross compiler?
« Reply #3 on: December 22, 2022, 07:46:49 am »
Thanks. Do you happen to know if everything I would need (on Windows) can be installed and set up with fpcupdeluxe or would I need to do it manually?

I don't know if fpcupdeluxe provides anything for Z80. I personally only set up my environments manually.

Wysardry

  • Jr. Member
  • **
  • Posts: 69
Re: Status of Z80 cross compiler?
« Reply #4 on: December 23, 2022, 11:24:17 pm »
Thanks. I'll look into what's involved with that.

Is there any advantage to installing Lazarus for this particular project? Would it add anything useful, or just make the process more complicated than it needs to be.

I was considering using a simpler editor, such as Geany or CudaText.

Bogen85

  • Hero Member
  • *****
  • Posts: 595
Re: Status of Z80 cross compiler?
« Reply #5 on: December 24, 2022, 12:57:30 am »
Is there any advantage to installing Lazarus for this particular project? Would it add anything useful, or just make the process more complicated than it needs to be.

The answer to that is very subjective. For me the Lazarus IDE is very "complicated" and I see no value in it as I'm not doing GUI work.
But many others who use Free Pascal like the Lazarus IDE and recommend it for all things Free Pascal related...

So, like I said, subjective...

I was considering using a simpler editor, such as Geany or CudaText.

I use CudaText (and a terminal, with a Makefile in my project to build it with FPC).

I don't have time to be overwhelmed by an IDE that I've not figured out what benefits it really adds... (where those benefits outweigh the complications that come with it)

Same with the likes of Microsoft's VSCode and IntelliJ, I've tried to force myself for weeks at the time to get use to them and learn to appreciate the value they supposedly add...
They do add some value, I will agree. But at the cost of being too complex and overwhelming overall as an environment to develop software in.

And always go back to something simple like CudaText, my project sources, a Makefile in those, and a terminal...
So to me Lazarus feels to be along the same vein. Too overwhelming and I can't get past that to appreciate the value it adds.


PascalDragon

  • Hero Member
  • *****
  • Posts: 5469
  • Compiler Developer
Re: Status of Z80 cross compiler?
« Reply #6 on: December 24, 2022, 09:59:48 pm »
Is there any advantage to installing Lazarus for this particular project? Would it add anything useful, or just make the process more complicated than it needs to be.

Lazarus provides code completion and other such gimmicks. Whether you use them with Windows or for embedded development doesn't matter, they make working with code easier nevertheless.

Wysardry

  • Jr. Member
  • **
  • Posts: 69
Re: Status of Z80 cross compiler?
« Reply #7 on: December 27, 2022, 07:26:06 pm »
Thanks. I'll try both options.

Would I need to change any of the existing code to add a new Z80 machine or will the existing system automatically look for the right files and directories based on the name provided to it?

Also, is there existing code for memory bank switching for machines with over 64Kb RAM? I know the later Spectrum models used bank/page switching to allow the CPU to access more memory, although I never used one.

I did own an Enterprise 128 and an Amstrad CPC6128, both of which had a similar feature. I vaguely remember the Memotech MTX series and the Sam Coupe also having models with 128Kb or more.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5469
  • Compiler Developer
Re: Status of Z80 cross compiler?
« Reply #8 on: December 28, 2022, 02:32:36 pm »
Would I need to change any of the existing code to add a new Z80 machine or will the existing system automatically look for the right files and directories based on the name provided to it?

There is no automatism for this. As I said, look at the changes I did for MSX-DOS to see what needs to be done.

Also, is there existing code for memory bank switching for machines with over 64Kb RAM? I know the later Spectrum models used bank/page switching to allow the CPU to access more memory, although I never used one.

No, there is no preexisting mechanism for that especially as that mechanism is board-specific. What my plan was - for MSX-DOS - is to use far calls and data for this as a transparent mechanism from the language side with a platform specific implementation for it.

af0815

  • Hero Member
  • *****
  • Posts: 1291
Re: Status of Z80 cross compiler?
« Reply #9 on: December 28, 2022, 06:23:33 pm »
Bankswitiching CPC :
http://norecess.cpcscene.net/advancedmemoryusage.html
MSX (2)
https://blog.qiqitori.com/2022/11/msx-msx2-bank-switching-and-short-simple-ram-test-in-basic/

ZXSpectrum:
https://github.com/tebl/ZX-Interface-2.021/blob/main/documentation/bank_switching.md

Common is, a Z80 can only adressing 64k. All other must be done with hardware support and every system have it own switching. Common is most, a call to the banking registers with a out command. And you must take care not to switch the bank, where your code is running :-) and the interrupts must be disabled for this. After the bank is switched, must have to take care if the bank 0 was switched. The interrupthandlers depends on the mode of interrupt. And this handler should not destroyed by the switichg mechanismen (or copied to the new bank).


regards
Andreas

Wysardry

  • Jr. Member
  • **
  • Posts: 69
Re: Status of Z80 cross compiler?
« Reply #10 on: December 29, 2022, 07:36:52 pm »
There is no automatism for this. As I said, look at the changes I did for MSX-DOS to see what needs to be done.
As there are over 21,000 files in the source directory, I had hoped that finding the changes for MSX-DOS would only require me to look at files with "MSX" somewhere in the file name.

Quote
No, there is no preexisting mechanism for that especially as that mechanism is board-specific. What my plan was - for MSX-DOS - is to use far calls and data for this as a transparent mechanism from the language side with a platform specific implementation for it.
Thanks. It would make sense for me to wait until you have implemented that before I attempt anything similar for other platforms.

How do those working on the Z80 platforms usually coordinate their efforts? Is it just via this "Other OS" subforum?

I noticed a couple of files for the Amstrad CPC series as I was browsing through.  Is there a list of machines that are being worked on by someone?

I had the Enterprise 64/128 and the Sharp MZ-700 (which is highly compatible with the MZ-80K) in mind for my own efforts, if I can get my head around how much time and effort would be involved compared with learning and using C with an existing cross compiler.

af0815

  • Hero Member
  • *****
  • Posts: 1291
Re: Status of Z80 cross compiler?
« Reply #11 on: December 29, 2022, 08:15:15 pm »
I know the internal of MSX1/MSX2/MSX2+ Z80 based computers in hard and software very good.

On a MSX you have in the runnig enviroment od MSX-DOS - it was a extended CP/M by ASCII-Corp - and special calls for Slot reading, writing, switiching and far calls are implemented by the MSX-System itself and the DISK-ROM
Quote
       +------+------+------+------+------+------+------+------+
 0000h |    Reboot entry    |  Reserved   |   MSX-DOS entry    |
       +------+------+------+------+------+------+------+------+
 0008h |  RST 08h not used         | RDSLT routine entry point |
       +------+------+------+------+------+------+------+------+
 0010h |  RST 10h not used         | WRSLT routine entry point |
       +------+------+------+------+------+------+------+------+
 0018h |  RST 18h not used         | CALSLT routine entry point|
       +------+------+------+------+------+------+------+------+
 0020h |  RST 20h not used         | ENASLT routine entry point|
       +------+------+------+------+------+------+------+------+
 0028h |  RST 28h not used         |          not used         |
       +------+------+------+------+------+------+------+------+
 0030h | CALLF routine entry point |          not used         |
       +------+------+------+------+------+------+------+------+
 0038h |  Interrupt vector  |                                  |
       +------+------+------+                                  +
This special parts were prepared by the MSX-Roms for loading the DOS. So waiting for a "far call" is not a waiting point. Because how shold this work ? A bankswitiching can also switch a ROM Bank into the CPU Memory area. And the banks are not fixed (except the starting layout in MSX). So you did not know is a bank empty, RAM or ROM. For a MSX there was some rules to find out what is going on :-) But this is nothing you can solve with a simple fast call. Maybe it is possible on a simulator, but in the world of MSX, nearly nothing was fixed, you have to query all. :-) If you go back more in history and look at the spectravideo computers, you see more was fixed, but used only by one company. MSX was produced by a lot of companies. In Europe the were only some companies visible, but is was a worldwide standard. I have bougth and used hard and software from japan and it was working on a european philips MSX computer.

Maybe other companies produce home computers with z80 and extend the ram/rom use similar techniques.   
regards
Andreas

Wysardry

  • Jr. Member
  • **
  • Posts: 69
Re: Status of Z80 cross compiler?
« Reply #12 on: December 30, 2022, 01:29:56 am »
There is also information on how to do bank switching in Z80 assembly on the Amstrad CPC, MSX, ZX Spectrum, Enterprise, Sam Coupe, Gameboy/GBC and Sega Master System/Game Gear starting here that might help.


PascalDragon

  • Hero Member
  • *****
  • Posts: 5469
  • Compiler Developer
Re: Status of Z80 cross compiler?
« Reply #13 on: December 30, 2022, 04:46:37 pm »
There is no automatism for this. As I said, look at the changes I did for MSX-DOS to see what needs to be done.
As there are over 21,000 files in the source directory, I had hoped that finding the changes for MSX-DOS would only require me to look at files with "MSX" somewhere in the file name.

When I say to look “at the changes” I assume you make the necessary transfer to make use of the version control system that FPC uses and thus look at the history.

Quote
No, there is no preexisting mechanism for that especially as that mechanism is board-specific. What my plan was - for MSX-DOS - is to use far calls and data for this as a transparent mechanism from the language side with a platform specific implementation for it.
Thanks. It would make sense for me to wait until you have implemented that before I attempt anything similar for other platforms.

Then you might have to wait a long time, because it's a very low priority task on my very long ToDo list.

How do those working on the Z80 platforms usually coordinate their efforts? Is it just via this "Other OS" subforum?

There is no need for coordination until now, cause the only developers who implemented something for the Z80 are Nikolay and me who are both FPC core developers and we implemented two different operating systems with quite some time having passed between these implementations, thus “coordination” through the repository was enough.

I noticed a couple of files for the Amstrad CPC series as I was browsing through.  Is there a list of machines that are being worked on by someone?

No, there is no list. Best is to check who authored corresponding files/changes.

Wysardry

  • Jr. Member
  • **
  • Posts: 69
Re: Status of Z80 cross compiler?
« Reply #14 on: December 31, 2022, 01:20:27 am »
When I say to look “at the changes” I assume you make the necessary transfer to make use of the version control system that FPC uses and thus look at the history.
At this point, I'm still trying to assess whether adding new platforms to such a large existing codebase would be my best option as a relative novice.

I used fpcupdeluxe to download FPC trunk rather than via a version control system, as I haven't used one before. I have only ever used the command line version of Git that is part of MSYS2 and even then I did not make any changes to the downloaded code before compiling.

Quote
Then you might have to wait a long time, because it's a very low priority task on my very long ToDo list.
It isn't that high a priority for me either, as so few Z80 machines even had more than 64Kb of memory.

I would also have a lot to learn before I could add support for another machine to the same level as you have already done for MSX-DOS.

 

TinyPortal © 2005-2018