SlideShare a Scribd company logo
UNIT-3
Memory Management
Segmentation
• 8086 microprocessor has memory size is 1MB.
• Thus we use a 20-bit physical address (actual address) to satisfy 1MB memory with unique
addresses.
• The unique address of every memory location is called a physical address. Every memory
location should have a unique address. The physical address is 20 bit, and it is not a byte
compatible number.
• Segmentation involves logically dividing the computer’s main memory into distinct
segments, each with its own base address.
• 8086 is divided into 4 segments i.e. Code, Stack, Data and Extra segment and each segment
is 64 KB in size.
• Program is stored sequentially in Code segment.Variables or data stored sequentially in
Data and Extra segment . The stack segment will be stored in the last in first out order
(Return Addresses)
Segment Register
Segment Register Designated Role
CS
Code Segment Register
This register points to the currently active code segment. Used in
conjunction with the IP register to point to the next instruction to be
fetched and executed by the processor.
DS
Data Segment Register
This register usually points to the default data segment which
contains the global and static variables of the active application.
ES
Extra Segment Register
General purpose segment register used mostly for data transfers
between different segments.
SS
Stack Segment Register
This register points to the segment containing the active stack. The
top of stack is located at address SS:SP.
UNIT-3.pptx digital electronics system 34
Memory Management(8086)
• Virtual Address(Logical Address):
• If you have a 20-bit address bus then you are bound to have a 20-bit address but 20 bit is
not byte compatible.
• To solve this we use16-bit address which is named virtual address so that we don’t have to use
a physical address.
• The virtual address is a combination of segment address and offsets address. The segment
address shows the segment you want to access. Offset address is the distance from the
starting of a segment to the location you want to access.
• Physical Address:-
• The combination of a segment and an offset within that segment forms a physical address.
Real-Mode Memory Management(8086)
PHYSICAL ADDRESS = SEGMENT ADDRESS X 10H + OFFSET ADDRESS
UNIT-3.pptx digital electronics system 34
Memory Management
in 80386
UNIT-3.pptx digital electronics system 34
Segmentation:-Logical address to Physical
Address
• In Segmentation Logical address of 48 bit is converted into 32 linear address.
UNIT-3.pptx digital electronics system 34
Selector(16bit)
• Content of Segment Register(CS ,DS,SS,ES ) is used as Selector
• Selector Selects one of the 8192 Descriptor from one of the table i.e GDT and LDT.
• Descriptor Index and Table Index (TI) :
– The 13 bit descriptor index selects one of up to 8K descriptors in either the GDT
and LDT, as specified by the TI bit.
• Therefore, these 14 bits allows access to 16K 8-byte descriptors.
• RPL :
– The desired privilege level of the program.
– Access is granted if the RPL value is lower (higher in privilege) than the AR of
the segment. Otherwise, a privilege violation is issued
UNIT-3.pptx digital electronics system 34
• Segmentation provides both memory management and protection.
• All information about the segments is stored in an 8-byte data structure
called a descriptor.
• All the descriptors are stored in tables identified by the 80386 hardware.
There are three types of tables holding 80386 descriptors:
1. global descriptor table (GDT)
2. local descriptor table (LDT)
3. interrupt descriptor table (I DT).
• 80386 processor have many LDT but only one GDT and one IDT.
• BASE: It contains the 32-bit base address for a segment. Thus
define the location of the segment within the 4 gigabyte
Physical Memory.
• LIMIT: It defines the size of the segment. When the processor
concatenates the two parts of the limit field, a 20-bit value
results. The processor interprets the limit field in one of two
ways, depending on the setting of the granularity bit:
80386 Descriptor
• segment descriptors are a part of the segmentation unit, which provides the processor
with the data it needs to translate a logical address into a linear address.
• A(Accessed bit):- This bit indicate whether segment has been accessed by CPU or not.
• Type field(4 bits)-This field decide the descriptor Type and Segment Type.
• S Bit:- This bit decide whether it is a(S=0) system descriptor or (S=1)Segment
descriptor(Code /Data Segment).
• DPL(descriptor Privilege level):- This field decide descriptor Privilege level.
• D bit:-D bit specify the code segment operation Size. If D=1 segment is 32 bit operand
segment else 16 bit operand segment.
• P bit:- P bit specify whether segment is present in Physical memory or not.
• G (Granularity )bit:-This bit indicate whether segment is Page addressable.
• AVL(U Bit):- This field specify whether the descriptor is available to user or to the
operating system.
• Zero bit must remain Zero for Compatibility with future processor.
UNIT-3.pptx digital electronics system 34
• GDTR is the GDT (Global Descriptor Table) Register. It
contains the base address (linear) and limit for the GDT, and
is set using lgdt.
• LDTR is the LDT (Local Descriptor Table) Register and
contains the linear base address and limit for the LDT.
• LDTR is a 16 bit Register used to point LDT
Descriptor.
GDT(Global Descriptor Table)
• GDT is Global Descriptor Table.GDT Represent the
global memory area shared by all tasks.
• There are total 8192 descriptors in GDT.
• Each Descriptor is of 64KB size.(8 Bytes)
Paging unit enabled in protected mode
Paging Mechanism
Control Register 3 (CR3) :-
Control register 3 holds the physical address of
the root of the two level paging tables used when paging is enabled.
It is also called Page Directory Base Register.
• Page Descriptor Base Register The 32-bit linear address is stored at the control register CR2 at
which the previous page fault can be detected. The control register CR3 is used as page directory
which is known as physical base address register. Hence, CR3 is used to store the physical starting
address of the page directory. The lower 12 bits of CR3 must be zero so that page size must be 4K and
the page size must be aligned with the directory.
• Page Directory The size of the page directory is 4 Kbytes. Each directory entry consists of
four bytes. Consequently, a total of 1K or 1024 entries are allowed in a directory. The
example of a typical directory entry is shown in Fig. 11.42. The upper 10 bits of the linear
address are used as an index to the equivalent page directory entry. The corresponding page
directory entry is used to indicate the page tables.
• P-bit The P-bit can be used in address translation. When P = 1, the entry can be
used in address translation. If P = 0, the entry cannot be used. The P-bit of the
presently executed page is always high.
• U/S and R/W Bit The User/Supervisor (U/S) bit and Read/Write (R/W) bit are
used to provide the four level protections as shown in Table 11.21. The level 0 has
the highest privilege level, but the level 3 has the lowest privilege level.
• A-bit The A-bit (access bit) must be set by the 80386 processor before accessing
any page. If A = 1, the page is accessed. When A=0, the page is not accessed.
• D-bit The D-bit (Dirty bit) is set before a write operation to the page. The D-bit is
undefined for page directory entries.
• The OS reserved bits are defined by the operating system
UNIT-3.pptx digital electronics system 34
Types of system and non - system descriptors
System descriptors :-
1. A Local Descriptor Table descriptors (LDT):-
• S bit is’0’ and type bit ‘2’.
• LDTR selects the LDT Descriptor from Global Descriptor Table.
• They points to the base of LDT.
• Each task has its own Local Descriptor, which is not shared by other tasks.
• LDT can be accessed by user if its privilege level is 0.Otherwise DPL level is neglected.
2. Task State Segment(TSS):-
• A Gate Descriptor is special type of Descriptor. The 80386 uses this Gate Descriptor for
performing protection Check.
• There are four types Gate Descriptor:
• Call Gate:-(Type=4)Call Gate used to call functions which is at another privilege level .It can
Change the privilege level and transfer program control to higher privilege level.
• Interrupt Gate:- :- (Type=6) IDTR used to select the descriptor from GDT .This selected
descriptor is called as Interrupt Gate.
• Interrupt Gate points to corresponding ISR(Interrupt service routine) to be executed.
• Task Gate:- :- (Type=5) They are used in multitasking systems to perform task switching.The
task register selects the task gate similar to LDTR selecting LDT descriptor.
• Task gate then selects the Task state Segments(TSS)that is used to copy the content of Current
task. On return from this Task ,the content of TSS is again loaded into registers.
• Trap Gate :-(Type=7) Trap gate is used to handle the single stepping interrupt.
• The segmentation can divide the physical memory into different
sizes of segments while the Paging divides the memory into
fixed-size pages of 4KB.
• The main advantage of the paging system is that it is not required
in the complete segment of a task in the physical memory at any
time. But only some required pages of the segments should he
available in the physical memory for the execution.
• When the remaining pages of the specified task are required for
execution, these pages can be fetched from the secondary
memory storage devices.
Combining Segment and Page Translation
UNIT-3.pptx digital electronics system 34

