Computer Organization and Design
Instruction Codes

Instruction Codes

In this section, we introduce a basic computer and demonstrate how its operation can be specified using register transfer statements. The organization of the computer is defined by its internal registers, the timing and control structure, and the set of instructions it uses. The design of the computer is then carried out in detail. Although the basic computer presented here is much smaller compared to commercial computers, it is simple enough to illustrate the design process without excessive complexity.

Internal Organization of a Digital System

The internal organization of a digital system is defined by the sequence of micro-operations it performs on data stored in its registers. A general-purpose digital computer is capable of executing various micro-operations and, in addition, can be instructed as to the specific sequence of operations it must perform. Users can control this process via a program. A program is a set of instructions that specify the operations, operands, and the sequence in which processing must occur. By specifying a new program with different instructions or the same instructions with different data, the data-processing task can be altered.

Computer Instructions

A computer instruction is a binary code that specifies a sequence of micro-operations for the computer. Both instruction codes and data are stored in memory. The computer reads each instruction from memory, places it in a control register, and then the control unit interprets the binary code of the instruction, executing it by issuing a sequence of micro-operations. Every computer has its own unique instruction set. The ability to store and execute instructions, known as the stored program concept, is the most important property of a general-purpose computer.

Instruction Code Structure

An instruction code is a group of bits that instruct the computer to perform a specific operation. It is typically divided into parts, each with its own particular interpretation. The most basic part of an instruction code is the operation code (opcode). The opcode is a group of bits that define operations such as add, subtract, multiply, shift, and complement. The number of bits required for the opcode depends on the total number of operations available in the computer.

For example, consider a computer with 64 distinct operations. The opcode must consist of at least 6 bits since 26=642^6 = 64. If the ADD operation is assigned the bit configuration 110010, the control unit decodes this opcode, reads an operand from memory, and adds the operand to a processor register.

Hello

Operation and Micro-operations

An operation code is part of an instruction stored in computer memory, which tells the computer to perform a specific operation. The control unit receives the instruction from memory, interprets the operation code bits, and issues a sequence of control signals to initiate micro-operations in internal computer registers. For each operation code, the control unit issues a sequence of micro-operations needed for the hardware implementation of the specified operation. Hence, an operation code is sometimes called a macro-operation because it specifies a set of micro-operations.

Specifying Operands

The operation part of an instruction code specifies the operation to be performed. This operation must be performed on some data stored in processor registers or in memory. Thus, an instruction code must specify not only the operation but also the registers or memory words where the operands are located, as well as the register or memory word where the result will be stored.

Memory words can be specified in instruction codes by their address. Processor registers can be specified by assigning another binary code of k bits within the instruction, specifying one of 2k2^k registers. There are many variations for arranging the binary code of instructions, and each computer has its own particular instruction code format.

Stored Program Organization

The simplest way to organize a computer is to have one processor register and an instruction code format with two parts: the opcode and the address. The memory address tells the control unit where to find an operand in memory. This operand is read from memory and used as the data to be operated on, together with the data stored in the processor register.

For example, in a memory unit with 4096 words, 12 bits are needed to specify an address since 212=40962^{12} = 4096. If each instruction code is stored in a 16-bit memory word, 4 bits are available for the opcode (specifying one of 16 possible operations), and 12 bits are available to specify the address of an operand. The control unit reads a 16-bit instruction from the program portion of memory, uses the 12-bit address part to read a 16-bit operand from the data portion of memory, and then executes the operation specified by the opcode.

Accumulator (AC)

Computers with a single-processor register typically label it as the accumulator (AC). Operations are performed with the memory operand and the content of the AC. If an instruction's operation does not require a memory operand, the remaining bits in the instruction can be used for other purposes. For instance, operations such as clear AC, complement AC, and increment AC operate on data stored in the AC register and do not need a memory operand. Therefore, the second part of the instruction code (bits 0 through 11) is available for other uses.

Indirect Addressing

In some cases, it is convenient to use the address bits of an instruction code not as an address but as the actual operand. When the second part of an instruction code specifies an operand, it is an immediate operand. When it specifies the address of an operand, it is a direct address. There is also the possibility of indirect addressing, where the bits in the second part of the instruction designate the address of a memory word that contains the operand's address. A single bit in the instruction code can distinguish between a direct and an indirect address.

For example, consider an instruction code with a 3-bit opcode, a 12-bit address, and an indirect address mode bit designated by I. If I = 0, it is a direct address instruction. If I = 1, it is an indirect address instruction. In the case of a direct address instruction, the operand is located in the specified address in memory. In an indirect address instruction, the address part specifies a memory location that contains the address of the operand.

Hello

Effective Address

The effective address is the address of the operand in a computation-type instruction or the target address in a branch-type instruction. In a direct address instruction, the effective address is the address part of the instruction. In an indirect address instruction, the effective address is found by first going to the address part specified in the instruction to retrieve the operand's address, and then accessing the operand.

By using these addressing modes, the basic computer can efficiently handle operations and data stored in memory.