There is a maximum of 7 64K banks, adding 80H to the bank code makes
8000-FFFF is a common write area bank.
Banks are selected by outputting to port 40H basically 2^n for the output
data, bank 0=1, bank 1=2,...,bank 6=40H.
Normally you start with bank 0 + common (output a 9 to port 40h). This
gives you access to lower 32K as bank 0 and upper 32K as write all banks.
You copy code from lower 32K to upper 32K that is common, reading the upper
32K when all are enabled would make no sense but when you write to upper 32K
it writes to all banks.
Now jump to upper 32K to the common code and select desired bank.
Now you have 64K of watever bank you want. When you switch banks you just
make sure to stay in the common code.
To copy data from one bank to another copy the data to lower 32K jump to
lower 32K enable current bank+common bank (add 80H to bank) to make top 32K
write to all banks. Now copy desired data to data buffer in upper RAM and
it will write out to all banks. Reselect current bank without adding common
bank, jump back to upper bank, select desired bank and you are in the
desired bank with data from previous bank.
You only need a small reserved area in upper RAM for common, the lower area
used for transferring data can either be a second reserved area or just a
temporary area that gets saved and restored between switches.
Please note this only allows for 448K of bank switched RAM but on a Z80
running at 4mhz this means 6 users (1 for system + 6 for users).
It a fairly complicated scheme but it gives 64K to each bank (minus maybe
1K).
Randy
www.s100-manuals.com