Você está na página 1de 22

ADDRESSING MODE

The Operation code of Instruction specifies the operation


that will be executed after it is read from memory and placed
it in the control unit of CPU.

The control unit know where to performed operand on which


the operation is to be performed.

During the execution of the program , operands are available


either in memory module or in general purpose register.
Cont
Execution is faster if the operand is present in GPR as it is
in CPU.GPRs are limited to CPU.

The way the operands are determined during program


execution is determine from the addressing mode of the
instruction.

Several types of addressing modes are as follows:-


TYPES OF ADDRESSING MODE
Implied Mode
Register Mode
Immediate Mode
Direct or Absolute Mode
Indirect Mode
Index Mode
Base Mode
Relative Mode
Auto Indexing Mode
Implied Mode

In this mode the operand is specified implicitly in the


destination of the instruction.

This is 1 byte instruction.

Ex: RAR(Rotate Accumulator Right)


RAL(Rotate Accumulator Left)
RAC (Rotate Accumulator Right through
carry)
CLA(Complement Accumulator)
Register Mode
In this mode the operand are in registers which reside with
in the CPU.

Register mode instruction are one byte instruction & can be


executed within the CPU without the need to reference
memory for operands.

Ex. MOVE R0,R1 //R0R1

Here R0 is destination & R1 is Source


Immediate Mode
If one of the operand is a constant specified in the
instruction then the addressing mode is said to be
immediate addressing mode.
MOVE R3,50 //R3 50
1 byte 1 byte
Length of the instruction =2 bytes.
Op-code occupies the 1st byte of the first memory location .
In this case the address of the operand is immediate to the
op-code or instruction.
It is thus called immediate addressing mode.
Note: All the operands follow the op-code.
Direct or Absolute Mode
In this mode the operand resides in the memory and its
address is given directly in the addressing part of the
instruction.
Ex: MOVE R2 , 1040 //(R2 [1040])
1 byte
1040=Address of Data object

100 OP-CODE
0100 1040
1

104
50
0
Cont..
Here the next location of the operation code ie. [1001]
holds the address of the data object.

The length of the instruction in this case depends upon the


length of the absolute address of the data object.

So, 1byte+ the bytes occupied by 1040.

In Direct Addressing mode one memory reference is


needed to bring the data object.
How to Differentiate between Direct
& Immediate A.M?
In intel processor:-
To differentiate between the Direct A.M & immediate
A.M the op-code are specified differently ie.

Ex: MVI R2,50 (Immediate A.M)


MOV R2,1040 (Direct A.M)

In Motorola Processor

Ex: MOVE R3, #50 (Immediate A.M)


MOVE R3,1040 (Direct A.M)
Cont..
Here to identify the immediate A.M a # symbol is used just
before the immediate data object.

The no of registers are 16, then 16 data objects can be


stored within CPU.

If the data object is there in the register then the name is


available & if it is in memory then it is given by the address
machine only understand the binary number.
Indirect Mode

It is of two types ie.

(a) Using the memory location

(b) Using the register


Indirect A.M. Using the memory location

Here the second operand holds the address of the


location which holds the data.
Ex. MOVE R6,(2000)
2000 =length of address byte
2000[5000]5000[Data]
Disadvantage:-Here two memory references are
needed to bring the data object.
Advantage :- Here the address of the data object can
be modified (by using pointer type variable)
Indirect A.M. Using the Register.

Ex:-MOVE R1, (R2) //1 byte


Here the register R2 contains the address of the data
object.
R2[2002] 2002[Data object]
The length of the instruction is 1 byte.
Advantage:-Length of the instruction is less
Indirect addressing mode using the registers is also
called as Register indirect addressing mode
Effective Address:-E.A=Register+Offset
Offset:-It is displacement between the address locations
unit is in bytes.
Index Mode

If index register is used as the register in finding out


the effective address then the addressing mode is said
to be index A.M.

In this mode the content of an index register is added


to the address part of the instruction to obtain the
effective address.

Ex:-MOVE R0,50(R1)
Here 50 is offset & R1 is index register.
Cont..

If content of the index register ie R1=4000


E.A=4000+50=4050
Here the length of instruction is 2 byte ie
1 byte(off-code)+1 byte(offset).
Note:-
i)Any one of the general purpose register can be used as
the index register.
ii)It can be changed at any point of time during the
execution of a program.
iii)Normally it points the starting address of an array.
iv) It helps us in looping a job.
Base Mode

If the base register is used as the register in finding


out the effective address, then the addressing mode is
known as base addressing mode.
Base Register
A) Base register points to the starting address of the
program.
B)The value of base register cant be changed during
the execution of the program.
C)It helps us in relocating the program.
Cont..

EX:- Op-code Base


Move 10(Reg), R0 5000 register
40
E.A=1000+10=1010 Offset
5001
EX:-MOVE R1, 40 (R15)
R15Base Reg
E.A of the Data =5000+40=5040 Data
5040
Cont..

Note:-This is similar to index addressing mode except


that the address part of the instruction consists of the
number of bits that is less then that the number of bits
required for full address.

Program or data are moved from one segment of


memory to another hence the address value of
instruction must reflect this change of position but the
displacement should not be changed.
Relative Mode

If the program counter is considered to be the register


in finding out the effective address then the addressing
mode is said to be relative addressing mode.

Normally relative addressing mode is used in


conditional or unconditional branch instruction.

E.A=Current contains of PC+Offset


Cont..
Ex:-
BR 50
Here E.A=1002+50=1052 Op-code
1000
100 50
1 PC
1002
Branchin
instruction
g 1052
Auto Indexing Mode

Auto Incrementing A.M


Ex:- MOVE R1, (R2)
Move R1,
R2R2+1 (R2)+

This is called auto-incrementing addressing mode

Auto Decrementing A.M

R2R2-1 Move R1,-(R2)


MOVE R1,
(R2)
This is called auto-decrementing addressing
mode
Thank You

Você também pode gostar