0% found this document useful (0 votes)
21 views50 pages

Lec 5

The document summarizes various addressing modes used in microprocessors, including data addressing modes, program addressing modes, and stack addressing modes. It describes different types of data addressing like register addressing, immediate addressing, direct addressing, register indirect addressing, base-plus-index addressing, register relative addressing, and base relative-plus-index addressing. It also discusses direct, relative, and indirect program addressing and how the stack is used for temporary data and return addresses through PUSH and POP instructions.

Uploaded by

Not me
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views50 pages

Lec 5

The document summarizes various addressing modes used in microprocessors, including data addressing modes, program addressing modes, and stack addressing modes. It describes different types of data addressing like register addressing, immediate addressing, direct addressing, register indirect addressing, base-plus-index addressing, register relative addressing, and base relative-plus-index addressing. It also discusses direct, relative, and indirect program addressing and how the stack is used for temporary data and return addresses through PUSH and POP instructions.

Uploaded by

Not me
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 50

Previous Lecture Review

Data Addressing Modes:-

– Register Addressing.

– Immediate Addressing.

– Direct Data Addressing.

– Register Indirect Addressing. 2


Quiz
Write an instruction for each of the
following tasks:-
Copy EBX into EDX. Move 123AH into AX.

Copy SI into BX. Move 0CDH into CL.

Copy DS into AX. Move 1000H into RAX.

Copy R8 into R10. Move 1200A2H into EBX.

Move 12H into AL. 3


Outline

Addressing Modes:-

–(Complete) Data Addressing Modes.

Program Addressing Modes.

Stack Addressing Modes. 4


Outline

Addressing Modes:-

–(Complete) Data Addressing Modes.

Program Addressing Modes.

Stack Addressing Modes. 5


Data Addressing Modes (Cont.)

–Base–Plus–Index Addressing.

–Register Relative Addressing.

–Base Relative–Plus–Index Addressing.


6
Data Addressing Modes (Cont.)

7
Data Addressing Modes (Cont.)

Base–Plus–Index Addressing:

• Similar to indirect addressing because it

indirectly addresses memory data.

• In the 8086 through the 80286, this type of

addressing uses one base register (BP or BX)


8
and one index register (DI or SI).
Data Addressing Modes (Cont.)

• The next Fig. shows how the base–plus–

index addressing mode functions for the

MOV DX,[BX + DI] instruction.

• For DS=0100H, BX=1000H & DI=0010H

the memory address 02010H is accessed. 9


Data Addressing Modes (Cont.)

10
Data Addressing Modes (Cont.)
• Note that The Intel assembler requires this

addressing mode appear as [BX][DI]

instead of [BX + DI].

• i.e. MOV DX,[BX + DI] instruction will be

written for a program for the Intel ASM

assembler as MOV DX,[BX][DI]. 11


Data Addressing Modes (Cont.)

12
Data Addressing Modes (Cont.)
• A major use is to address elements in a

memory array.

• To accomplish this, load the BX register

(base) with the beginning address of the

array and the DI register (index) with the

element number to be accessed. 13


Data Addressing Modes (Cont.)

• 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

memory array. 14
Data Addressing Modes (Cont.)
• The following Fig. shows an element (DI) of an
ARRAY (BX) is addressed.

15
Data Addressing Modes (Cont.)
Register Relative Addressing:

• Similar to base–plus–index addressing and

displacement addressing.

• Data in a segment of memory are addressed

by adding the displacement to the contents

of a base or an index register (BP, BX, DI,

or SI). 16
Data Addressing Modes (Cont.)
• The next Fig. shows the operations of MOV
AX,[BX+1000H] instruction. When BX =
0100H and DS=0200H.

17
Data Addressing Modes (Cont.)
• Remember that BX, DI, or SI addresses
the data segment and BP addresses the
stack segment.
• The displacement is a number added to
the register within the [ ], as in the
MOV AL,[DI+2] instruction.
• or it can be a displacement is subtracted
from the register, as in MOV AL,[SI–1].
18
Data Addressing Modes (Cont.)

• A displacement also can be an offset

address appended to the front of the [ ],

as in MOV AL,DATA[DI].

• Both forms of displacements also can

appear simultaneously, as in the MOV

AL,DATA[DI+3] instruction. 19
Data Addressing Modes (Cont.)

20
Data Addressing Modes (Cont.)
• It is possible to address array data with
register relative addressing. The displacement
ARRAY adds to DI to generate a reference to
an array element.

21
Data Addressing Modes (Cont.)
Base Relative–Plus–Index Addressing:
• Similar to base–plus–index addressing,
but it adds a displacement besides uses 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. 22
Data Addressing Modes (Cont.)

• Generally, this modes is the least–used

addressing mode because it’s too complex for

frequent use in programming.

• MOV AX,[BX + SI + 100H]. Displacement of

100H adds to BX and SI to form the offset


23
address within the data segment.
Data Addressing Modes (Cont.)
• The following Fig. shows an example of base
relative–plus–index addressing using a MOV
AX,[BX+SI+100H] instruction. Note: DS =
1000H.