More Related Content

PPT
Architecture_of_80386_Micropro-An Introduction
PPT
Architecture of 80386(www.munnuz.co.cc)
PDF
80386_AKRay.pdf study computer programme
PPT
Architecture_of_80386_Microprocessor - Inroduction
PPTX
PPT
Microprocessor 80386
PPT
PDF
Introduction to 80386
Architecture_of_80386_Micropro-An Introduction
Architecture of 80386(www.munnuz.co.cc)
80386_AKRay.pdf study computer programme
Architecture_of_80386_Microprocessor - Inroduction
Microprocessor 80386
Introduction to 80386

Similar to UNIT-3.pptx digital electronics system 34 (20)

PPTX
32- bit Microprocessor-Indtel 80386.pptx
PDF
PAI Unit 2 Segmentation in 80386 microprocessor
PPT
Memory mgmt 80386
PPT
The 80386 80486
PDF
Introduction to 80386 microprocessor
PPT
ADVANCED MICROPROCESSORS featuers, block diagram and register organization.ppt
PPTX
Advanced Microprocessors By Er. Swapnil Kaware
PPTX
Pentium (80586) Microprocessor By Er. Swapnil Kaware
PPTX
Advanced Microprocessors By Er. Swapnil Kaware
PDF
Microprocessor Unit-1( Introduction to 80386 Microprocessors)Second Year ppt
PDF
80386 Basic Programming Model and Application
PPTX
U I - 4. 80386 Real mode.pptx
PPTX
Segment descriptior imp engineering.pptx
PPTX
DOC-20230509-WA0002..pptx segment pptxe
PDF
Intel 80386 Architecture and Programming
PPTX
Protected addressing mode and Paging
DOC
3 organization of intel 8086
PPTX
Protected mode memory addressing 8086
PPT
Intel microprocessor history lec12_x86arch.ppt
PPTX
Microprocessor
32- bit Microprocessor-Indtel 80386.pptx
PAI Unit 2 Segmentation in 80386 microprocessor
Memory mgmt 80386
The 80386 80486
Introduction to 80386 microprocessor
ADVANCED MICROPROCESSORS featuers, block diagram and register organization.ppt
Advanced Microprocessors By Er. Swapnil Kaware
Pentium (80586) Microprocessor By Er. Swapnil Kaware
Advanced Microprocessors By Er. Swapnil Kaware
Microprocessor Unit-1( Introduction to 80386 Microprocessors)Second Year ppt
80386 Basic Programming Model and Application
U I - 4. 80386 Real mode.pptx
Segment descriptior imp engineering.pptx
DOC-20230509-WA0002..pptx segment pptxe
Intel 80386 Architecture and Programming
Protected addressing mode and Paging
3 organization of intel 8086
Protected mode memory addressing 8086
Intel microprocessor history lec12_x86arch.ppt
Microprocessor
Ad

