8086 Memory Banking - Advanced Memory Organization
Master the advanced concepts of memory banking in 8086 systems, including interleaved memory access, bank switching techniques, and performance optimization strategies.
Introduction to Memory Banking
Memory Banking is an advanced memory organization technique that divides the available memory into separate banks or modules that can be accessed independently or in parallel. In 8086 systems, memory banking is crucial for achieving optimal performance, especially when dealing with 16-bit data transfers and addressing the inherent limitations of the 8-bit data path in some implementations.
Foundation Concepts
- Memory Bank: Independent memory module with its own control signals
- Bank Interleaving: Technique to overlap memory access operations
- Bank Switching: Method to access memory beyond directly addressable space
- Parallel Access: Simultaneous operation of multiple memory banks
- Address Mapping: Logical to physical address translation across banks
Why Memory Banking is Important
Performance Benefits:
- Reduced Memory Access Time: Overlapped access cycles
- Increased Bandwidth: Parallel data transfer capabilities
- Better Resource Utilization: Efficient use of memory modules
- Scalability: Easy expansion of memory capacity
System Design Advantages:
- Modular Architecture: Flexible memory configuration
- Cost Optimization: Use of different memory types per bank
- Fault Tolerance: Isolation of memory failures
- Power Management: Selective bank activation
8086 Memory Banking Architecture
The 8086 microprocessor supports various memory banking configurations, from simple two-bank systems to complex multi-bank arrangements with sophisticated control logic.
Basic Two-Bank System
The most common 8086 memory banking implementation uses two banks: one for even addresses and one for odd addresses.
Bank Selection Logic
| A0 | BHE | Bank 0 (Even) | Bank 1 (Odd) | Operation Type | Data Transfer |
|---|
| 0 | 0 | Active | Active | Word Transfer | 16-bit data from both banks |
| 0 | 1 | Active | Inactive | Byte Transfer (Even) | 8-bit data from even bank |
| 1 | 0 | Inactive | Active | Byte Transfer (Odd) | 8-bit data from odd bank |
| 1 | 1 | Inactive | Inactive | Invalid | No operation |
Address Distribution in Banks
Even Bank (Bank 0) - Addresses:
Pattern: All addresses where A0 = 0
Examples: 00000H, 00002H, 00004H, 00006H, ...
Data Lines: Connected to D7-D0
Control: Enabled when A0 = 0
Odd Bank (Bank 1) - Addresses:
Pattern: All addresses where A0 = 1
Examples: 00001H, 00003H, 00005H, 00007H, ...
Data Lines: Connected to D15-D8
Control: Enabled when BHE = 0
Interleaved Memory Access
Memory Interleaving is a technique where consecutive memory locations are distributed across different banks, allowing parallel access to improve overall memory bandwidth and reduce access time.
Interleaving Concepts
Basic Interleaving Principle:
While one bank is being accessed, other banks can be prepared for the next access, effectively hiding memory latency through parallel operation.
Types of Interleaving:
- 2-Way Interleaving: Two banks alternating (most common in 8086)
- 4-Way Interleaving: Four banks cycling
- Higher-Order Interleaving: More banks for specialized systems
Interleaved Access Timing
Performance Analysis
Interleaving Implementation
Hardware Requirements:
- Address Decoders: Route addresses to appropriate banks
- Bank Selection Logic: Generate individual bank enable signals
- Data Multiplexers: Route data between CPU and active banks
- Timing Controllers: Coordinate access sequences
Address Mapping Schemes:
| Address | Binary (Last 3 bits) | Bank Selection | Internal Address |
|---|
| 0000H | 000 | Bank 0 | 0000H |
| 0001H | 001 | Bank 1 | 0000H |
| 0002H | 010 | Bank 0 | 0001H |
| 0003H | 011 | Bank 1 | 0001H |
Bank Switching Techniques
Bank Switching allows systems to access more memory than can be directly addressed by the processor, by selectively mapping different memory banks into the addressable space.
Bank Switching Fundamentals
Why Bank Switching?
- Address Space Limitation: 8086 can only directly address 1MB
- Memory Expansion: Access to multi-megabyte memory systems
- Application Separation: Isolate different programs or data
- Virtual Memory Simulation: Early form of memory management
Bank Switching Mechanisms:
- Hardware Registers: CPU writes to special I/O ports
- Memory-Mapped Control: Special memory locations control switching
- External Logic: Dedicated bank switching controllers
- Software Protocol: Standardized switching procedures
Bank Switching Architecture
Bank Switching Implementation Example
EMS (Expanded Memory Specification) Style Banking:
Bank Switching Code:
; Switch to Bank 2 MOV AL, 02H ; Bank number in AL OUT 40H, AL ; Write to bank register at port 40H ; Access data in the switched bank MOV SI, 8000H ; Address in switchable window MOV AX, [SI] ; Read data from Bank 2 ; Switch back to Bank 0 MOV AL, 00H ; Bank 0 OUT 40H, AL ; Switch to Bank 0
Memory Map with Bank Switching:
| Address Range | Content | Switchable | Purpose |
|---|
| 00000H - 7FFFFH | System Memory | No | OS, Programs |
| 80000H - 8FFFFH | Switchable Bank | Yes | Extended Data |
| 90000H - FFFFFH | Reserved/ROM | No | BIOS, Video |
Advanced Bank Switching Schemes
Multi-Window Banking:
Multiple switchable windows allow simultaneous access to different banks:
- Window 1: 80000H - 8FFFFH (Bank A)
- Window 2: 90000H - 9FFFFH (Bank B)
- Window 3: A0000H - AFFFFH (Bank C)
Hierarchical Banking:
Multiple levels of bank selection for very large memory systems:
- Page Selection: Choose 1MB page
- Bank Selection: Choose 64KB bank within page
- Total Capacity: 256 pages × 16 banks = 4GB theoretical
Performance Optimization with Memory Banking
Optimization Strategies
Software Optimization:
- Bank Locality: Keep related data in the same bank
- Minimize Switching: Reduce bank switching overhead
- Prefetching: Prepare next bank while processing current
- Buffer Management: Use system memory as cache for banked data
Hardware Optimization:
- Fast Switching Logic: Reduce bank switching time
- Parallel Banks: Access multiple banks simultaneously
- Cache Integration: Combine banking with cache memory
- DMA Support: Direct memory access across banks
Performance Metrics
Real-World Performance Examples
Practical Implementation Examples
Complete Banking System Design
System Specifications:
- Total Memory: 4MB using bank switching
- Bank Size: 64KB per bank
- Number of Banks: 64 banks
- Switching Method: I/O port control
- Interleaving: 2-way within active bank
Hardware Components:
Programming Examples
Bank Management Library:
; Bank switching library for 8086 ; Author: System Programmer ; Purpose: Manage memory banks efficiently CURRENT_BANK DB 0FFH ; Track current bank (FFH = unknown) BANK_PORT EQU 40H ; Bank selection port ; Procedure: SWITCH_BANK ; Input: AL = target bank number (0-63) ; Output: None ; Destroys: None (preserves all registers) SWITCH_BANK PROC PUSH AX CMP AL, CURRENT_BANK ; Check if already in target bank JE SWITCH_DONE ; Skip if same bank OUT BANK_PORT, AL ; Select new bank MOV CURRENT_BANK, AL ; Update current bank tracker ; Small delay for bank switching PUSH CX MOV CX, 10 ; Delay loops SWITCH_DELAY: LOOP SWITCH_DELAY POP CX SWITCH_DONE: POP AX RET SWITCH_BANK ENDP ; Procedure: COPY_BETWEEN_BANKS ; Input: AL = source bank, AH = dest bank ; SI = source offset, DI = dest offset ; CX = bytes to copy ; Output: None COPY_BETWEEN_BANKS PROC PUSH AX PUSH BX PUSH CX PUSH DX PUSH SI PUSH DI MOV BL, AL ; Save source bank MOV BH, AH ; Save dest bank COPY_LOOP: ; Switch to source bank and read MOV AL, BL CALL SWITCH_BANK MOV DL, [SI] ; Read byte from source INC SI ; Switch to dest bank and write MOV AL, BH CALL SWITCH_BANK MOV [DI], DL ; Write byte to dest INC DI LOOP COPY_LOOP POP DI POP SI POP DX POP CX POP BX POP AX RET COPY_BETWEEN_BANKS ENDP
Performance Testing
Advanced Topics and Future Concepts
Evolution to Modern Memory Systems
The memory banking concepts introduced with the 8086 evolved into sophisticated memory management systems in modern processors.
| Concept | 8086 Era | Modern Implementation | Key Improvements |
|---|
| Banking | Manual bank switching | Virtual memory paging | Automatic, hardware-managed |
| Interleaving | 2-4 way interleaving | Multi-channel DDR memory | 8+ channels, automatic |
| Address Translation | Simple segment:offset | MMU with TLB | Hardware translation caching |
| Bank Selection | Software I/O ports | Page table entries | OS-managed, transparent |
Learning Outcomes and Applications
Key Concepts Mastered:
- Memory Organization: Understanding bank-based memory systems
- Performance Optimization: Interleaving for bandwidth improvement
- Address Translation: Logical to physical address mapping
- System Design: Hardware-software interface design
- Trade-off Analysis: Performance vs. complexity decisions
Practical Applications:
- Embedded Systems: Memory-constrained environments
- Real-time Systems: Predictable memory access patterns
- Graphics Systems: Frame buffer management
- Database Systems: Buffer pool management
- Operating Systems: Memory management unit design
Design Considerations Summary
When to Use Memory Banking:
| Scenario | Recommendation | Primary Benefit | Implementation Cost |
|---|
| Sequential data processing | Interleaved banking | High bandwidth | Medium |
| Large memory requirements | Bank switching | Extended capacity | Low |
| Multi-application systems | Combined approach | Isolation + performance | High |
| Cost-sensitive designs | Simple banking | Moderate expansion | Low |