SlideShare a Scribd company logo
1 of 88
Download to read offline
Microprocessor and Interfacing Techniques
(TE-309)
Engr. Adeel Asghar
Addressing Modes
Lecture 03
Prophet Muhammad ‫ﷺ‬ said,
“A Muslim does not regularly attend
the mosques to perform prayer and
remember Allah, but Allah feels
happy with him just as the family of
one who is absent feels happy when
he comes back to them”
Sunan Ibn Majah, Book 4, Hadith 66
Outline
• Data Addressing modes
• Types of data and register addressing mode
• Program memory addressing mode
• Stack memory addressing mode
Addressing Modes
CHAPTER OBJECTIVES
• Explain the operation of each data-addressing mode.
• Use the data-addressing modes to form assembly language
statements.
• Explain the operation of each program memory-addressing mode.
• Use the program memory-addressing modes to form assembly and
machine language statements.
• Select the appropriate addressing mode to accomplish a given
task.
• Detail the difference between addressing memory data using real
mode and protected mode operation.
• Describe the sequence of events that place data onto the stack or
remove data from the stack.
• Explain how a data structure is placed in memory and used with
software Addressing Modes
5
Addressing modes
• Three Addressing modes
• Data Addressing modes
• Program memory addressing
• Stack memory addressing
Data Addressing Modes
• MOV instruction defines the direction of data flow. The source is to
the right and the destination is to the left, next to the opcode MOV.
MOV AX,BX
• An opcode, or operation code, tells the microprocessor which
operation to perform.
• MOV AX, BX instruction transfers the word contents of the source
register (BX) into the destination register (AX).
7
3.1 Data Addressing mode
• Register Addressing
• Immediate Addressing
• Direct Data Addressing
• Register Indirect Addressing
• Base plus Index Addressing
• Register relative Addressing
• Base relative plus index Addressing
• Scaled index Addressing
DATA-ADDRESSING MODES
9
Register Addressing
• The most common form of data addressing.
– once register names learned, easiest to apply.
• The microprocessor contains these 8-bit
register names used with register addressing:
AH, AL, BH, BL, CH, CL, DH, and DL.
• 16-bit register names: AX, BX, CX, DX, SP,
BP, SI, and DI.
10
In 80386 & above, extended 32-bit register
names are: EAX, EBX, ECX, EDX, ESP,
EBP, EDI, and ESI.
• 64-bit mode register names are: RAX, RBX,
RCX, RDX, RSP, RBP, RDI, RSI, and R8
through R15.
• Important for instructions to use registers that
are the same size.
– never mix an 8-bit with a 16-bit register, an 8- or
a 16-bit register with a 32-bit register
– this is not allowed by the microprocessor and
results in an error when assembled
11
Fig.3.3 The effect of executing the MOV BX, CX instruction at the point just before
the BX register changes. Note that only the rightmost 16 bits of register EBX
change.
12
Immediate Addressing
• Term immediate implies that data immediately
follow the hexadecimal opcode in the memory.
– immediate data are constant data
– data transferred from a register or memory
location are variable data
• Immediate addressing operates upon a byte or
word of data.
• Figure 3–4 shows the operation of a MOV
EAX,13456H instruction.
13
• Figure 3–4 The operation of the MOV EAX,3456H instruction. This
instruction copies the immediate data (13456H) into EAX.
As with the MOV instruction illustrated in
Figure 3–3, the source data overwrites the
destination data.
14
• In symbolic assembly language, the symbol #
precedes immediate data in some assemblers.
– MOV AX,#3456H instruction is an example
• Most assemblers do not use the # symbol, but
represent immediate data as in the
MOV AX,3456H instruction.
– an older assembler used with some Hewlett-
Packard logic development does, as may others
15
• The symbolic assembler portrays immediate
data in many ways.
• The letter H appends hexadecimal data.
• If hexadecimal data begin with a letter, the
assembler requires the data start with a 0.
– to represent a hexadecimal F2, 0F2H is used in
assembly language
• Decimal data are represented as it is and
requires no special codes or adjustments.
– an example is the 100 decimal in the
MOV AL,100 instruction
16
An ASCII-coded character or characters may be
depicted in the immediate form if the ASCII data
are enclosed in apostrophes.
– be careful to use the apostrophe (‘) for ASCII
data and not the single quotation mark (`)
• Binary data are represented if the binary
number is followed by the letter B.
– in some assemblers, the letter Y
17
Direct Data Addressing
• Applied to many instructions in a typical program.
Copies the content from memory location
• Two basic forms of direct data addressing:
– direct addressing, which applies to a MOV between a
memory location and AL, AX, or EAX
– displacement addressing, which applies to almost any
instruction in the instruction set
• Address is formed by adding the displacement to the
default data segment address or an alternate segment
address.
18
Direct Addressing
• Direct addressing with a MOV instruction transfers data
between a memory location, located within the data
segment, and the AL (8-bit), AX (16-bit), or EAX (32-bit)
register.
• MOV AL,DATA loads AL from the data segment memory
location DATA (1234H).
– DATA is a symbolic memory location, while 1234H is the
actual hexadecimal location
19
• This instruction transfers a copy contents of memory
location 11234H into AL.
– the effective address is formed by adding 1234H (the
offset address) and 10000H (the data segment address of
1000H times 10H) in a system operating in the real mode
20
Direct addressing
Register Indirect Addressing
• Allows data to be addressed at any memory
location through an offset address held in any of the
following registers: BP, BX, DI, and SI.
• In addition, 80386 and above allow register
indirect addressing with any extended register
except ESP.
• In the 64-bit mode, the segment registers serve no
purpose in addressing a location in the flat model.
22
23
Base-Plus-Index Addressing
• Similar to indirect addressing because it indirectly
addresses memory data.
• The base register often holds the beginning
location of a memory array.
– the index register holds the relative position of an
element in the array
– whenever BP addresses memory data, both the
stack segment register and BP generate the effective
address
24
25
Locating Array Data Using Base-
Plus-Index Addressing
• 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.
• Figure 3–9 shows the use of BX and DI to access an
element in an array of data.
26
27
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)
• Figure 3–10 shows the operation of the
MOV AX,[BX+1000H] instruction.
• A real mode segment is 64K bytes long.
28
29
+
Addressing Array Data with
Register Relative
• It is possible to address array data with register
relative addressing.
– such as with base-plus-index addressing
• In Figure 3–11, register relative addressing is
illustrated with the same example as for
baseplus-index addressing.
– this shows how the displacement ARRAY adds to
index register DI to generate a reference to an array
element
30
31
Base Relative-Plus-Index
Addressing
• Similar to base-plus-index addressing.
– adds a displacement
– 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.
32
Addressing Data with Base
Relative-Plus-Index
• Least-used addressing mode.
• Figure 3–12 shows how data are referenced if the
instruction executed by the microprocessor is MOV
AX,[BX + SI + 100H].
– displacement of 100H adds to BX and SI to form
the offset address within the data segment
• This addressing mode is too complex for frequent
use in programming.
33
34
Addressing Arrays with Base
Relative-Plus-Index
• Suppose a file of many records exists in memory,
each record with many elements.
– displacement addresses the file, base register
addresses a record, the index register addresses an
element of a record
• Figure 3–13 illustrates this very complex form of
addressing.
35
36
Scaled-Index Addressing
• Unique to 80386 - Core2 microprocessors.
– uses two 32-bit registers (a base register and an
index register) to access the memory
• The second register (index) is multiplied by a
scaling factor.
– the scaling factor can be 1x, 2x, 4x, 8x
• A scaling factor of is implied and need not be
included in the assembly language instruction
(MOV AL,[EBX + ECX]).
37
Task
• MOV [7000H],CX
• Which addressing does instruction above belong, and why?
Memory Addressing Modes
Memory addressing modes (Architectural)
Real Mode Memory addressing
Protected mode Memory Addressing
Flat Mode Memory addressing
Memory Addressing Modes(Programming Model)
Program Memory Addressing
Stack Memory Addressing
Memory addressing modes (Architectural)
Real Mode Memory Addressing
•The only mode available on for 8088-8086
•Real mode memory is the first 1M (220) bytes of the
memory system (real, conventional, DOS memory)
•All real mode 20-bit addresses are a combination of a
segment address (in a segment register) plus an offset
address (in another register)
•The segment register address (16-bits) is appended with
a 0H or 00002 (or multiplied by 10H) to form a 20-bit
start of segment address
•The effective memory address =
this 20-bit segment address + a 16-bit offset address in
a register
•Segment length is fixed = 216 = 64K bytes 42
1 MB
20-bit (5-byte)
Physical
Memory address
64 KB
Segment
16-bit
Appended bit 0H
+
EA (Effective Address)
(1 MB)
43
Effective Address Calculations
• EA = segment register (SR) x 10H plus offset
(a) SR: 1000H
10000 + 0023 = 10023
(b) SR: AAF0H
AAF00 + 0134 = AB034
(c) SR: 1200H
12000 + FFF0 = 21FF0
44
Defaults
• CS for program (code)
• SS for stack
• DS for data
• ES for string destination
• Default offset addresses that go with them:
Segment Offset (16-bit)
8080, 8086, 80286
Offset (32-bit)
80386 and above
Purpose
CS IP EIP Program
SS SP, BP ESP, EBP Stack
DS BX, DI, SI, 8-bit or 16-bit
#
EAX, EBX, ECX, EDX,
ESI, EDI, 8-bit or 32-bit
#
Data
ES DI EDI String
destination 45
Overlapping segments
Top of CS:
090F0
FFFF+
190EF
46
Segmentation: Pros and Cons
Advantages:
•Allows easy and efficient relocation of code and data
•A program can be located anywhere in memory without
any change to the program
•Program writing needs not worry about actual memory
structure of the computer used to execute it
•To relocate code or data only the segment number
needs to be changed
Disadvantages:
•Complex hardware and for address generation
•Software: Programs limited by segment size
(only 64KB with the 8086)
47
Limitations of the above real mode segmentation scheme
•Segment size is fixed at 64 KB
•Segment can not begin at an arbitrary memory
address…
With 20-bit memory addressing, can only begin at
addresses starting with 0H, i.e. at 16 byte intervals
•Difficult to use with 24 or 32-bit memory addressing
with segment registers remaining at 16-bits
80286 and above use 24, 32, 36 bit addresses but still
16-bit segment registers
→ Use memory segmentation in the protected mode
48
49
Segment and Offset Addressing Scheme Allows
Relocation
• Segment plus offset addressing allows DOS programs to be relocated in
memory.
• A relocatable program is one that can be placed into any area of memory and
executed without change.
• Relocatable data are data that can be placed in any area of memory and used
without any change to the program.
Protected Mode Memory Addressing
• Used in 80286 and above
• Protected mode is where Windows operates
• Allows access to data and programs located above the first 1M byte
of memory, as well as within the first 1M byte of memory
• Multi-task Support
• 32 bit offset address
• Segments can be up to 4GB in Size
• Task Segments Defined by Descriptor Tables
• Memory Protection and Task Privilege
• Paging Support
Protected Mode Memory Addressing
51
Remember using real mode addressing we were previously able
to address 1M Byte of memory.
Using Protected Mode memory addressing locations above the
1M byte boundary can be addressed.
The Protected Memory scheme still uses base address and
index address to calculate actual memory locations but, this is
done in a different way from what we had done previously.
52
The offset address is still used as previously, to find the
memory location within the segment that we are interested in.
The use of the base or the segment address has changed a bit.
The segment register now contains a selector rather than the
“actual” base address of the segment.
An additional table called a descriptor table uses the selector
as an index to provide additional information known as
descriptor.
The descriptor describes:
• location
•Length
•Access rights
For the segment of interest.
53
There are two descriptor tables. Global Descriptor table and
local descriptor table.
Each table contains 8192 descriptors.
Global descriptors contain segment definitions that apply to all
programs. – System Descriptor.
Local Descriptors provide information that are unique to an
application. – Application Descriptor.
Because each table contains 8192 descriptors, there are a total
of 16384 descriptors available to any application.
This also now means that up to 16384 memory segments could
be described to be used by each application.
54
80286 Descriptor
00000000 00000000
Access Rights Base (B23-B16)
Base (B15 – B0)
Limit (L15 –L0)
80386 through P4 Descriptor
Base
(B31-B24)
G D 0 A
V
Limit
(L19-L16)
Access Rights Base (B23-B16)
Base (B15 – B0)
Limit (L15 –L0)
55
Segment Limit – The last possible offset address of the
segment.
So if the segment begins at memory location F00000H and
ends at location F000FFH. What should be the value of the
limit register ?
Remember the limit registers size on 80286 is 16 bits and
80386 and above is 20 bit.
Additional bits available to 80386 and above
G – Granularity bit –
If G =0 – The limit specifies segment limit of 00000H to FFFFFH.
If G =1 – The limit specifies segment limit of 00000XXXH to
FFFFFXXXH.
appended with FFFH
56
This increases the limit and allows the segment length of 4K to
4G bytes in steps of 4K Bytes.
80286 has 16 bits to define offset because of its internal
architecture.
80386 and above have 32 bits and have a 32 bit internal
architecture.
Thus operating systems also work in either 16 bit mode or 32
bit mode. DOS works uses 16 bit environment and windows
uses 32 bits.
In the 64-bit descriptor, the L bit (probably means large, but
Intel calls it the 64-bit)
64-bit extensions when L = 1 & 32-bit when L=0
57
Example:
Segment start and end if the base address is
10000000H, the limit is 001FFH and G bit =0.
Base = Start = 10000000H
G =0
End = Base + Limit = 10000000H + 001FFH =
100001FFH
58
Example:
Segment start and end if the base address is 10000000H, the
limit is 001FFH and G bit =1.
Base = Start = 10000000H
G =1
End = Base + Limit = 10000000H + 001FFXXXH = 101FFFFFH
59
AV – Available
AV =1 – Available
AV =0 – Not Available.
D = Data access
D = 1 – The instructions are in 32bits and the registers are 32
bits.
D = 0 – The instructions are 16 bit instructions compatible with
8086-80286
60
Access Rights byte- Control access to protected mode memory
segment. This byte describes how the segment functions in the
system.
7 6 5 4 3 2 1 0
P DPL S E ED/C R/W A
A = 0 – Segment Not Accessed
A =1 – Segment has been accessed
E = 1 Descriptor describes code segment
E = 0 Descriptor describes data segment
ED = 0 Segment expands upwards
ED = 1 Segment expands downward
W = 0 Data may not be written
W = 1 Data may be written
61
C = 0 Ignore descriptor privilege level
C = 1 Abide by privilege level
R = 0 Code segment may not be read
R = 1 Code segment may be read
S = 0 System descriptor
S = 1 Code or data segment descriptor
DPL= Sets the descriptor privilege level ( 00 – 11)
P = 0 Descriptor is undefined
P = 1 Segment contains a valid base and limit
7 6 5 4 3 2 1 0
P DPL S E ED/C R/W A
62
Selector TI RPL
15 3 2 1 0
Selector – Selects one of the 8192 descriptors.
TI – Chooses either the global descriptor table or the local
table.
T1 = 0 – Global descriptor table
T1 =1 – Local descriptor table
RPL – Requested privilege level.
00 – highest
11 - lowest
64
Flat Mode Memory
• A flat mode memory system is one in which there is no segmentation.
• does not use a segment register to address a location in the memory
• First byte address is at 00 0000 0000H; the last location is at FF FFFF FFFFH.
• address is 40-bits
• The segment register still selects the privilege level of the software.
• Real mode system is not available if the processor operates in the 64-bit mode.
• Protection and paging are allowed in the 64-bit mode.
• The CS register is still used in the protected mode operation in the 64-bit mode.
• Most programs today are operated in the IA32 compatible mode.
• current software operates properly, but this will change in a few years as memory
becomes
larger and most people have 64-bit computers
65
The 64-bit flat mode memory model.
Memory Paging
66
The memory paging mechanism located within the 80386 and
above allows any physical memory location to be assigned to
any linear address.
The linear address is defined as the address generated by a
program.
Within the memory paging unit the linear address is invisibly
translated into any physical address.
This allows an application written to function at a specific
address to be relocated through the paging mechanism
It also allows memory to be placed into areas where no
memory exists.
The paging unit is controlled by the contents of the
microprocessor’s control registers.
The linear address is broken into three sections that are used
to access the page directory entry, page table entry, and page
offset address
The page directory contains 1,024 doubleword addresses that
locate up to 1,024 page tables
The page directory and each page table are 4K bytes in length
32 bit paging control registers
Memory Addressing Modes(Programming
Model)
PROGRAM MEMORY ADDRESSING
MODES
• Used with the JMP (jump) and CALL instructions.
• Consist of three distinct forms:
– direct, relative, and indirect
70
Direct Program Memory Addressing
• Used for all jumps and calls by early
microprocessor; also used in high-level languages,
such as BASIC.
– GOTO and GOSUB instructions
• The microprocessor uses this form, but not as
often as relative and indirect program memory
addressing.
• The instructions for direct program memory
addressing store the address with the opcode.
71
72
• This JMP 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 system
• Often called a far jump because it can jump to
any memory location for the next instruction.
– in real mode, any location within the first 1M
byte
– In protected mode operation, the far jump can
jump to any location in the 4G-byte address range
in the 80386 - Core2 microprocessors
73
• The only other instruction using direct program
addressing is the intersegment or far 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.
74
Relative Program Memory
Addressing
• Not available in all early microprocessors, but it is
available to this family of microprocessors.
• The term relative means “relative to the
instruction pointer (IP)”.
• The JMP instruction is a 1-byte instruction, with a
1-byte or a 2-byte displacement that adds to the
instruction pointer
75
76
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 register EAX
77
• If a relative register holds the address, the
jump is considered to be an indirect jump.
• For example, JMP [BX] refers to the memory
location within the data segment at the offset
address contained in BX.
– at this offset address is a 16-bit number used as
the offset address in the intra-segment jump
– this type of jump is sometimes called an indirect-
indirect or double-indirect jump
• Figure shows a jump table that is stored,
beginning at memory location TABLE.
78
79
STACK MEMORY-ADDRESSING
MODES
• The stack plays an important role in all
microprocessors.
– holds data temporarily and stores return
addresses used by procedures
• Stack memory is LIFO (last-in, first-out) memory
– describes the way data are stored and removed
from the stack
80
• Data are placed on the stack with a PUSH
instruction; removed with a POP instruction.
• Stack memory is maintained by two registers:
– the stack pointer (SP or ESP)
– the stack segment register (SS)
• 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
81
• The SP is decremented by 2 so the next word
is stored in the next available stack location.
– the SP/ESP register always points to an area of
memory located within the stack segment.
• In protected mode operation, the SS register
holds a selector that accesses a descriptor for
the base address of the stack segment.
• 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; the SP register is
incremented by 2
82
83
• 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.
• 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 off the stack into any register
or any segment register except CS.
84
• PUSHA and POPA instructions push or pop all
except segment registers, on the stack.
• Not available on early 8086/8088 processors.
• 80386 and above allow extended registers to be
pushed or popped.
– 64-bit mode for Pentium and Core2 does not
contain a PUSHA or POPA instruction
85
✓Data Movement Instructions

More Related Content

Similar to lect 03- MIT Addressing Modes.pdf

Notes 8086 instruction format
Notes 8086 instruction formatNotes 8086 instruction format
Notes 8086 instruction formatHarshitParkar6677
 
8086 instruction set (with simulator)
8086 instruction set (with simulator)8086 instruction set (with simulator)
8086 instruction set (with simulator)Aswini Dharmaraj
 
SAURABH MITRA-8086 MICROPROCESSOR
SAURABH MITRA-8086 MICROPROCESSORSAURABH MITRA-8086 MICROPROCESSOR
SAURABH MITRA-8086 MICROPROCESSORSAURABH MITRA
 
pptx_20221115_180411_0000.pptx
pptx_20221115_180411_0000.pptxpptx_20221115_180411_0000.pptx
pptx_20221115_180411_0000.pptxAManiMaran1
 
Pai unit 1_l1-l2-l3-l4_upload
Pai unit 1_l1-l2-l3-l4_uploadPai unit 1_l1-l2-l3-l4_upload
Pai unit 1_l1-l2-l3-l4_uploadYogesh Deshpande
 
Introduction to 8086 microprocessor
Introduction to 8086 microprocessorIntroduction to 8086 microprocessor
Introduction to 8086 microprocessorShreyans Pathak
 
Microprocessor Miscellaneous datatrans+directives
Microprocessor Miscellaneous datatrans+directivesMicroprocessor Miscellaneous datatrans+directives
Microprocessor Miscellaneous datatrans+directiveswaqasahmad1995
 
Architecture of 8086 Microprocessor
Architecture of 8086 Microprocessor  Architecture of 8086 Microprocessor
Architecture of 8086 Microprocessor Mustapha Fatty
 
(246431835) instruction set principles (2) (1)
(246431835) instruction set principles (2) (1)(246431835) instruction set principles (2) (1)
(246431835) instruction set principles (2) (1)Alveena Saleem
 
Computer Architecture
Computer ArchitectureComputer Architecture
Computer ArchitectureMohamed Essam
 
address5ng modes.pptx IS A GOOD MATERIAL
address5ng  modes.pptx IS A GOOD MATERIALaddress5ng  modes.pptx IS A GOOD MATERIAL
address5ng modes.pptx IS A GOOD MATERIALDrkoteswararaoseelam
 
Microprocessor 80386
Microprocessor 80386Microprocessor 80386
Microprocessor 80386yash sawarkar
 
31. 8086 addressing modes
31. 8086 addressing modes31. 8086 addressing modes
31. 8086 addressing modessandip das
 

Similar to lect 03- MIT Addressing Modes.pdf (20)

Notes 8086 instruction format
Notes 8086 instruction formatNotes 8086 instruction format
Notes 8086 instruction format
 
Chapter 1 archietecture of 8086
Chapter 1 archietecture of 8086Chapter 1 archietecture of 8086
Chapter 1 archietecture of 8086
 
8086 instruction set (with simulator)
8086 instruction set (with simulator)8086 instruction set (with simulator)
8086 instruction set (with simulator)
 
SAURABH MITRA-8086 MICROPROCESSOR
SAURABH MITRA-8086 MICROPROCESSORSAURABH MITRA-8086 MICROPROCESSOR
SAURABH MITRA-8086 MICROPROCESSOR
 
pptx_20221115_180411_0000.pptx
pptx_20221115_180411_0000.pptxpptx_20221115_180411_0000.pptx
pptx_20221115_180411_0000.pptx
 
110 ec0644
110 ec0644110 ec0644
110 ec0644
 
CO_Chapter2.ppt
CO_Chapter2.pptCO_Chapter2.ppt
CO_Chapter2.ppt
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
 
Pai unit 1_l1-l2-l3-l4_upload
Pai unit 1_l1-l2-l3-l4_uploadPai unit 1_l1-l2-l3-l4_upload
Pai unit 1_l1-l2-l3-l4_upload
 
Introduction to 8086 microprocessor
Introduction to 8086 microprocessorIntroduction to 8086 microprocessor
Introduction to 8086 microprocessor
 
Microprocessor Miscellaneous datatrans+directives
Microprocessor Miscellaneous datatrans+directivesMicroprocessor Miscellaneous datatrans+directives
Microprocessor Miscellaneous datatrans+directives
 
Architecture of 8086 Microprocessor
Architecture of 8086 Microprocessor  Architecture of 8086 Microprocessor
Architecture of 8086 Microprocessor
 
(246431835) instruction set principles (2) (1)
(246431835) instruction set principles (2) (1)(246431835) instruction set principles (2) (1)
(246431835) instruction set principles (2) (1)
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
 
Computer Architecture
Computer ArchitectureComputer Architecture
Computer Architecture
 
Co&al lecture-05
Co&al lecture-05Co&al lecture-05
Co&al lecture-05
 
address5ng modes.pptx IS A GOOD MATERIAL
address5ng  modes.pptx IS A GOOD MATERIALaddress5ng  modes.pptx IS A GOOD MATERIAL
address5ng modes.pptx IS A GOOD MATERIAL
 
Microprocessor 80386
Microprocessor 80386Microprocessor 80386
Microprocessor 80386
 
80386
8038680386
80386
 
31. 8086 addressing modes
31. 8086 addressing modes31. 8086 addressing modes
31. 8086 addressing modes
 

Recently uploaded

Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Arindam Chakraborty, Ph.D., P.E. (CA, TX)
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationBhangaleSonal
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptxJIT KUMAR GUPTA
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptNANDHAKUMARA10
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaOmar Fathy
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projectssmsksolar
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoordharasingh5698
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startQuintin Balsdon
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapRishantSharmaFr
 

Recently uploaded (20)

Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 

lect 03- MIT Addressing Modes.pdf

  • 1. Microprocessor and Interfacing Techniques (TE-309) Engr. Adeel Asghar
  • 3. Prophet Muhammad ‫ﷺ‬ said, “A Muslim does not regularly attend the mosques to perform prayer and remember Allah, but Allah feels happy with him just as the family of one who is absent feels happy when he comes back to them” Sunan Ibn Majah, Book 4, Hadith 66
  • 4. Outline • Data Addressing modes • Types of data and register addressing mode • Program memory addressing mode • Stack memory addressing mode
  • 5. Addressing Modes CHAPTER OBJECTIVES • Explain the operation of each data-addressing mode. • Use the data-addressing modes to form assembly language statements. • Explain the operation of each program memory-addressing mode. • Use the program memory-addressing modes to form assembly and machine language statements. • Select the appropriate addressing mode to accomplish a given task. • Detail the difference between addressing memory data using real mode and protected mode operation. • Describe the sequence of events that place data onto the stack or remove data from the stack. • Explain how a data structure is placed in memory and used with software Addressing Modes 5
  • 6. Addressing modes • Three Addressing modes • Data Addressing modes • Program memory addressing • Stack memory addressing
  • 7. Data Addressing Modes • MOV instruction defines the direction of data flow. The source is to the right and the destination is to the left, next to the opcode MOV. MOV AX,BX • An opcode, or operation code, tells the microprocessor which operation to perform. • MOV AX, BX instruction transfers the word contents of the source register (BX) into the destination register (AX). 7
  • 8. 3.1 Data Addressing mode • Register Addressing • Immediate Addressing • Direct Data Addressing • Register Indirect Addressing • Base plus Index Addressing • Register relative Addressing • Base relative plus index Addressing • Scaled index Addressing
  • 10. Register Addressing • The most common form of data addressing. – once register names learned, easiest to apply. • The microprocessor contains these 8-bit register names used with register addressing: AH, AL, BH, BL, CH, CL, DH, and DL. • 16-bit register names: AX, BX, CX, DX, SP, BP, SI, and DI. 10
  • 11. In 80386 & above, extended 32-bit register names are: EAX, EBX, ECX, EDX, ESP, EBP, EDI, and ESI. • 64-bit mode register names are: RAX, RBX, RCX, RDX, RSP, RBP, RDI, RSI, and R8 through R15. • Important for instructions to use registers that are the same size. – never mix an 8-bit with a 16-bit register, an 8- or a 16-bit register with a 32-bit register – this is not allowed by the microprocessor and results in an error when assembled 11
  • 12. Fig.3.3 The effect of executing the MOV BX, CX instruction at the point just before the BX register changes. Note that only the rightmost 16 bits of register EBX change. 12
  • 13. Immediate Addressing • Term immediate implies that data immediately follow the hexadecimal opcode in the memory. – immediate data are constant data – data transferred from a register or memory location are variable data • Immediate addressing operates upon a byte or word of data. • Figure 3–4 shows the operation of a MOV EAX,13456H instruction. 13
  • 14. • Figure 3–4 The operation of the MOV EAX,3456H instruction. This instruction copies the immediate data (13456H) into EAX. As with the MOV instruction illustrated in Figure 3–3, the source data overwrites the destination data. 14
  • 15. • In symbolic assembly language, the symbol # precedes immediate data in some assemblers. – MOV AX,#3456H instruction is an example • Most assemblers do not use the # symbol, but represent immediate data as in the MOV AX,3456H instruction. – an older assembler used with some Hewlett- Packard logic development does, as may others 15
  • 16. • The symbolic assembler portrays immediate data in many ways. • The letter H appends hexadecimal data. • If hexadecimal data begin with a letter, the assembler requires the data start with a 0. – to represent a hexadecimal F2, 0F2H is used in assembly language • Decimal data are represented as it is and requires no special codes or adjustments. – an example is the 100 decimal in the MOV AL,100 instruction 16
  • 17. An ASCII-coded character or characters may be depicted in the immediate form if the ASCII data are enclosed in apostrophes. – be careful to use the apostrophe (‘) for ASCII data and not the single quotation mark (`) • Binary data are represented if the binary number is followed by the letter B. – in some assemblers, the letter Y 17
  • 18. Direct Data Addressing • Applied to many instructions in a typical program. Copies the content from memory location • Two basic forms of direct data addressing: – direct addressing, which applies to a MOV between a memory location and AL, AX, or EAX – displacement addressing, which applies to almost any instruction in the instruction set • Address is formed by adding the displacement to the default data segment address or an alternate segment address. 18
  • 19. Direct Addressing • Direct addressing with a MOV instruction transfers data between a memory location, located within the data segment, and the AL (8-bit), AX (16-bit), or EAX (32-bit) register. • MOV AL,DATA loads AL from the data segment memory location DATA (1234H). – DATA is a symbolic memory location, while 1234H is the actual hexadecimal location 19
  • 20. • This instruction transfers a copy contents of memory location 11234H into AL. – the effective address is formed by adding 1234H (the offset address) and 10000H (the data segment address of 1000H times 10H) in a system operating in the real mode 20
  • 22. Register Indirect Addressing • Allows data to be addressed at any memory location through an offset address held in any of the following registers: BP, BX, DI, and SI. • In addition, 80386 and above allow register indirect addressing with any extended register except ESP. • In the 64-bit mode, the segment registers serve no purpose in addressing a location in the flat model. 22
  • 23. 23
  • 24. Base-Plus-Index Addressing • Similar to indirect addressing because it indirectly addresses memory data. • The base register often holds the beginning location of a memory array. – the index register holds the relative position of an element in the array – whenever BP addresses memory data, both the stack segment register and BP generate the effective address 24
  • 25. 25
  • 26. Locating Array Data Using Base- Plus-Index Addressing • 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. • Figure 3–9 shows the use of BX and DI to access an element in an array of data. 26
  • 27. 27
  • 28. 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) • Figure 3–10 shows the operation of the MOV AX,[BX+1000H] instruction. • A real mode segment is 64K bytes long. 28
  • 29. 29 +
  • 30. Addressing Array Data with Register Relative • It is possible to address array data with register relative addressing. – such as with base-plus-index addressing • In Figure 3–11, register relative addressing is illustrated with the same example as for baseplus-index addressing. – this shows how the displacement ARRAY adds to index register DI to generate a reference to an array element 30
  • 31. 31
  • 32. Base Relative-Plus-Index Addressing • Similar to base-plus-index addressing. – adds a displacement – 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. 32
  • 33. Addressing Data with Base Relative-Plus-Index • Least-used addressing mode. • Figure 3–12 shows how data are referenced if the instruction executed by the microprocessor is MOV AX,[BX + SI + 100H]. – displacement of 100H adds to BX and SI to form the offset address within the data segment • This addressing mode is too complex for frequent use in programming. 33
  • 34. 34
  • 35. Addressing Arrays with Base Relative-Plus-Index • Suppose a file of many records exists in memory, each record with many elements. – displacement addresses the file, base register addresses a record, the index register addresses an element of a record • Figure 3–13 illustrates this very complex form of addressing. 35
  • 36. 36
  • 37. Scaled-Index Addressing • Unique to 80386 - Core2 microprocessors. – uses two 32-bit registers (a base register and an index register) to access the memory • The second register (index) is multiplied by a scaling factor. – the scaling factor can be 1x, 2x, 4x, 8x • A scaling factor of is implied and need not be included in the assembly language instruction (MOV AL,[EBX + ECX]). 37
  • 38. Task • MOV [7000H],CX • Which addressing does instruction above belong, and why?
  • 40. Memory addressing modes (Architectural) Real Mode Memory addressing Protected mode Memory Addressing Flat Mode Memory addressing Memory Addressing Modes(Programming Model) Program Memory Addressing Stack Memory Addressing
  • 41. Memory addressing modes (Architectural)
  • 42. Real Mode Memory Addressing •The only mode available on for 8088-8086 •Real mode memory is the first 1M (220) bytes of the memory system (real, conventional, DOS memory) •All real mode 20-bit addresses are a combination of a segment address (in a segment register) plus an offset address (in another register) •The segment register address (16-bits) is appended with a 0H or 00002 (or multiplied by 10H) to form a 20-bit start of segment address •The effective memory address = this 20-bit segment address + a 16-bit offset address in a register •Segment length is fixed = 216 = 64K bytes 42
  • 43. 1 MB 20-bit (5-byte) Physical Memory address 64 KB Segment 16-bit Appended bit 0H + EA (Effective Address) (1 MB) 43
  • 44. Effective Address Calculations • EA = segment register (SR) x 10H plus offset (a) SR: 1000H 10000 + 0023 = 10023 (b) SR: AAF0H AAF00 + 0134 = AB034 (c) SR: 1200H 12000 + FFF0 = 21FF0 44
  • 45. Defaults • CS for program (code) • SS for stack • DS for data • ES for string destination • Default offset addresses that go with them: Segment Offset (16-bit) 8080, 8086, 80286 Offset (32-bit) 80386 and above Purpose CS IP EIP Program SS SP, BP ESP, EBP Stack DS BX, DI, SI, 8-bit or 16-bit # EAX, EBX, ECX, EDX, ESI, EDI, 8-bit or 32-bit # Data ES DI EDI String destination 45
  • 46. Overlapping segments Top of CS: 090F0 FFFF+ 190EF 46
  • 47. Segmentation: Pros and Cons Advantages: •Allows easy and efficient relocation of code and data •A program can be located anywhere in memory without any change to the program •Program writing needs not worry about actual memory structure of the computer used to execute it •To relocate code or data only the segment number needs to be changed Disadvantages: •Complex hardware and for address generation •Software: Programs limited by segment size (only 64KB with the 8086) 47
  • 48. Limitations of the above real mode segmentation scheme •Segment size is fixed at 64 KB •Segment can not begin at an arbitrary memory address… With 20-bit memory addressing, can only begin at addresses starting with 0H, i.e. at 16 byte intervals •Difficult to use with 24 or 32-bit memory addressing with segment registers remaining at 16-bits 80286 and above use 24, 32, 36 bit addresses but still 16-bit segment registers → Use memory segmentation in the protected mode 48
  • 49. 49 Segment and Offset Addressing Scheme Allows Relocation • Segment plus offset addressing allows DOS programs to be relocated in memory. • A relocatable program is one that can be placed into any area of memory and executed without change. • Relocatable data are data that can be placed in any area of memory and used without any change to the program.
  • 50. Protected Mode Memory Addressing • Used in 80286 and above • Protected mode is where Windows operates • Allows access to data and programs located above the first 1M byte of memory, as well as within the first 1M byte of memory • Multi-task Support • 32 bit offset address • Segments can be up to 4GB in Size • Task Segments Defined by Descriptor Tables • Memory Protection and Task Privilege • Paging Support
  • 51. Protected Mode Memory Addressing 51 Remember using real mode addressing we were previously able to address 1M Byte of memory. Using Protected Mode memory addressing locations above the 1M byte boundary can be addressed. The Protected Memory scheme still uses base address and index address to calculate actual memory locations but, this is done in a different way from what we had done previously.
  • 52. 52 The offset address is still used as previously, to find the memory location within the segment that we are interested in. The use of the base or the segment address has changed a bit. The segment register now contains a selector rather than the “actual” base address of the segment. An additional table called a descriptor table uses the selector as an index to provide additional information known as descriptor. The descriptor describes: • location •Length •Access rights For the segment of interest.
  • 53. 53 There are two descriptor tables. Global Descriptor table and local descriptor table. Each table contains 8192 descriptors. Global descriptors contain segment definitions that apply to all programs. – System Descriptor. Local Descriptors provide information that are unique to an application. – Application Descriptor. Because each table contains 8192 descriptors, there are a total of 16384 descriptors available to any application. This also now means that up to 16384 memory segments could be described to be used by each application.
  • 54. 54 80286 Descriptor 00000000 00000000 Access Rights Base (B23-B16) Base (B15 – B0) Limit (L15 –L0) 80386 through P4 Descriptor Base (B31-B24) G D 0 A V Limit (L19-L16) Access Rights Base (B23-B16) Base (B15 – B0) Limit (L15 –L0)
  • 55. 55 Segment Limit – The last possible offset address of the segment. So if the segment begins at memory location F00000H and ends at location F000FFH. What should be the value of the limit register ? Remember the limit registers size on 80286 is 16 bits and 80386 and above is 20 bit. Additional bits available to 80386 and above G – Granularity bit – If G =0 – The limit specifies segment limit of 00000H to FFFFFH. If G =1 – The limit specifies segment limit of 00000XXXH to FFFFFXXXH. appended with FFFH
  • 56. 56 This increases the limit and allows the segment length of 4K to 4G bytes in steps of 4K Bytes. 80286 has 16 bits to define offset because of its internal architecture. 80386 and above have 32 bits and have a 32 bit internal architecture. Thus operating systems also work in either 16 bit mode or 32 bit mode. DOS works uses 16 bit environment and windows uses 32 bits. In the 64-bit descriptor, the L bit (probably means large, but Intel calls it the 64-bit) 64-bit extensions when L = 1 & 32-bit when L=0
  • 57. 57 Example: Segment start and end if the base address is 10000000H, the limit is 001FFH and G bit =0. Base = Start = 10000000H G =0 End = Base + Limit = 10000000H + 001FFH = 100001FFH
  • 58. 58 Example: Segment start and end if the base address is 10000000H, the limit is 001FFH and G bit =1. Base = Start = 10000000H G =1 End = Base + Limit = 10000000H + 001FFXXXH = 101FFFFFH
  • 59. 59 AV – Available AV =1 – Available AV =0 – Not Available. D = Data access D = 1 – The instructions are in 32bits and the registers are 32 bits. D = 0 – The instructions are 16 bit instructions compatible with 8086-80286
  • 60. 60 Access Rights byte- Control access to protected mode memory segment. This byte describes how the segment functions in the system. 7 6 5 4 3 2 1 0 P DPL S E ED/C R/W A A = 0 – Segment Not Accessed A =1 – Segment has been accessed E = 1 Descriptor describes code segment E = 0 Descriptor describes data segment ED = 0 Segment expands upwards ED = 1 Segment expands downward W = 0 Data may not be written W = 1 Data may be written
  • 61. 61 C = 0 Ignore descriptor privilege level C = 1 Abide by privilege level R = 0 Code segment may not be read R = 1 Code segment may be read S = 0 System descriptor S = 1 Code or data segment descriptor DPL= Sets the descriptor privilege level ( 00 – 11) P = 0 Descriptor is undefined P = 1 Segment contains a valid base and limit 7 6 5 4 3 2 1 0 P DPL S E ED/C R/W A
  • 62. 62 Selector TI RPL 15 3 2 1 0 Selector – Selects one of the 8192 descriptors. TI – Chooses either the global descriptor table or the local table. T1 = 0 – Global descriptor table T1 =1 – Local descriptor table RPL – Requested privilege level. 00 – highest 11 - lowest
  • 63.
  • 64. 64 Flat Mode Memory • A flat mode memory system is one in which there is no segmentation. • does not use a segment register to address a location in the memory • First byte address is at 00 0000 0000H; the last location is at FF FFFF FFFFH. • address is 40-bits • The segment register still selects the privilege level of the software. • Real mode system is not available if the processor operates in the 64-bit mode. • Protection and paging are allowed in the 64-bit mode. • The CS register is still used in the protected mode operation in the 64-bit mode. • Most programs today are operated in the IA32 compatible mode. • current software operates properly, but this will change in a few years as memory becomes larger and most people have 64-bit computers
  • 65. 65 The 64-bit flat mode memory model.
  • 66. Memory Paging 66 The memory paging mechanism located within the 80386 and above allows any physical memory location to be assigned to any linear address. The linear address is defined as the address generated by a program. Within the memory paging unit the linear address is invisibly translated into any physical address. This allows an application written to function at a specific address to be relocated through the paging mechanism
  • 67. It also allows memory to be placed into areas where no memory exists. The paging unit is controlled by the contents of the microprocessor’s control registers. The linear address is broken into three sections that are used to access the page directory entry, page table entry, and page offset address The page directory contains 1,024 doubleword addresses that locate up to 1,024 page tables The page directory and each page table are 4K bytes in length
  • 68. 32 bit paging control registers
  • 70. PROGRAM MEMORY ADDRESSING MODES • Used with the JMP (jump) and CALL instructions. • Consist of three distinct forms: – direct, relative, and indirect 70
  • 71. Direct Program Memory Addressing • Used for all jumps and calls by early microprocessor; also used in high-level languages, such as BASIC. – GOTO and GOSUB instructions • The microprocessor uses this form, but not as often as relative and indirect program memory addressing. • The instructions for direct program memory addressing store the address with the opcode. 71
  • 72. 72
  • 73. • This JMP 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 system • Often called a far jump because it can jump to any memory location for the next instruction. – in real mode, any location within the first 1M byte – In protected mode operation, the far jump can jump to any location in the 4G-byte address range in the 80386 - Core2 microprocessors 73
  • 74. • The only other instruction using direct program addressing is the intersegment or far 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. 74
  • 75. Relative Program Memory Addressing • Not available in all early microprocessors, but it is available to this family of microprocessors. • The term relative means “relative to the instruction pointer (IP)”. • The JMP instruction is a 1-byte instruction, with a 1-byte or a 2-byte displacement that adds to the instruction pointer 75
  • 76. 76
  • 77. 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 register EAX 77
  • 78. • If a relative register holds the address, the jump is considered to be an indirect jump. • For example, JMP [BX] refers to the memory location within the data segment at the offset address contained in BX. – at this offset address is a 16-bit number used as the offset address in the intra-segment jump – this type of jump is sometimes called an indirect- indirect or double-indirect jump • Figure shows a jump table that is stored, beginning at memory location TABLE. 78
  • 79. 79
  • 80. STACK MEMORY-ADDRESSING MODES • The stack plays an important role in all microprocessors. – holds data temporarily and stores return addresses used by procedures • Stack memory is LIFO (last-in, first-out) memory – describes the way data are stored and removed from the stack 80
  • 81. • Data are placed on the stack with a PUSH instruction; removed with a POP instruction. • Stack memory is maintained by two registers: – the stack pointer (SP or ESP) – the stack segment register (SS) • 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 81
  • 82. • The SP is decremented by 2 so the next word is stored in the next available stack location. – the SP/ESP register always points to an area of memory located within the stack segment. • In protected mode operation, the SS register holds a selector that accesses a descriptor for the base address of the stack segment. • 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; the SP register is incremented by 2 82
  • 83. 83
  • 84. • 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. • 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 off the stack into any register or any segment register except CS. 84
  • 85. • PUSHA and POPA instructions push or pop all except segment registers, on the stack. • Not available on early 8086/8088 processors. • 80386 and above allow extended registers to be pushed or popped. – 64-bit mode for Pentium and Core2 does not contain a PUSHA or POPA instruction 85
  • 86.
  • 87.