Recently uploaded (20)

PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PDF
PPT on Performance Review to get promotions
PDF
composite construction of structures.pdf
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPTX
additive manufacturing of ss316l using mig welding
PPTX
Sustainable Sites - Green Building Construction
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPT
Mechanical Engineering MATERIALS Selection
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PDF
Digital Logic Computer Design lecture notes
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Embodied AI: Ushering in the Next Era of Intelligent Systems
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPT on Performance Review to get promotions
composite construction of structures.pdf
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
R24 SURVEYING LAB MANUAL for civil enggi
additive manufacturing of ss316l using mig welding
Sustainable Sites - Green Building Construction
UNIT-1 - COAL BASED THERMAL POWER PLANTS
CYBER-CRIMES AND SECURITY A guide to understanding
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
Mechanical Engineering MATERIALS Selection
OOP with Java - Java Introduction (Basics)
CH1 Production IntroductoryConcepts.pptx
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Digital Logic Computer Design lecture notes
Foundation to blockchain - A guide to Blockchain Tech
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Ad

UNIT-3.pptx digital electronics system 34

  • 2. Segmentation • 8086 microprocessor has memory size is 1MB. • Thus we use a 20-bit physical address (actual address) to satisfy 1MB memory with unique addresses. • The unique address of every memory location is called a physical address. Every memory location should have a unique address. The physical address is 20 bit, and it is not a byte compatible number. • Segmentation involves logically dividing the computer’s main memory into distinct segments, each with its own base address. • 8086 is divided into 4 segments i.e. Code, Stack, Data and Extra segment and each segment is 64 KB in size. • Program is stored sequentially in Code segment.Variables or data stored sequentially in Data and Extra segment . The stack segment will be stored in the last in first out order (Return Addresses)
  • 3. Segment Register Segment Register Designated Role CS Code Segment Register This register points to the currently active code segment. Used in conjunction with the IP register to point to the next instruction to be fetched and executed by the processor. DS Data Segment Register This register usually points to the default data segment which contains the global and static variables of the active application. ES Extra Segment Register General purpose segment register used mostly for data transfers between different segments. SS Stack Segment Register This register points to the segment containing the active stack. The top of stack is located at address SS:SP.
  • 5. Memory Management(8086) • Virtual Address(Logical Address): • If you have a 20-bit address bus then you are bound to have a 20-bit address but 20 bit is not byte compatible. • To solve this we use16-bit address which is named virtual address so that we don’t have to use a physical address. • The virtual address is a combination of segment address and offsets address. The segment address shows the segment you want to access. Offset address is the distance from the starting of a segment to the location you want to access. • Physical Address:- • The combination of a segment and an offset within that segment forms a physical address.
  • 6. Real-Mode Memory Management(8086) PHYSICAL ADDRESS = SEGMENT ADDRESS X 10H + OFFSET ADDRESS
  • 10. Segmentation:-Logical address to Physical Address • In Segmentation Logical address of 48 bit is converted into 32 linear address.
  • 12. Selector(16bit) • Content of Segment Register(CS ,DS,SS,ES ) is used as Selector • Selector Selects one of the 8192 Descriptor from one of the table i.e GDT and LDT. • Descriptor Index and Table Index (TI) : – The 13 bit descriptor index selects one of up to 8K descriptors in either the GDT and LDT, as specified by the TI bit. • Therefore, these 14 bits allows access to 16K 8-byte descriptors. • RPL : – The desired privilege level of the program. – Access is granted if the RPL value is lower (higher in privilege) than the AR of the segment. Otherwise, a privilege violation is issued
  • 14. • Segmentation provides both memory management and protection. • All information about the segments is stored in an 8-byte data structure called a descriptor. • All the descriptors are stored in tables identified by the 80386 hardware. There are three types of tables holding 80386 descriptors: 1. global descriptor table (GDT) 2. local descriptor table (LDT) 3. interrupt descriptor table (I DT). • 80386 processor have many LDT but only one GDT and one IDT.
  • 15. • BASE: It contains the 32-bit base address for a segment. Thus define the location of the segment within the 4 gigabyte Physical Memory. • LIMIT: It defines the size of the segment. When the processor concatenates the two parts of the limit field, a 20-bit value results. The processor interprets the limit field in one of two ways, depending on the setting of the granularity bit:
  • 16. 80386 Descriptor • segment descriptors are a part of the segmentation unit, which provides the processor with the data it needs to translate a logical address into a linear address. • A(Accessed bit):- This bit indicate whether segment has been accessed by CPU or not. • Type field(4 bits)-This field decide the descriptor Type and Segment Type. • S Bit:- This bit decide whether it is a(S=0) system descriptor or (S=1)Segment descriptor(Code /Data Segment). • DPL(descriptor Privilege level):- This field decide descriptor Privilege level. • D bit:-D bit specify the code segment operation Size. If D=1 segment is 32 bit operand segment else 16 bit operand segment. • P bit:- P bit specify whether segment is present in Physical memory or not. • G (Granularity )bit:-This bit indicate whether segment is Page addressable. • AVL(U Bit):- This field specify whether the descriptor is available to user or to the operating system. • Zero bit must remain Zero for Compatibility with future processor.
  • 18. • GDTR is the GDT (Global Descriptor Table) Register. It contains the base address (linear) and limit for the GDT, and is set using lgdt. • LDTR is the LDT (Local Descriptor Table) Register and contains the linear base address and limit for the LDT.
  • 19. • LDTR is a 16 bit Register used to point LDT Descriptor.
  • 20. GDT(Global Descriptor Table) • GDT is Global Descriptor Table.GDT Represent the global memory area shared by all tasks. • There are total 8192 descriptors in GDT. • Each Descriptor is of 64KB size.(8 Bytes)
  • 21. Paging unit enabled in protected mode
  • 23. Control Register 3 (CR3) :- Control register 3 holds the physical address of the root of the two level paging tables used when paging is enabled. It is also called Page Directory Base Register.
  • 24. • Page Descriptor Base Register The 32-bit linear address is stored at the control register CR2 at which the previous page fault can be detected. The control register CR3 is used as page directory which is known as physical base address register. Hence, CR3 is used to store the physical starting address of the page directory. The lower 12 bits of CR3 must be zero so that page size must be 4K and the page size must be aligned with the directory. • Page Directory The size of the page directory is 4 Kbytes. Each directory entry consists of four bytes. Consequently, a total of 1K or 1024 entries are allowed in a directory. The example of a typical directory entry is shown in Fig. 11.42. The upper 10 bits of the linear address are used as an index to the equivalent page directory entry. The corresponding page directory entry is used to indicate the page tables.
  • 25. • P-bit The P-bit can be used in address translation. When P = 1, the entry can be used in address translation. If P = 0, the entry cannot be used. The P-bit of the presently executed page is always high. • U/S and R/W Bit The User/Supervisor (U/S) bit and Read/Write (R/W) bit are used to provide the four level protections as shown in Table 11.21. The level 0 has the highest privilege level, but the level 3 has the lowest privilege level. • A-bit The A-bit (access bit) must be set by the 80386 processor before accessing any page. If A = 1, the page is accessed. When A=0, the page is not accessed. • D-bit The D-bit (Dirty bit) is set before a write operation to the page. The D-bit is undefined for page directory entries. • The OS reserved bits are defined by the operating system
  • 27. Types of system and non - system descriptors
  • 28. System descriptors :- 1. A Local Descriptor Table descriptors (LDT):- • S bit is’0’ and type bit ‘2’. • LDTR selects the LDT Descriptor from Global Descriptor Table. • They points to the base of LDT. • Each task has its own Local Descriptor, which is not shared by other tasks. • LDT can be accessed by user if its privilege level is 0.Otherwise DPL level is neglected.
  • 29. 2. Task State Segment(TSS):-
  • 30. • A Gate Descriptor is special type of Descriptor. The 80386 uses this Gate Descriptor for performing protection Check. • There are four types Gate Descriptor: • Call Gate:-(Type=4)Call Gate used to call functions which is at another privilege level .It can Change the privilege level and transfer program control to higher privilege level. • Interrupt Gate:- :- (Type=6) IDTR used to select the descriptor from GDT .This selected descriptor is called as Interrupt Gate. • Interrupt Gate points to corresponding ISR(Interrupt service routine) to be executed. • Task Gate:- :- (Type=5) They are used in multitasking systems to perform task switching.The task register selects the task gate similar to LDTR selecting LDT descriptor. • Task gate then selects the Task state Segments(TSS)that is used to copy the content of Current task. On return from this Task ,the content of TSS is again loaded into registers. • Trap Gate :-(Type=7) Trap gate is used to handle the single stepping interrupt.
  • 31. • The segmentation can divide the physical memory into different sizes of segments while the Paging divides the memory into fixed-size pages of 4KB. • The main advantage of the paging system is that it is not required in the complete segment of a task in the physical memory at any time. But only some required pages of the segments should he available in the physical memory for the execution. • When the remaining pages of the specified task are required for execution, these pages can be fetched from the secondary memory storage devices.
  • 32. Combining Segment and Page Translation