Addressing modes

Hello everyone!
Today we'll be learning about addressing modes 


What do you think an addressing mode is ?
Okay in simple words, The different ways that a person can access data are referred to as addressing modes or also called addressing schemes.

Let us see how addressing modes are used 

1. Register mode : The operand is the contents of processor register. The name of register is specified in the instruction. 
Example: MOV R2, R1
This instruction copies the contents of register R2 to R1.

 2.  Absolute mode or direct mode : The address of the location of the operand is given explicitly in the instruction. 
The constant for address and data can be represented by immediate addressing mode in the assembly language programming.

3.  Immediate mode : The operand is given explicitly in the instruction.
Example: MOV #20, A
The above instruction copies operand 20 in the register A. The sign # in front of the value of an operand is used to indicate that this value is an immediate operand.

4. Indirect mode : The effective address of the contents of a register or the main memory location whose address is given explicitly in the instruction. 
Example: MOV (R0), A
The above instruction copies the contents of the memory addressed by the memory address given in the instruction in parentheses.
The  register or memory location which provides the address of the operand is known as pointer.

5. Index mode : The effective address of the operand is generated by adding a constant value to the contents of a register.
Example: MOV R2, 20 (R1)
The above instruction loads the contents of register R2 into the memory location whose address is calculated by addition of the contents of register R1 and constant value 20

6. Relative Addressing mode : The effective address is determined by the index mode using program counter in place of the general purpose processor register.
This addressing mode is commonly used to specify the target address in branch instructions.
Example: JNZ BACK
This instruction causes program execution to go to the branch target location identified by the name BACK, if the branch condition is satisfied. The branch target location can be determined by specifying it an offset from the current value of the program counter. Since the branch target location may either before or after the branch instruction, the offset is specified as a signed number.

7. Auto increment  mode : The effective address of the operand is the contents of a register specified in the instruction. After accessing the operand, the contents of the register are incremented to address the next location.
Example: MOV R0, (R2)+
The above instruction copies the contents of register R0 into the memory location whose address is specified by the contents of R1. After copy operation, the contents of register R2 are automatically incremented by 1.

8. Auto decrement mode : The contents of a register specified in the instruction are decremented and then they are used as an effective address to access a memory location.
Example: MOV -(R0), R1
This instruction initially decrements the contents of register R0 and then the decremented contents of register R0 are used to address the memory location. Finally, the contents from addressed memory location are copied into the register R1.

Thank you everyone!
Hope you all understand
And I hope that this is beneficial for you all!


0 comments