Zero page
From Wikipedia, the free encyclopedia
The zero page is the memory address page at the absolute beginning of a computer's address space (the lowermost page, covered by the memory address range 0 ... page size−1).
In early computers, including the PDP-8, the zero page had a special fast addressing mode, which facilitated its use for temporary storage of data and compensated for the relative shortage of CPU registers. The PDP-8 had only one register, so zero page addressing was essential.
Possibly unimaginable by computer users after the 1980s, the RAM of a computer used to be faster than or as fast as the CPU during the 1970s. Thus it made sense to have few registers and use the main memory as substitutes. Since each memory location within the zero page of a 16-bit address bus computer may be addressed by a single byte, it was faster, in 8-bit data bus machines, to access such a location rather than a non-zero page one.
For example, the MOS Technology 6502 has only one general purpose register. As a result, it used the zero page extensively. Many instructions are coded differently for zero page and non-zero page addresses:
LDA $00 ; zero page LDA $0000 ; non-zero page
The above two instructions both do the same thing; they load the value of memory location $00 into the A register. However, the first instruction is only two bytes long and also faster than the second instruction. Unlike today's RISC processors, the 6502's instructions can be from one byte to three bytes long.
Zero page addressing now has mostly historical significance, since the developments in integrated circuit technology have made adding more registers to a CPU less expensive, and have made CPU operations much faster than RAM accesses. Some computer architectures still reserve the beginning of address space for other purposes, though; for instance, the Intel x86 systems reserve the first 512 words of address space for the interrupt table.
In fact, quite contrary to the zero page's original preferential use, some modern operating systems such as Linux and Microsoft Windows actually make the zero page inaccessible to trap uses of NULL pointers. This is useful, as NULL pointers are the method used to represent the value of a reference that points to nothing. Since code operating on a reference will be written assuming it that the reference actually refers to some valid structure or value, catching the case where the reference points to nothing is of use since it is a sure sign of a bug.
[edit] CP/M
In 8-bit CP/M, the zero page is used for communication between the running program and the operating system. See Zero page (CP/M) for more information.