You are on page 1of 20

“Addressing Modes”

[ 8086 Instruction Set ]

Lecture-07

Maham Fatima
mahamfatima@cuisahiwal.edu.pk
[ Topics Covered ]
• Assembly language instruction break down

• Addressing Modes
1. Register
2. Immediate
3. Direct
4. Register Indirect
5. Base-Plus-Index
6. Register Relative
7. Base Relative-Plus-Index

Note: Topics covered are from chapter 3 of Barry B. Brey’s book.

1.2
• An Instruction manipulates the stored data.

• Sequence of Instructions is called a Program.

• Generally an instruction has two components:


1. Op-code field → Operation code
2. Address field(s) → Operand(s)

Op-code specifies how data is to be manipulated.


Address field indicates data address. It can be in the processor or
it can be in the main memory.

Fall 2019 - M. M. Yasin 1.3


[ Addressing Modes ]

• Sequence of operations that a processor carries out


while executing an instruction is called instruction cycle
(including determining addresses of the operands).

This determining of addresses, is called Addressing Mode.

1.4
[ Addressing Modes ]

1. An instruction is said to have a Register Mode if it


contains a register address (as opposed to memory).
In this case, operand values are held in CPU registers.
For example,
ADD CX, DX ;(CX  CX+DX)

Note: Large number of registers are key characteristics of RISC


based computers.

1.5
[ Addressing Modes ]

2. Whenever an instruction contains the operand value or


constant, it's called an Immediate Mode Instruction.

For example,
Add AX, 25 ;( AXAX+25 )

1.6
[ Addressing Modes ]

1.7
[ Addressing Modes ]

3. An instruction is said to have a Direct Addressing Mode


if it contains the address of the operand.
For example,
MOV AL, Data1 ;(AL  Contents of Data1)
* MOV BH, [5000h] ;(BH  Contents of memory location at 5000h)

MOV AX, Data2 ;(AX  Contents of Data2)


* MOV BX, [5000h] ;(BX  Contents of memory locations at
; 5000h and 5001h)

*Note: This type of addressing is also called displacement addressing

1.8
[ Addressing Modes ]
4. Register Indirect Addressing allows data to be addressed at
any memory location through an offset address held in any
of the following registers: BX, BP, SI and DI.

From this, it follows that the Effective Address(EA) of an


operand in the Register Indirect Mode is the contents of the
CPU register R, EA = (R).
This example is for
For example, MOV [DX], [CX] understanding purpose only.
CX = 500016 DX = 400016
[5000] 16 = 125616 [4000] 16 = 462916

i.e., CPU Register is used as a data pointer. What’s the result?

1.9
[ Addressing Modes ]

1.10
[ Addressing Modes ]

Two variations of the Register Indirect Mode are Auto-


Increment and Auto-Decrement Modes.

i. In Auto-Increment,
first the contents of the specified CPU register are used as
the address of the operand,
and then data transfer takes place,
then register contents are incremented automatically by
some constant. For example,
MOV [DI]+, [SI] ;[DI]  [SI]

1.11
[ Addressing Modes ]

Two variations of the Register Indirect Mode are Auto-


Increment and Auto-Decrement modes.

ii. In Auto-Decrement,
first contents are decremented
then it is used as the address of the operand.
For example,
CLR –[CX]

Note: These modes are useful in array manipulation.

1.12
[ Addressing Modes ]

Another important concept used in the context of


addressing modes is Address Modification, that is,

EA (Effective Address) = RA (Ref. Address) + M (Modifier or Offset)

This address modification is used in:


5. Base-Plus-Index Addressing
6. Register Relative Addressing
7. Base Relative-Plus-Index Addressing

1.13
[ Addressing Modes ]

5. Base-Plus-Index Addressing uses one base register (BP


or BX) and one index register (SI or DI).

The base register often holds the beginning location


of a memory array, whereas
the index register holds the relative position of an
element in the array.

1.14
[ Addressing Modes ]

1.15
[ Addressing Modes ]

6. In Register Relative Addressing the data in a segment


of memory are addressed by adding the displacement
to the contents of a base or an index register (BX, BP, SI,
DI).

The displacement is a number added/subtracted to


the register within the [ ]. It can also be an offset
address appended to the front of the [ ]. Both forms
of displacements also can appear simultaneously.

In 8086, the value of displacement is limited to a 16-


bit signed number (+32767 to -32768) (7FFFh to 8000h).
1.16
[ Addressing Modes ]

1.17
[ Addressing Modes ]

7. Base Relative-Plus-Index Addressing mode is similar to


base-plus-index addressing, but it adds a
displacement, besides using a base register and an
index register to form the memory address.

This type of addressing mode often addresses a two-


dimensional array of memory data.

This addressing mode is the least-used addressing


mode.

1.18
[ Addressing Modes ]

1.19
1.20

You might also like