Bank switching

From Computer History Wiki
Jump to: navigation, search

Bank switching is a form of memory management, but with a different purpose from most other forms of memory management (such as the early base and bounds mechanism). It is generally not intended to either i) prevent one user from interfering with another (in a multi-programming system), or ii) hide the real addresses a program is occupying in main memory (instead of providing virtual addresses, so that the program appears to always be in the same location, every time it is run).

Rather, it is most commonly found in machines whose CPU architecture provides a limited address space - less than the amount of real memory which it is desirable to have on the machine. This was a common problem in early machines, whose designers often failed to correctly foresee either the future economics of memory, or the demand for it from software. To be fair, though, it's not a trivial problem; supporting longer addresses (needed for more memory) has costs (e.g. needing longer instructions and registers), which are incurred from the start of the design's lifetime; whereas the benefits are only received later on.

In bank switching, the machine's main memory is divided into 'banks' (hence the name), each usually the size of the machine's basic address space. The running program uses the current bank, until a special operation is used to switch to a different bank. (In some systems, instructions are fetched from one bank, and data from a potentially different bank.)

A variety of low-level mechanisms are possible to achieve this. Perhaps the most common is to have a 'current bank' register (usually in the CPU; if the current bank can be different for instructions and data, there would be two such registers). A current bank register can have a new value loaded into it either explicitly (perhaps by a special instruction), or implicitly. An example of the latter is on machines which have main memory words, and registers, which are larger than the machine's basic address: use of a register's, or memory word's, contents which are not zero in the high-order bits (above the bits needed to hold the basic address) as the address for a memory operation causes the current bank register to be loaded with those high-order bits, as a side-effect of the operation. On machines which have separate current bank registers for instructions and data, operations like jumps would load the current instruction bank register, whereas normal data references would load the other.

Other mechanisms are also possible; for example, memory banks could be disabled, so that only the current bank can respond to memory operations. (This approach would avoid needing to modify the CPU<->memory bus to have more address bits.)