GOOD MORNING
FRIENDS!!!!!
ADDRESSING MODES
By Nithin Santhosh
WHAT IS ADDRESSING MODE?
The different ways in which location of an operand is specified in an instruction are
referred to as “Addressing Modes”.
The different types of generic addressing modes are Immediate, Register,
Absolute(Direct), Indirect, Index, Base with index, Base with index and offset, Relative,
Autoincrement, Autodecrement .
Register Addressing Mode
Register addressing mode involves the use of registers to hold the data to be
manipulated.
Eg : Mov A,R0
Mov R1,R0
Mov Res,R1
In this mode operand is the content of a processor register.
ABSOLUTE MODE(DIRECT MODE)
In the absolute or direct addressing mode, the data is in a ram memory location whose
address is known, and this address is given as a part of the instruction.
Eg : Mov Loc,R1
IMMEDIATE ADDRESSING MODE
In this addressing mode, the source operand is a constant.
In immediate addressing mode, as the name indicates when the
instruction is assembled, the operand comes immediately after the
opcode.
In this addressing mode the data must be immediately
preceded by the pound sign, ‘#’;
INDIRECT ADDRESSING MODE
In this addressing mode, the instruction does not give the operand or
its address explicitly.
This addressing mode provides information from which the memory address
or the operand can be determined. This address is the effective address of
the operand.
When we use this addressing mode here actually the register acts as a pointer, where
pointer is nothing but the register or memory location that contains the address of an
operand.
Continuation…..
Example : Move N,R1
Move #Num1,R2
Clear R0
LOOP: Add (R2),R0
Add #4,R2
Decrement R1
Branch>0 LOOP
Move R0,Sum
INDEX ADDRESSING MODE
This is useful in dealing with lists and arrays.
The effective address of the operand is generated by adding a constant
value to the contents of the register.
The register used may be either a special function register or general purpose
register, the register which we use here is known as “index register”.
We indicate the Index mode symbolically as X(Ri).
Continuation……….
In X(Ri)
X denotes the constant value contained in the instruction
and
Ri is the name of the register involved.
The effective address of the operand is given by
EA = X+[Ri].
The contents of the index registers are not changed in the
process of generating the effective address.
The value X defines an offset also called as a
displacement.
Continuation…….
Move #LIST,R0
Clear R1
Clear R2
Clear R3
Move N,R4
Add 4(R0),R1
Add 8(R0),R2
Add 12(R0),R3
Add #16,R0
Decrement R4
Branch>0 LOOP
Move R1,SUM1
Move R2,SUM2
Move R3,SUM3
LOOP:
RELATIVE ADDRESSING MODE
In this addressing mode the effective address is determined by the Index
mode using the program counter in the place of general purpose register
Ri.
ADDITIONAL MODES
The two additional modes are Autoincrement and Autodecrement mode.
Autoincrementmode – The effective address of the operand is the
contents of a register specified in the instruction. After accessing the
operand, the contents of this register are automatically incremented to
point to the next item in a list. The autoincrement mode is written as
(Ri)+
Autodecrementmode - The contents of a register specified in the
instruction are first automatically decremented and are then used as the
effective address of the operand. The Autodecrementmode is written as
-(Ri)
ADVANTAGE OF INDIRECT OVERDIRECT MODE
In direct addressing mode we cannot use loops, and in case of indirect addressing mode we
can use loop.
QUESTIONS
Registers R1 and R2 of a computer contain the decimal values 1200 and 4600. What is the
effective address of the memory operand in each of the following instructions?
Q1.
i) Load 20(R1),R5
a) 20 b) 4600 c)1220 d)1200
Ans : 1220
ii) Move #3000,R5
a)1220 b)1400 c)4600 d)None of the above
Ans : d) None of the above
iii) Store R5,30(R1,R2)
a)5830 b)5600 c)1200 d)4600
Ans : a)5830
iv) Add -(R2),R5
v) Add (R1)+,R5
a)1200 b)4599 c)1199 d)4600
Ans : b)4599
a)1199 b)1200 c)1198d)1201
Ans : d)1199
Q 2. Identify the addressing modes
i) ADD #6,R1
a)Register b)Absolute(Direct) c)Indirect d)Index e)Immediate
Ans : a) and e)
ii) ADD R1
a)Register b)Absolute(Direct) c)Indirect d)Index e)Immediate
Ans : a)
iii) ADD (R1)+,R5
a)Increment Mode b)Absolute(Direct) c) Autoincrement Mode d)Index e)Immediate
Ans : C) Autoincrement Mode
iv) Load 20(R1),R5
a)Base with index and offset b)Absolute(Direct) c)Indirect d)Index e)Immediate
Ans : d)Index
v) Store R5,30(R1,R2)
a)Base with index and offset b)Absolute(Direct) c)Indirect d)Index e)Immediate
Ans : a)Base with index and offset
Sorting
The process of rearranging the elements so that they are in ascending
or descending order is called as sorting
The various types of sorting are bubble sort, quick sort, insertion
sort etc…
C-Language for bubble sorting
for (j=n-1;j>0;j=j-1)
{
for(k=j-1;k>0;k=k-1)
{
if(List[k]>List[j])
{
Temp=List[k];
List[k]=List[j];
List[j]=Temp;
}
}
}
ALP For Bubble Sorting
Move #LIST,R0
Move N,R1
Subtract #1,R1
OUTER Move R2,R2
Subtract #1,R1
MoveByte (R0,R1),R3
INNER CompareByte R3,(R0,R2)
Branch<=0 NEXT
MoveByte (R0,R2),R4
MoveByte R3,(R0,R2)
MoveByte R4,(R0,R1)
MoveByte R4,R3
NEXT Decrement R2
Branch>=0 INNER
Decrement R1
Branch>0 OUTER
END!!!!!

