Am 10.01.20 um 18:46 schrieb Alan Cox: > On Thu, 9 Jan 2020 16:45:58 +0100 > Philipp Klaus Krause <p...@spth.de> wrote: >> […] >> For Z180 and eZ80 we know the hardware. But there are still many ways to >> set up stuff (different sizes of banked areas, etc). > > No you don't actually. There are many of Z180 systems with a flat 64K > address space because the Z180 was an upgrade board to the Z80 originally > present and the original banking is used. Some of the more common old > ones are even hybrids (eg the XLR8R cards for the TRS80 have 256K of > Z180 linear space but the base system memory is 128K banked in 32K > chunks). > > Not as common as with 65C816 (where some poor design decisions in the CPU > make it often better to use external banking) but still not unusual, and > in fact present even on current retrobrew hardware when you for example > put a Z180 CPU board in an existing RC2014 Z80 system.
I see. That makes implementation actually easier, as we could just do the same for all z80-related ports. > > Fuzix does the following > > 1. A small patch that adds a compiler option to selecte 'banked' compiles > > This just changes the argument offset on the stack by two bytes, and > causes the compiler to emit > > push af > call foo > pop af > > for function calls. > > The existing stuff to set the code segment name is used so you compile > stuff into _CODE1 _CODE2 _CODE3 etc (and some names for common). > > The compiler piece is trivial but important because those extra two bytes > are essential in order to make bank unwinding work properly in all cases. Why do you need two bytes? I would have guessed that one should be enough. The approach of essentially treating all calls as banked is interesting. Maybe this could be implemented as a new memory model (e.g. --model-large, similar to how this is implemented for stm8, making function pointers 24 bits). I'd still like to have banked calls in the normal memory model, handled differently from normal calls. > > The linker looks for calls that go between banks or banks and common > > If a relocation is from code to code then it swaps the push af/call/pop af > with > > call __bank_n_m ; where n/m are the banks > .word funcaddr > > and the platform provides specific banking functions according to need. > The extra push/pop af is removed and the extra 2 bytes on the stack are > needed by the bank switching code (it uses it to push the address of the > correct stub to switch back) > So you have one stub per bank? Philipp
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user