The computer performs a specific task only when the necessary steps to complete the task are specified. The ordered collection of such steps forms a program. These ordered steps are called instructions. Instructions of a program are stored in main memory at particular addresses and are executed one at a time in sequence unless altered by control-transfer instructions. The control unit reads an instruction from a memory address, decodes and executes it, and then proceeds to the next instruction address until the program completes.
An instruction is represented by a fixed number of bits. The bits of an instruction are divided into groups called fields. Common fields in an instruction format are listed below.
If an instruction word is n bits long, contains k bits for the address field and m bits for the opcode field, then the instruction can directly refer to 2k distinct memory/register locations and can specify 2m distinct operations.
The opcode is the portion of the instruction that tells the CPU what operation to perform. The address field gives the reference to the operand (which may be in memory or in a register). The mode field modifies the meaning of the address field and determines how the operand is to be obtained. Common addressing modes include:
Whether a particular addressing mode is available depends on the instruction set architecture and the instruction format; the mode field provides the necessary specification so the control unit can form the effective address.
The CPU internal organisation strongly influences the instruction format and the number of address fields required by instructions. Three common CPU organisations are listed below.
All arithmetic and logical operations use a single, implied accumulator register AC. The instruction format typically contains a single address field which names a memory location. The operation is performed between the accumulator and the memory operand. Example instruction: ADD X, where X is the memory address of the operand. Load and store instructions (for example LOAD X, STORE X) are used to transfer data between memory and the accumulator.
The CPU has several general-purpose registers and instructions explicitly reference these registers. Typical instruction formats contain multiple register address fields. For arithmetic operations that specify three registers, an instruction may look like ADD R1, R2, R3, meaning R1 ← R2 + R3 (result in R1). This organisation supports fewer memory references in arithmetic instructions and allows compact expression of computations in registers.
A stack machine uses a last-in, first-out stack for intermediate results. Computational instructions typically have no explicit address fields; they implicitly operate on the top elements of the stack. For example, the instruction ADD pops the two top values from the stack, adds them and pushes the result back on the stack. Instructions that manipulate the stack (for instance PUSH X, POP X) may require an address field to move data between memory and the stack.
Instructions are often classified by the number of explicit address fields they contain. The common categories are three-address, two-address, one-address and zero-address instructions. Each class affects program length, instruction complexity and instruction word size.
Each instruction specifies two operand locations and a distinct result location. A conventional three-address instruction has the form:
Two-address formats are common in commercial machines. Each address field may reference a register or a memory word. One of the addresses commonly serves as both a source and the destination.
One-address machines generally use an implied accumulator register AC. The instruction format contains a single address field that names a memory location. An operation is performed between the accumulator and the memory operand and the result is left in the accumulator.
Zero-address instructions do not include operand address fields for computational operations. The operands are implicitly taken from the stack top. Examples of such instructions are ADD, SUB, MUL, DIV which pop the required operands from the stack, perform the operation and push the result back. Stack manipulation instructions like PUSH and POP may require an address field to transfer data between memory and the stack.
Consider the arithmetic expression X = (A + B) × (C + D). The number and form of instructions required to evaluate this expression depend on the instruction format (zero, one, two or three address). The following sequences illustrate the differences. It is assumed that the machine has two processor registers R1 and R2 where usable; the notation M[A] denotes the contents of memory at address A. A temporary memory location T may be used in formats that cannot hold all intermediate values in registers.
The image above shows a representative sequence for one of the formats. The other sequences are in the images below and they illustrate how the number of instructions and the use of temporaries or registers vary with the instruction format.
In the sequences above, T denotes a temporary memory location used to store an intermediate result when the instruction format or register availability prevents holding that result in a register. The choice between using registers or memory temporaries affects both instruction count and execution time.
Instruction formats are a trade-off among instruction word size, program density, simplicity of the CPU control unit and execution speed. Key points to remember:
| 1. What are the different types of instruction formats? | ![]() |
| 2. What is the purpose of an instruction format? | ![]() |
| 3. What is the difference between RISC and CISC instruction formats? | ![]() |
| 4. How are instruction formats related to CPU performance? | ![]() |
| 5. Can instruction formats be changed or updated? | ![]() |
![]() | Explore Courses for Computer Science Engineering (CSE) exam |
![]() | Get EduRev Notes directly in your Google search |