Addressing modes

  • 1.
  • 2.
  • 3.
    WHAT IS ADDRESSINGMODE? The different ways in which location of an operand is specified in an instruction are referred to as “Addressing Modes”. The different types of generic addressing modes are Immediate, Register, Absolute(Direct), Indirect, Index, Base with index, Base with index and offset, Relative, Autoincrement, Autodecrement .
  • 4.
    Register Addressing Mode Registeraddressing mode involves the use of registers to hold the data to be manipulated. Eg : Mov A,R0 Mov R1,R0 Mov Res,R1 In this mode operand is the content of a processor register.
  • 5.
    ABSOLUTE MODE(DIRECT MODE) Inthe absolute or direct addressing mode, the data is in a ram memory location whose address is known, and this address is given as a part of the instruction. Eg : Mov Loc,R1
  • 6.
    IMMEDIATE ADDRESSING MODE Inthis addressing mode, the source operand is a constant. In immediate addressing mode, as the name indicates when the instruction is assembled, the operand comes immediately after the opcode. In this addressing mode the data must be immediately preceded by the pound sign, ‘#’;
  • 7.
    INDIRECT ADDRESSING MODE Inthis addressing mode, the instruction does not give the operand or its address explicitly. This addressing mode provides information from which the memory address or the operand can be determined. This address is the effective address of the operand. When we use this addressing mode here actually the register acts as a pointer, where pointer is nothing but the register or memory location that contains the address of an operand.
  • 8.
    Continuation….. Example : MoveN,R1 Move #Num1,R2 Clear R0 LOOP: Add (R2),R0 Add #4,R2 Decrement R1 Branch>0 LOOP Move R0,Sum
  • 9.
    INDEX ADDRESSING MODE Thisis useful in dealing with lists and arrays. The effective address of the operand is generated by adding a constant value to the contents of the register. The register used may be either a special function register or general purpose register, the register which we use here is known as “index register”. We indicate the Index mode symbolically as X(Ri).
  • 10.
    Continuation………. In X(Ri) X denotesthe constant value contained in the instruction and Ri is the name of the register involved. The effective address of the operand is given by EA = X+[Ri]. The contents of the index registers are not changed in the process of generating the effective address. The value X defines an offset also called as a displacement.
  • 11.
    Continuation……. Move #LIST,R0 Clear R1 ClearR2 Clear R3 Move N,R4 Add 4(R0),R1 Add 8(R0),R2 Add 12(R0),R3 Add #16,R0 Decrement R4 Branch>0 LOOP Move R1,SUM1 Move R2,SUM2 Move R3,SUM3 LOOP:
  • 12.
    RELATIVE ADDRESSING MODE Inthis addressing mode the effective address is determined by the Index mode using the program counter in the place of general purpose register Ri.
  • 13.
    ADDITIONAL MODES The twoadditional modes are Autoincrement and Autodecrement mode. Autoincrementmode – The effective address of the operand is the contents of a register specified in the instruction. After accessing the operand, the contents of this register are automatically incremented to point to the next item in a list. The autoincrement mode is written as (Ri)+ Autodecrementmode - The contents of a register specified in the instruction are first automatically decremented and are then used as the effective address of the operand. The Autodecrementmode is written as -(Ri)
  • 14.
    ADVANTAGE OF INDIRECTOVERDIRECT MODE In direct addressing mode we cannot use loops, and in case of indirect addressing mode we can use loop.
  • 15.
    QUESTIONS Registers R1 andR2 of a computer contain the decimal values 1200 and 4600. What is the effective address of the memory operand in each of the following instructions? Q1. i) Load 20(R1),R5 a) 20 b) 4600 c)1220 d)1200 Ans : 1220
  • 16.
    ii) Move #3000,R5 a)1220b)1400 c)4600 d)None of the above Ans : d) None of the above iii) Store R5,30(R1,R2) a)5830 b)5600 c)1200 d)4600 Ans : a)5830
  • 17.
    iv) Add -(R2),R5 v)Add (R1)+,R5 a)1200 b)4599 c)1199 d)4600 Ans : b)4599 a)1199 b)1200 c)1198d)1201 Ans : d)1199
  • 18.
    Q 2. Identifythe addressing modes i) ADD #6,R1 a)Register b)Absolute(Direct) c)Indirect d)Index e)Immediate Ans : a) and e) ii) ADD R1 a)Register b)Absolute(Direct) c)Indirect d)Index e)Immediate Ans : a)
  • 19.
    iii) ADD (R1)+,R5 a)IncrementMode b)Absolute(Direct) c) Autoincrement Mode d)Index e)Immediate Ans : C) Autoincrement Mode iv) Load 20(R1),R5 a)Base with index and offset b)Absolute(Direct) c)Indirect d)Index e)Immediate Ans : d)Index
  • 20.
    v) Store R5,30(R1,R2) a)Basewith index and offset b)Absolute(Direct) c)Indirect d)Index e)Immediate Ans : a)Base with index and offset
  • 21.
    Sorting The process ofrearranging the elements so that they are in ascending or descending order is called as sorting The various types of sorting are bubble sort, quick sort, insertion sort etc…
  • 22.
    C-Language for bubblesorting for (j=n-1;j>0;j=j-1) { for(k=j-1;k>0;k=k-1) { if(List[k]>List[j]) { Temp=List[k]; List[k]=List[j]; List[j]=Temp; } } }
  • 23.
    ALP For BubbleSorting Move #LIST,R0 Move N,R1 Subtract #1,R1 OUTER Move R2,R2 Subtract #1,R1 MoveByte (R0,R1),R3 INNER CompareByte R3,(R0,R2) Branch<=0 NEXT MoveByte (R0,R2),R4 MoveByte R3,(R0,R2) MoveByte R4,(R0,R1) MoveByte R4,R3 NEXT Decrement R2 Branch>=0 INNER Decrement R1 Branch>0 OUTER
  • 24.