[fpc-devel] Questions about cross-compiling (z80)

BogDan bog_dan_ro at yahoo.com
Sat Feb 12 10:18:22 CET 2022


Hey,

zx spectrum has ~41k or ram available for apps (it has 48k in total but ~7k are needed for screen).
If RTL needs has over 32k it will not be too much left for the application itself.
IMHO the z80 port RTL should have at least two implementations:
- bare-metal which implement all the needed stuff
- zx-spectrum which should use the existing routines/data from spectrum rom (see https://skoolkid.github.io/rom  or http://www.primrosebank.net/computers/zxspectrum/docs/CompleteSpectrumROMDisassemblyThe.pdf )

Also, everything that is not used by the application it should be stripped by the linker (if it has one). Again I'd like to highlight that I'm new to fpc, last time I used pascal it was over 20 years ago :) .

This means, IMHO an empty application (begin;end.) should not produce more than a few bytes of code.

Cheers,
BogDan.


P.S. Sorry for top posting, yahoo email is so difficult to be used with maillists

On Friday, February 11, 2022, 11:38:21 PM GMT+2, Florian Klämpfl via fpc-devel <fpc-devel at lists.freepascal.org> wrote: 





Am 11.02.2022 um 22:20 schrieb BogDan via fpc-devel:
> Hi,
> 
> 
> Thanks a lot for your quick reply.
> 
> Adding ihxutil to path fixed the problem.
> But the size problem is stil there, a simple 2 lines of code "begin; end."  generates over 32k of code. That code should not generate more than 8 bytes of code.

- no smartlinking?
- any high level language comes with some overhead
- begin end. is simply a bad tests. Getting rid of code any useful program needs makes little sense.
- Z80 rtl is probably not optimized for size yet.

E.g. on avrtiny, the smallest program is 94 bytes, most space taken by the interrupt vector table and flash to ram 
copying routines any program needs anyways, but in this case a lot of optimization has been spent in the compiler which 
Z80 didn't receive yet.

> Are there any flags that I need to use to make the code smaller?
> 
> Cheers,
> BogDan.
> 
> 
> 
> On Friday, February 11, 2022, 03:14:46 PM GMT+2, Sven Barth via fpc-devel <fpc-devel at lists.freepascal.org> wrote:
> 
> 
> 
> 
> 
> BogDan via fpc-devel <fpc-devel at lists.freepascal.org> schrieb am Fr., 11. Feb. 2022, 11:09:
>> Hello,
>>
>> According to https://wiki.freepascal.org/Z80 fpc is able to compile pascal code for z80.
>> Sadly I'm a newbie on fpc, therefore I have a few questions:
>>
>> 1. I changed a bit the build script from https://wiki.freepascal.org/Z80#Building and I managed to build fpc, and when I built a simple hello world file, the resulted tzx file seems wrong:
>>   ./ppcrossz80 -n -Tzxspectrum -PZ80 -Fu/path/to/fpc/lib/fpc/3.3.1/units/z80-zxspectrum/rtl -viwn -CX -XX test.pas
>>
>> $ cat test.tzx
>> :105CF800314CEA0188E0214DE6373FED423E000293
>> :105D0800032BBD20FABC20F7FD2288E0F31100FE2A
>> :105D180021FDFD7AED477D121C20FC141236C321AB
>> ....
>>
>> It seems is an IHX format not tzx
>> Also the result for a simple hello world is way too big (over 20k) !
>> I assume that I'm passing wrong params to ppcrossz80. What params should I use? Where I can find more info on this matter?
> 
> You need to make sure that the ihxutil built in utils/ihxutil/<hostcpu>-<hostos>/ is available in PATH, so that the compiler will do the conversion.
> 
>>    
>> 2. Is it possible to add z80 cross compilation target to FP IDE? The FP IDe shows me a few targets, but z80 is not there.
>>
> 
> The text mode IDE can only ever compile for one CPU platform, so you need to build it for Z80. Though I don't know right now whether this is enabled.
> 
> Regards,
> Sven
>>    
> 
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


_______________________________________________
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