关于 Bank Switching 的含义
The bank switching technique provides a way for computer systems to access more memory than they would otherwise be capable of. When a computer processor is limited to a specific amount of addressable memory space, additional banks of memory can be set up for the processor to use. These separate banks can then be used to switch away from code that is no longer being used, such as read only memory (ROM) used when starting up the computer, and open up banks of memory for multiple users on the system or store memory for other devices on the system.
Bank switching came about as a cost-effective way to keep computers up and running back in the 1980s without having to replace the processor. It found a good deal of use on older 8-bit computer systems, extending the useful life of a computer by simply adding more memory. As newer systems were developed, they also implemented bank switching methods so that programs created on the older systems could still run.
The way bank switching works is by implementing what's called a latch technique. The latch is really just something of a switch that toggles the address space that the computer processor is using. For example, 8-bit computers use a 16-bit address space, meaning that they are only capable of working with 64K, or 65,536, individual memory locations at any given time. When a latch was added, either by means of software or hardware, it could then toggle between multiple banks of memory.
The latch is set up separate from the processor, leaving the bank switching in the hands of an external operation. In some cases, it's simply a bit hiding out in the upper register of memory addresses and toggled as necessary by the computer's operating system or some other software. As the memory fills, the processor can check the bit at the top and toggle to another bank. Other methods of decoding the latch involved bit-addressable ports that granted access to another bank of memory.
Bank switching found its way into a number of video game consoles from the era as well. The ROM cartridges would come equipped with additional hardware built-in that would expand the console beyond its limited available memory space, allowing for better graphics in games and longer game play through additional stages. As technology and techniques improved, however, the method fell out of use. Some modern operating systems can still emulate bank switching in order to operate older software. Many modern embedded computer systems, those computer systems built into some other device or system and typically designed to perform a single task, also still use bank switching due to its cost effectiveness and ease of use.
std::ifstream in("path/to/file", std::ios::binary);