Lesson on Addressing Modes Continued....


Indirect mode

The effective address of the operand is the contents of a register or memory location whose address appears in the instruction.

Assembler Syntax: (Ri), LOC
Addressing Function:EA=[Ri],EA=[LOC]

  • The register or memory location that contains the address of an operand is called a pointer.
  • The instruction does not give the operand or address explicitly
    E.g: MOV [Ri],Rj

Consider the pointer operation of C programming language
Assume value of J to be stored in the variables A using the pointer notation.
So B=&J
A=*B where B is a pointer variable. This statement when compiled it may generate the following statements
MOV B,R1 [Address of J stored in R1]
MOV (R1),A [Store the contents from memory location present in R1 to A]
The above statement can also be achieved by
MOV (B),A

Program

  • The program just shown add a list of numbers, it uses indirect addressing mode to access the successive numbers in the list.
  • Register R2 is used as a pointer to the number list, and the operands are accessed indirectly through R2.
  • The initialization section of the program loads the counter value n from memory location N into R1 and uses the immediate addressing mode to place the address value NUM1, which is the address of the first number in the list, into R2. Then it clears R0 to 0.
  • The instruction, ADD (R2),R0 fetches the operand at location NUM1 and adds it to R0. The second ADD instruction add 4 to the contents of pointer R2, so that it will contain the address of NUM2. This is continued till all the numbers are added. The result is store in variable SUM


Animated Lesson on Addressing Modes << Previous
Next >> Lesson on Addressing Modes

Support us generously: contact@lessons2all.com


Our aim is to provide information to the knowledge seekers. 


comments powered by Disqus






Footer1