Bank switching can be considered as a way of extending the
address space of processor instructions with some register. Examples: • The original
CDC 160 processor has 12-bit addresses; the follow-up CDC 160-A processor, a follow-on to the CDC 160, has a 15-bit address bus, but there is no way to directly specify the high three bits on the address bus. Internal bank registers can be used to provide those bits. • The
CDC 1604 has 15-bit addresses; the follow-on
CDC 3600 system has an 18-bit address bus, but legacy instructions only have 15 address bits; internal bank registers can be used to provide those bits. Some new instructions can explicitly specify the bank. • A processor with a 16-bit external address bus can only address 216 = 65536 memory locations. If an external
latch was added to the system, it could be used to control which of two sets of memory devices, each with
65536 addresses, could be accessed. The processor could change which set is in current use by setting or clearing the latch bit. The latch can be set or cleared by the processor in several ways; a particular memory address may be decoded and used to control the latch, or, in processors with separately-decoded
I/O addresses, an output address may be decoded. Several bank-switching control bits could be gathered into a register, approximately doubling the available memory spaces with each additional bit in the register. Because the external bank-selecting latch (or register) is not directly connected with the
program counter of the processor, it does not automatically change state when the program counter overflows; this cannot be detected by the external latch since the program counter is an internal register of the processor. The extra memory is not seamlessly available to programs. Internal registers of the processor remain at their original length, so the processor cannot directly span all of bank-switched memory by, for example, incrementing an internal register. Instead the processor must explicitly do a bank-switching operation to access large memory objects. There are other limitations. Generally a bank-switching system will have one block of program memory that is common to all banks; no matter which bank is currently active, for part of the address space only one set of
memory locations will be used. This area would be used to hold code that manages the transitions between banks, and also to process
interrupts. Often a single database spans several banks, and the need arises to move records between banks (as for sorting). If only one bank is accessible at a time, it would be necessary to move each byte twice: first into the common memory area, perform a bank switch to the destination bank, and then actually to move the byte into the destination bank. If the computer architecture has a
DMA engine or a second CPU, and its bank access restrictions differ, whichever subsystem can transfer data directly between banks should be used. Unlike a
virtual memory scheme, bank-switching must be explicitly managed by the running program or operating system; the processor hardware cannot automatically detect that data not currently mapped into the active bank is required. The application program must keep track of which
memory bank holds a required piece of data, and then call the bank-switching routine to make that bank active. However, bank-switching can access data much faster than, for example, retrieving the data from disk storage. == Microcomputer use ==