On Fri, 06 Dec 2019 14:21:15 +0100 (CET)
"Vaclav Peroutka" <vacla...@seznam.cz> wrote:

> Hello,
> 
> 
> 
> I was thinking about how to make a bigger projects where I can possibly need
> more than 64kB of memory on Z80 (or other 8-bit architectures as well). 
> There is a memory mapper in the design and one can map 8kB segments to the 
> range of Z80 CPU.
> 
> 
> 
> 
> Has anybody seen some method how to do it efficiently without too much 
> overhead ? How to set up the SDCC compiler ?

I have a slightly patched SDCC and a modified linker that can do
code banking and automatically bank switch that I use for Fuzix. The
compiler mods are tiny but the linker is a bit more complex, and you also
need to write support code for your platform.

With that I've been happily running 64K of code in a 4 x 16K banked
EPROM, code banked on a ZX Spectrum 128K, and 2 x 32K banks of code on
RC2014 including interrupt handling and multi-tasking.

For code it's not very hard. You need to solve two things
1. Adjust the stack so that you've got an extra word or so to store the
bank info within the call frame
2. Generate code that can be linker patched into a bank to bank call when
needed.

For Z80 I patch SDCC with an option that expects an extra word on the
stack from the caller, and to generate

                PUSH AF
                CALL foo
                POP AF

The linker in turn replaces inter bank calls with

                CALL __bank_n_m
                DEFW foo

or for things like tables of functions it replaces the address with the
address of a stub function that does the call, and then sticks all those
in a 'STUB' segment the app describes.

Data banking is a different game however. If it's big chunks of data for
things like game maps then often all you need is a 'far copy' function.

Alan


_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to