Different Addressing Modes used in Addressing

Different Addressing Modes

~By Anonyo Sanyal
The operation field of an instruction specifies the operation to be performed. This operation must be executed on some data stored in computer registers or memory words. The way the operands are chosen during program execution is dependent on the addressing mode of the instruction. The addressing mode specifies a rule for interpreting or modifying the address field of the instruction before the operand is actually referenced. Computers use addressing mode techniques for the purpose of accommodating one or both of the following provisions:
1. To give programming versatility to the user by providing such facilities as pointers to memory, counters for loop control, indexing of data, and program relocation.
2. To reduce the number of bits in the addressing field of the instruction.

In simpler words, it can be compared to the addressing of a particular location on earth. Just like we have different ways to reach a particular address using the various method of addressing modes. For example, we might have the direct address of a particular location. In this case, we directly reach the Location. It might also happen that we have the address of a third party who knows the address of the desired location. What do we do then? We reach the third party according to the address I have, then I take the address from him of the desired location then I reach my particular location. Similarly, a computer also uses a different type of addressing methods known as addressing modes. And what does it's desired location is, it is the location where the operand resides.

Implicit Addressing Mode

This is also known as implied mode. In this mode, the operands are specified implicitly in the definition of the instruction. For example, CMA(Complement Accumulator) is an implicit instruction because the operand in the accumulator register is implied in the definition of the instruction that uses an accumulator are implied mode instructions.
Examples:-
CMA->Complements the contents of the accumulator i.e. invert 0's to 1's and 1's to 0's
RLC->Rotate Accumulator Left through Carry Flag.

Immediate Addressing Mode



In this mode, the operand is specified in the instruction itself. In other words, an immediate mode instruction has an operand field instead of an address field. The operand field contains actual operand to be used in conjunction with the operation specified in the instruction. Immediate mode instructions are useful for initializing registers to a constant value


Direct Addressing Mode




In this mode, the effective address is equal to the address part of the instruction. the operand resides in the main memory and its address is given directly by the address field of the instruction. In a branch-type instruction, the address field specifies the actual branch address.


Indirect Addressing Mode


In this mode, the address field of the instruction gives the address where the effective address is stored in the memory. Effective Address(EA) which means the address where we will find our operand or data. Control fetches the instruction from the memory and uses its address part to access memory again to get the effective address.


Register Direct Addressing Mode

Each and every architecture has a set of registers in its CPU known as register sets. For each unique registers, there is residing an equivalent operand. This particular register is selected from a register field in the instruction. A k-bit field can specify any one of 2^k registers.

Register Indirect Addressing Mode



In this mode, the instruction specifies a register in the CPU whose content gives the address of the operand in the memory. In other words, the selected registers contain the address of the operand rather than the operand itself. Before using a register indirect mode instruction, the programmer must ensure that the memory address of the operand is placed in the processor register with the previous instruction.



Displacement Addressing Mode


In displacement addressing mode the address field of the instruction is to be added to the content of a specific register in the CPU. The effective address in these modes is obtained from the following computation.
effective address = address part of instruction + content of CPU register
The CPU register used in computation may be the program counter, index register or a base register. Depending on this factor Displacement addressing modes are of three types:-
  • Relative
  • Base Register
  • Indexing
  1. Relative Addressing mode:- In this mode, the content of the program counter is added to the address part of the instruction in order to get an effective address. The address part of the instruction is usually a signed number (in 2's complement) which can be either positive or negative. When this number is added to the content of the program counter, the result produces an effective address whose position in memory is relative to the address of the next instruction.
  2. Base Register Addressing mode:- In this mode, the content of a base register is added to the address part of the instruction to obtain the effective address. This is similar to the indexed addressing mode except that the register is now called base register instead of the index register. The effective address is then mapped on the memory to find out the operand. 
  3. Indexed Addressing mode:- In this mode, the content of an index register is added to the address part of the instruction to obtain the effective address. The effective address is then mapped on the memory to find out the operand. 


Comments

Post a Comment

Popular posts from this blog

What is Artificial Intelligence(AI)?

The Java Program Execution Procedure