This document discusses different addressing modes used in computer instructions including register, absolute, immediate, indirect, index, base with index, relative, autoincrement, and autodecrement modes. It provides examples of each mode and how effective memory addresses are calculated. The document also contains questions about identifying addressing modes and calculating effective addresses from sample instructions. Sorting algorithms like bubble sort are explained with C language and assembly language examples.
In this document
Powered by AI
Greeting the audience and introducing topic of addressing modes in computer architecture.
Addressing modes specify how an operand's location is identified in instructions like Immediate, Register, Indirect, etc.
Utilizes processor registers to hold operands. Example: Mov A,R0.
Operands are directly specified using a known memory location. Example: Mov Loc,R1.
Operand is a constant directly included in the instruction, preceded by '#'. Example given.
Operands are accessed indirectly via a pointer in a register. Example of assembly instructions provided.
Operand's effective address computed using a constant added to index register. Notation X(Ri) explained.
Further examples demonstrate practical usage of index addressing mode.
Effective address is based on the program counter, distinguishing it from the general-purpose register approach.
Explains Autoincrement and Autodecrement modes where effective addresses change based on register values.
Comparison between direct and indirect modes, highlighting looping capabilities in indirect addressing.
Questions regarding effective addresses and identifying addressing modes from instructions.
Continued questions from previous slide focusing on identifying various addressing modes.
Defines sorting, processes involved, and lists common sorting algorithms.
C-language code snippet provided for bubble sort algorithm implementation.
Assembly language algorithm for performing bubble sort with detailed instructions.
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.
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.
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