Memory Segmentation in 8086 Microprocessor || Microprocessors and Microcontrollers
Memory Segmentation in 8086 Microprocessor
Overview of the 8086 Microprocessor
- The 8086 microprocessor is a 16-bit processor, meaning it operates on 16-bit data and has 16-bit registers.
- In contrast, the earlier 8085 microprocessor had 8-bit registers.
Address Bus and Memory Capacity
- The address bus in the 8086 uses 20 bits, allowing for a maximum physical memory capacity of 2^20, which equals 1 megabyte.
- This memory can be segmented into 16 segments, each with a size of 64 kilobytes.
Memory Segmentation Explained
- The main memory is divided into various parts called segments; specifically, it can be divided into up to 16 segments of 64 kilobytes each.
- For illustration, only four segments are discussed:
- Code Segment
- Stack Segment
- Data Segment
- Extra Segment
Details on Memory Segments
- Each segment is designed for specific purposes:
- The Code Segment (CS) contains the currently executing program.
- The Stack Segment (SS) stores subroutines or procedures.
- The Data Segment (DS) and the Extra Segment (ES) are used for storing operands and data related to instructions.
Advantages of Segmentation Registers
- There are four segmentation registers:
- CS: Code Segment Register
- SS: Stack Segment Register
- DS: Data Segment Register
- ES: Extra Segment Register
Functions of Each Register
- CS holds the starting address of the code segment being executed by the CPU. For example, it may contain an address like
5A1H.
- SS stores the starting address for stack operations, such as
5A2H, facilitating function calls and returns using LIFO principles.
Understanding Addressing in Memory
- Addresses in this system require five hexadecimal digits since each digit represents four bits; thus, a total of twenty bits are needed to specify an address fully.
Memory Segmentation in 8086 Microprocessor
Overview of Registers and Their Functions
- The data is held using registers, specifically the data segment register which stores the address of the data segment.
- Offset resistance is introduced; an offset register contains a specific location within a corresponding segment (code, stack, data, or extra).
- Each segment has a size of 64 kilobytes. The offset refers to a particular location within that segment.
Types of Pointer Registers
- Three main pointer registers are identified:
- IP (Instruction Pointer Register)
- SP (Stack Pointer Register)
- BP (Base Pointer Register)
- These three can collectively be referred to as pointer registers. Additionally, SI (Source Index Register) and DI (Destination Index Register) are also categorized as index registers.
Functionality of Key Registers
- The Instruction Pointer points to an offset within the code segment, indicating where execution should begin.
- The Stack Pointer indicates an offset within the stack segment while the Base Pointer can point to offsets in either the data or extra segments.
- Source Index points to an offset in the data segment and Destination Index points to an offset in the extra segment.
Calculating Physical Addresses
- To calculate physical addresses, use the formula:
- Physical Address = Segment Address × 10 + Offset