Computer Architecture : Instruction Format

The instruction is divided into fields, each a binary number. A machine instruction must contain at least one field, namely the operation code or opcode, that tells the control unit what the instruction is supposed to do. Most instructions contain other fields specifying registers, memory addresses, immediate quantities, addressing modes, and other parameters. The instruction format defines the layout of the bits of an instruction. An instruction format must include an opcode and, implicitly or explicitly, zero or more operands, which are referenced using one of the addressing mode that is available for that machine. The format must, implicitly or explicitly, indicate the addressing mode of each operand. For most instruction sets, more than one instruction format is used. Some of the common instruction format are shown in the figure below :



The above figure shows that the opcode can have different sizes. The opcode can also be broken up into a number of separate fields. Fields containing immediate operands (numbers used as data) can have different sizes. A field containing an address is much larger than a register field. This is because number of registers is small, while size of memory is large. Instructions can have different sizes. The size depends on the number and nature of the individual fields, which will affected by the following aspects :
  • Number of Addressing modes
  • Number of operands
  • Register or Memory
  • Number of Register set
  • Address  range
  • Address granularity


1. Number of Addressing modes : 

A single machine can support different types of addressing modes, and in these addressing modes the number of bits in an instruction is also different. Sometimes as addressing mode can be indicated implicitly. In other cases, the addressing mode must be explicit, and one or more bits will be needed.


2. Number of operands : 

Typical instructions on today's machines provide for two operands. Each operand address in the instruction might require its own mode indicator, or the use of a mode indicator could be limited to just one of the address field. 


3. Register or Memory : 

A machine must have registers so that data can be brought into the CPU for processing. With a single user-visible register (usually called the accumulator), one operand address is implicit and consumes no instruction bits. Even with multiple registers, only a few bits are needed to specify the register. The more that registers can be used for operand references, the fewer bits are needed. But in memory referencing, then the instruction is having larger number of bits to denote the memory location address.


4. Number of Register set : 

A number of machines have one set of general purpose registers, with typically 8 or 16 registers in the set. These registers can be used to store data and can be used to store addresses for displacement addressing. The trend recently has been away from one bank of general purpose registers and toward a collection of two or more specialized sets (such as data and displacement). A number of machines have one set of general purpose registers, with typically 8 or 16 registers in the set. These registers can be used to store data and can be used to store addresses for displacement addressing. The trend recently has been away from one bank of general purpose registers and toward a collection of two or more specialized sets (such as data and displacement). 


5. Address Range : 

For addresses that reference memory, the range of addresses that can be referenced is related to the number of address bits. With displacement addressing, the range is opened up to the length of the address register.


6. Address granularity : 

In a system with 16- or 32-bit words, an address can reference a word or a byte at the designer's choice. Byte addressing is convenient for character manipulation but at word addressing it has to look for memory address for a word or 32 bits data.

Some Examples of Instruction formats :

Zero-address instruction -
  • ADD          ; Add two values from the top of the stack by popping them and store the result                           on top of the stack

One-address instruction -        
  • ADD r1          ; (AC = AC + r1)  (where AC is accumulator)
  • ADD A           ; (AC = AC + A)
  • LOAD B         ; (AC = AC + B)
  • STORE C       ; (C = AC) 

Two-address instruction :
  • ADD r1, A      ; (r1 = r1 + A)
  • ADD A, B      ; (A = A + B)
  • MUL C, D      ; (C = C * D)
  • MOV X, Y     ; (X = Y)

Three-address instruction :

  • ADD A, B, C       ; (A = B + C)
  • MUL X, Y, Z       ; (X = Y * Z)
  • DIV U, V, X        ; (U = V / X) 



Next Topic :

No comments:

Post a Comment