Status of Z80 cross compiler? lazarus / 68-Other OS ---------------------------------------------------------------------- Wysardry · 2022-12-20 19:18 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 · 2022-12-20 20:33 Quote from: Wysardry on December 20, 2022, 08:18:57 pmI'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). Quote from: Wysardry on December 20, 2022, 08:18:57 pmwhether 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. Quote from: Wysardry on December 20, 2022, 08:18:57 pm, 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 · 2022-12-21 20:15 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 · 2022-12-22 06:46 Quote from: Wysardry on December 21, 2022, 09:15:45 pmThanks. 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 · 2022-12-23 22:24 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 · 2022-12-23 23:57 Quote from: Wysardry on December 23, 2022, 11:24:17 pmIs 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... Quote from: Wysardry on December 23, 2022, 11:24:17 pmI 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 · 2022-12-24 20:59 Quote from: Wysardry on December 23, 2022, 11:24:17 pmIs 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 · 2022-12-27 18:26 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 · 2022-12-28 13:32 Quote from: Wysardry on December 27, 2022, 07:26:06 pmWould 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. Quote from: Wysardry on December 27, 2022, 07:26:06 pmAlso, 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 · 2022-12-28 17:23 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). ---------------------------------------------------------------------- Wysardry · 2022-12-29 18:36 Quote from: PascalDragon on December 28, 2022, 02:32:36 pmThere 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. QuoteNo, 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 · 2022-12-29 19:15 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. ---------------------------------------------------------------------- Wysardry · 2022-12-30 00:29 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 · 2022-12-30 15:46 Quote from: Wysardry on December 29, 2022, 07:36:52 pmQuote from: PascalDragon on December 28, 2022, 02:32:36 pmThere 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 from: Wysardry on December 29, 2022, 07:36:52 pmQuoteNo, 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. Quote from: Wysardry on December 29, 2022, 07:36:52 pmHow 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. Quote from: Wysardry on December 29, 2022, 07:36:52 pmI 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 · 2022-12-31 00:20 Quote from: PascalDragon on December 30, 2022, 04:46:37 pmWhen 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. QuoteThen 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. ---------------------------------------------------------------------- PascalDragon · 2022-12-31 15:55 Quote from: Wysardry on December 31, 2022, 01:20:27 amI 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. The command line version of Git is what I use as well though without MSYS2, but Git for Windosw directly. But you can see what I meant also in the web interface which is why I gave you that link. Quote from: Wysardry on December 31, 2022, 01:20:27 amQuoteThen 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. Adding a new target is a rather nice beginner task, in fact that was what I had started with as well around 10 years ago. In addition to my adding of MSX-DOS you can also take a look here. The guide might be a bit old, but in general it should still work. ---------------------------------------------------------------------- Wysardry · 2023-01-08 17:41 Thank you. This is starting to sound a lot simpler than I originally thought, although I will still have a lot to learn. I have a related question (that probably doesn't warrant a new thread): would adding another 8-bit CPU be something that a beginner could tackle? I would like to write programs for the 6809 processor and the Dragon 32/64 computers at some point. There are existing cross assemblers available. ---------------------------------------------------------------------- PascalDragon · 2023-01-09 20:32 Quote from: Wysardry on January 08, 2023, 06:41:11 pmI have a related question (that probably doesn't warrant a new thread): would adding another 8-bit CPU be something that a beginner could tackle? I would like to write programs for the 6809 processor and the Dragon 32/64 computers at some point. There are existing cross assemblers available. Adding a new platform is definitely more involved and you should first get familiar a bit more with the compiler. Though you can give it a try...