Tuesday, August 24, 2021

Instruction Format (With reference to address)

 

Instruction Format (With reference to address)

Instruction contains some specific fields: opcode, source/destination operand, source operand address, destination operand address, next instruction address. 

Computers may have instructions of several different length containing varying number of addresses.  According to address reference, there are mainly four types of instruction:

1. Three address instruction

2. Two address instruction

3. One address instruction

4. Zero address instruction


Three Address Instruction

Syntax of three address instruction is,  

Operation Destination, Source 1, Source 2

For Example:  ADD A, B, C

Where A, B, C are the operands. These variable names are assigned to distinct locations in the memory. In above example, operands B and C are called source operands and operand A is called destination operand and ADD is the operation to be performed on the operands. Bits required the three memory addresses of the three operands. If n-bit are required to specify one memory address, 3n bits are required to specify three memory addresses.


Two Address Instruction

Syntax of two address instruction is,

Operation   Destination, Source

For Example: ADD A, B

Where A, B are the operands. These variable names are assigned to distinct locations in the memory. In above example, operands B are called source operands and operand A is serves as both source & destination operand.  ADD is the operation to be performed on the operands. Bits required the two memory addresses of the two operands. If n-bit are required to specify one memory address, 2n bits are required to specify two memory addresses.


One Address Instruction

Syntax of one address instruction is,

Operation Source

For Example: ADD A

This instruction adds the contents of variable A into the processor register called accumulator and stores the sum back into the accumulator destroying the previous content of the accumulator. In this instruction the second operand is assumed implicitly in a unique location accumulator.

Example of one address instruction:

LOAD A (Copy content of memory location A into accumulator)

STORE B (Copies the contents of accumulator into memory location B)


Zero Address Instruction

In this instruction, the locations of all operands are defined implicitly. Such instructions are found in machines that stores operands in a structure called a pushdown stack. Though all the functionalities (like push, pop, TOS...) of stack is included in the instruction execution.

The instruction with only one address will require a smaller number of bits to represent it, and instruction with three addresses will require a greater number of bits to represent it. Three addresses instruction requires more memory accesses (more time required to execute) and one address requires less memory accesses (less time required to execute).


To learn more about Instruction format (with referece to address), watch below video


Video : Instruction format (with reference to address)

Watch more videos click here.


No comments:

Post a Comment