On Thu, 4 Aug 2022 09:06:35 +0200
Philipp Klaus Krause <p...@spth.de> wrote:

> Am 29.05.22 um 21:44 schrieb Tony Pavlov via Sdcc-user:
> 
> > 
> > another annoying thing is one byte hidden parameter for the bank number on 
> > the Z80 target.
> > inc sp/dec sp everywhere, while on gbz80 two bytes are reserved - that is 
> > much faster! why
> > not unify that? also, on systems like MSX you may want to save/restore more 
> > than one page
> > and two bytes may be very useful here!
> > 
> >   
> 
> Well, I'm personally not very familiar with all that banking stuff. I 
> try not to break it, but otherwise leave it to other sdcc devs (or wait 
> for patches from users). But since I'm not that familiar with it, I'm 
> reluctant to make changes that might be a problem for other users.

You actually want the smarts in the linker not the compiler IMHO
(especially on Z180 and R2K/R3K).

On Z80 with the Fuzix patches for transparent banked support I use

                push af
                call foo
                pop af

which has a cost but creates the needed consistent extra stack offset for
all functions. The linker rewrites those 5 bytes into something else for
a cross bank (or overlay..) function. That allows arbitrary calling
between banks to work properly as you've got the 2 bytes needed.
Typically it's something like

                call __bank1_2           ; from 1 to 2
                .word foo

You also have to rewrite function pointers for it to work properly so
that any function pointer is turned into the address of a stub in common
space that does the banked call needed. This is also needed for standards
compliance so that all references to the address of the function give the
same value.

R2K/R3K is a bit different because the processor is designed to keep a
rolling window of paged in code with most common space for data but apart
from having extra hardware support the same basic logic applies along
with rather more linker magic to pack functions so no function crosses an
8K boundary. It's something the official compiler does (did - it's
basically dead software you have to run under emulators) but would be a
big change to the very primitive linker SDCC relies upon.

Whether explicit or automatic banking is the best option is another topic
altogether and does depend a lot on use cases

Alan


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

Reply via email to