At a top level, a computer consists of processor, memory, and I/O components, with one or more modules of each type. These components are interconnected in some fashion to achieve the main function of the computer, which is to execute programs. Thus, there are four main structural elements: • Processor: Controls the operation of the computer and performs its data processing functions. When there is only one processor, it is often referred to as the central processing unit (CPU). • Main memory: Stores data and programs. This memory is typically volatile; that is, when the computer is shut down, the contents of the memory are lost. In contrast, the contents of disk memory are retained even when the computer system is shut down. Main memory is also referred to as real memory or primary memory. • I/O modules: Move data between the computer and its external environment. The external environment consists of a variety of devices, including secondary memory devices (e. g., disks), communications equipment, and terminals. • System bus: Provides for communication among processors, main memory, and I/O modules. One of the processor’s functions is to exchange data with memory. For this purpose, it typically makes use of two internal (to the processor) registers (MAR), which specifies the address in memory for the next read or write. (MBR), a memory buffer register which contains the data to be written into memory or which receives the data read from memory. Similarly (I/OAR) I/O address register specifies a particular I/O device. An I/O buffer register (I/OBR) is used for the exchange of data between an I/O module and the processor. PROCESSOR REGISTERS
A processor includes a set of registers that provide memory that is faster and smaller than main memory. Processor registers serve two functions: • User-visible registers: Enable the machine or assembly language programmer to minimize main memory references by optimizing register use. For high- level languages, an optimizing compiler will attempt to make intelligent choices of which variables to assign to registers and which to main memory locations. Some high-level languages, such as C, allow the programmer to suggest to the compiler which variables should be held in registers. • Control and status registers: Used by the processor to control the operation of the processor and by privileged OS routines to control the execution of programs.
A user-visible register may be referenced by means of the machine language that the processor executes and is generally available to all programs, including application programs as well as system programs. Types of registers that are typically available are data, address, and condition code registers. Data registers can be assigned to a variety of functions by the programmer. In some cases, they are general purpose in nature and can be used with any machine instruction that performs operations on data. Often, however, there are restrictions. For example, there may be dedicated registers for floating-point operations and others for integer operations. Address registers contain main memory addresses of data and instructions, or they contain a portion of the address that is used in the calculation of the complete or effective address. These registers may themselves be general purpose, or may be devoted to a particular way, or mode, of addressing memory. Examples include the following: • Index register: Indexed addressing is a common mode of addressing that involves adding an index to a base value to get the effective address. Segment pointer: With segmented addressing, memory is divided into segments, which are variable-length blocks of words. A memory reference consists of a reference to a particular segment and an offset within the segment • Stack pointer: If there is user-visible stack2 addressing, then there is a dedicated register that points to the top of the stack. This...