24
Data Addressing Modes (Cont.)

25
Data Addressing Modes (Cont.)
• Suppose a file of many records exists in memory

and each record contains many elements.

• The displacement addresses the file, the base

register addresses a record, the index register

addresses an element of a record. 26


Data Addressing Modes (Cont.)
• The following Fig. illustrates base relative
plus–index addressing used to access a FILE
that contains multiple records (REC).

27
Outline

Addressing Modes:-

–(Complete) Data Addressing Modes.

Program Addressing Modes.

Stack Addressing Modes. 28


Program Addressing Modes
• Used with the jump (JMP) and CALL

instructions.

• Consist of three distinct forms:

– Direct Program Addressing.

– Relative Program Addressing.


29
– Indirect Program Addressing.
Program Memory Addressing (Cont.)
Direct Program Memory Addressing:
• Used for all jumps and calls by early
MP; also used in high–level languages,
such as BASIC (GOTO and GOSUB
instructions).
• The MP uses this form, but not as often
as relative and indirect program memory
addressing.
30
Program Memory Addressing (Cont.)

• JMP 10000H instruction loads CS with 1000H

and IP with 0000H to jump to memory

location 10000H for the next instruction.

• An intersegment jump is a jump to any

memory location within the entire memory


31
system.
Program Memory Addressing (Cont.)
• The other instruction using direct program
addressing is the intersegment CALL instruction.
• Usually, the name of a memory address, called a
label, refers to the location that is called or
jumped to instead of the actual numeric address.
• When using a label with the CALL or JMP
instruction, most assemblers select the best
form of program addressing.
32
Program Memory Addressing (Cont.)

Relative Program Memory Addressing:

• Not available in all early MP, but it is

available to this family of MP.

• The term relative means relative to the

instruction pointer (IP).


33
Program Memory Addressing (Cont.)
• The following Fig. shows A JMP [2]
instruction. This instruction skips the next 2
bytes of memory, the address in relation to the
instruction pointer is a 2 that adds to the
instruction pointer.

34
Program Memory Addressing (Cont.)
Indirect Program Memory Addressing:
• The microprocessor allows several forms of
program indirect memory addressing for the
JMP and CALL instructions.
• In 80386 and above, an extended register can
be used to hold the address or indirect address
of a relative JMP or CALL. For example, the
JMP EAX jumps to the location address by
35
register EAX.
Program Memory Addressing (Cont.)
• For example, if the BX register contains
1000H and a JMP BX instruction
executes, the MP jumps to offset address
1000H in the current code segment.
• If a register holds an address which
contains the required location to jump,
this type is also considered an indirect
36
program memory addressing.
Program Memory Addressing (Cont.)

• For example, JMP [BX] refers to the

memory location within the data segment

at the offset address contained in BX.

• This type of jump is sometimes called an

indirect–indirect or double–indirect jump.


37
Program Memory Addressing (Cont.)

38
Outline

Addressing Modes:-

–(Complete) Data Addressing Modes.

Program Addressing Modes.

Stack Addressing Modes. 39


Stack Memory Addressing

• The stack plays an important role in all MP. It

holds data temporarily and stores return

addresses used by procedures.

• Stack memory is LIFO (Last–In, First–Out)

memory, which describes the way that data


40
are stored and removed from the stack.
Stack Memory Addressing (Cont.)

• Data are placed on the stack with a


PUSH instruction and removed with a
POP instruction.
• Stack memory is maintained by two
registers: The stack pointer (SP or ESP)
and the stack segment register (SS).
41
Stack Memory Addressing (Cont.)

• Whenever a word of data is pushed onto

the stack, the high–order 8 bits are placed

in the location addressed by SP–1.

• Low–order 8 bits are placed in the location

addressed by SP–2 as shown in the Fig. in

the next slide. 42


Stack Memory Addressing (Cont.)

43
Stack Memory Addressing (Cont.)

• The SP is decremented by 2 so the next

word is stored in the next available

stack location.

• The SP/ESP register always adds to

SS Х 10H to form the stack memory

address in the real mode. 44


Stack Memory Addressing (Cont.)
• When data are popped from the stack,
the low–order 8 bits are removed from
the location addressed by SP.
• High–order 8 bits are removed from the
location addressed by SP+1 as shown in
the next Fig. the SP register is then
incremented by 2. 45
Stack Memory Addressing (Cont.)

46
Stack Memory Addressing (Cont.)
• Note that PUSH and POP store or

retrieve words of data – never bytes – in

8086 – 80286.

• 80386 and above allow words or

doublewords to be transferred to and

from the stack. 47


Stack Memory Addressing (Cont.)
• Data may be pushed onto the stack from

any 16–bit register or segment register. In

80386 and above, from any 32–bit extended

register

• Data may be popped o the stack into any

register or any segment register except CS.


48
Summary

Data Addressing Modes:-

– Base–Plus–Index Addressing.

– Register Relative Addressing.

– Base Relative–Plus–Index Addressing.

Program Addressing Modes.

Stack Addressing Modes. 49


Thank you for your attention!

Questions, ideas, and suggestions.

50

You might also like