11.2 Register-based machines
The general organization of a machine is often referred to as its architecture. Over the years, computer scientists and engineers have explored a wide variety of computer architectures. This section introduces the most popular architecture – the register-based machine. Our study of register-based machines will be aided by reference to the Watson Virtual Machine. While the Watson Virtual Machine (VM) is a “toy” computer, designed solely for the purpose of instruction, it embodies most of the major features of register-based machines and does exist as a fully programmable software simulation (the Watson assembly lab).
The Watson Virtual Machine is presented in Figure 11.1. The Watson VM consists of two major parts: a main memory and a CPU (Central Processing Unit). These two components are connected together via a third component, called the data bus, which allows information to be copied between the CPU and main memory.
Figure 11.1: The Watson Virtual Machine
The purpose of main memory is to store computer programs and the data on which they act. The main memory of the Watson Virtual Machine can be visualized as a list, or array, of 256 storage locations, numbered 0 to 255. Each of these locations is individually addressable. In other words, the main memory unit can be given an address and told to retrieve a value from that location, or be given an address and told to write a value to that location.
The purpose of the Central Processing Unit, or CPU, is to perform the arithmetic and logic functions specified by the instructions of a computer program. CPU’s are complex devices composed of many functional units. One of the most prominent features of the CPU’s of register-based machines is a large collection of general-purpose registers. The Watson Virtual Machine contains sixteen of these registers – labeled 0-9 and A-F.
Registers can be directly manipulated by the arithmetic and logic units of the CPU. Main memory locations cannot. Thus, in order to perform any kind of arithmetic or logic operation on values stored in main memory it is necessary to copy those values into CPU registers, manipulate the contents of the registers in the desired way, and then copy the computed results back to main memory. For example, in order to add two numbers stored in main memory locations, the computer must:
In addition to the general-purpose registers, there are a number of special-purpose registers important to the operation of the CPU. These registers include the instruction register, the program counter, and the status bits. The instruction register holds a copy of the program instruction that the CPU is currently executing. The program counter contains the address of the next instruction to be executed. The status bits are used to hold information about the most recently performed computation – was a carry generated? Was the result zero? Or negative? Did an overflow occur?
We’ll not worry too much about these special-purpose registers right now. They are described in detail in Section 11.5. At this point, I just want you to know they exist.
Real world computers are similar to the Watson Virtual machine in that they contain a main memory, CPU, and data bus. The Watson Virtual Machine differs from real machines in that it has no I/O devices (such as keyboards, display screens, mice, and modems); nor any long-term storage devices (like disk drives). The size of its memory is also very small, containing only 256 “words”. Modern computers typically have memories capable of storing hundreds of millions of words. There are other differences between the Watson VM and real-world computers, such as the size of the numbers it can manipulate and the limited number of commands in its machine language.