Microprocessors & Microprogramming: Addressing Modes, Registers, and Pipelining

What is a Microprocessor?

Three Main Functions of a Microprocessor:

1. Data Processing:

The microprocessor performs arithmetic (addition, subtraction, multiplication, division) and logical (AND, OR, NOT) operations on data.

2. Control Function:

The microprocessor controls all other system components by sending signals. It fetches, decodes, and executes instructions, directing hardware components like input/output devices and memory.

3. Data Transfer:

The microprocessor facilitates data movement between components, including transferring data between memory, registers, and external devices.

What is an Addressing Mode?

An addressing mode specifies how the operand (data on which an instruction operates) is identified in an instruction. It determines how the CPU fetches the operand, which can be from registers, memory, or immediate values.

Types of Addressing Modes:

  1. Immediate Addressing Mode: The operand is part of the instruction. Example: MVI A, 05H (05H is the operand)
  2. Register Addressing Mode: The operand is in a CPU register. Example: MOV B, A (Value in register A is moved to B)
  3. Direct Addressing Mode: The operand’s memory address is specified in the instruction. Example: STA 2000H (Stores the accumulator value into memory address 2000H)
  4. Indirect Addressing Mode: The operand’s memory address is held in a register or memory location. Example: MOV A, M (Value in the memory location pointed to by a register pair is moved to register A)
  5. Indexed Addressing Mode: The operand’s address is determined by adding an offset to a base address in a register. Example: MOV A, [Base + Index]

Why STA 2000H is Direct Addressing Mode:

In STA 2000H, the operation stores the accumulator’s contents (A) into memory location 2000H. 2000H is a 16-bit memory address given directly in the instruction. The CPU directly stores the value in the given memory location (2000H).

Registers in 8085

The 8085 microprocessor uses various registers for data handling and control during instruction execution. These registers can be categorized into:

1. General-Purpose Registers:

  • B, C, D, E, H, L Registers: Each is 8-bit and can be used individually or in pairs (BC, DE, HL) for 16-bit operations. The HL pair often acts as a memory pointer.

2. Special-Purpose Registers:

  • Accumulator (A Register): An 8-bit register used for arithmetic, logic, and data transfer operations.
  • Program Counter (PC): A 16-bit register holding the address of the next instruction to be executed.
  • Stack Pointer (SP): A 16-bit register pointing to the top of the stack, a memory area used for temporary storage.

3. Status Register (Flag Register):

  • Sign Flag (S): Set if the result is negative.
  • Zero Flag (Z): Set if the result is zero.
  • Auxiliary Carry Flag (AC): Set if there’s a carry from bit 3 to bit 4 during addition.
  • Parity Flag (P): Set if the result has an even number of 1s.
  • Carry Flag (CY): Set if there’s a carry out of the most significant bit during addition or a borrow during subtraction.

4. Temporary Register:

  • Temporary Data Register: An 8-bit register used internally by the microprocessor for temporary data storage during instruction execution. It’s not accessible to the programmer.

5. Instruction Register and Decoder:

  • Instruction Register: Holds the opcode of the currently decoded instruction.
  • Instruction Decoder: Decodes the opcode in the instruction register and determines the actions to be taken.

Main Memory vs. Control Memory in Microprogrammed Controlled Computers

What is DMA and Why is it Used?

Direct Memory Access (DMA) allows hardware components (like peripherals) to directly read from or write to system memory without involving the CPU. This is managed by a DMA controller.

Reasons for Using DMA:

  1. CPU Efficiency: DMA frees the CPU from data transfer tasks, allowing it to focus on processing.
  2. Faster Data Transfer: DMA enables faster transfer of large data blocks by bypassing slower CPU-mediated processes.
  3. Multitasking: The CPU can process other tasks while DMA handles data transfer, improving system performance.
  4. Reduced Latency: DMA minimizes delays in data handling, ideal for high-speed I/O devices.
  5. Improved System Performance: DMA helps maintain system throughput and reduce bottlenecks in high-performance and real-time systems.

Memory Address Map

A Memory Address Map is a structured representation of how memory addresses are allocated to various memory components (RAM, ROM, I/O devices). It outlines address ranges for each type, enabling efficient CPU access.

Importance:

  1. Organization: Prevents memory space conflicts.
  2. Efficient Access: Enables quick access to memory locations.
  3. Resource Management: Aids in allocating resources among devices.

Example:

Consider an embedded system with:

Address RangeComponentSize
0x0000 to 0x1FFFROM8 KB
0x2000 to 0x3FFFRAM8 KB
0x4000 to 0x4FFFI/O Devices4 KB

Explanation:

  • ROM (0x0000 to 0x1FFF): Stores firmware or boot instructions, accessed during startup.
  • RAM (0x2000 to 0x3FFF): Used for active data and running programs, allowing read and write operations.
  • I/O Devices (0x4000 to 0x4FFF): Reserved for interfacing with peripherals, enabling communication with the CPU.

Data Dependency in Pipelining

Data dependency in pipelining occurs when instructions depend on the results of previous instructions, potentially causing hazards that affect pipeline execution.

1. Types of Dependencies:

  • True Dependency (Read After Write): An instruction needs the result of a previous instruction.
  • Anti-Dependency (Write After Read): An instruction writes to a location before a previous instruction reads from it.
  • Output Dependency (Write After Write): Two instructions write to the same location.

2. Impact on Pipelining:

  • Dependencies can cause stalls or bubbles in the pipeline, reducing efficiency.

3. Hazards:

  • Data Hazards: Arise from dependencies and can be categorized into:
    • Read-after-write (RAW): Requires forwarding or stalling.
    • Write-after-read (WAR): Can occur in out-of-order execution.

4. Mitigation Techniques:

  • Forwarding: Sending an instruction’s output directly to another’s input, bypassing registers.
  • Stalling: Introducing pipeline stalls to wait for data.

5. Performance Implications:

  • Unmanaged dependencies can significantly degrade pipeline performance.

Micro-operations and Block Diagram

A micro-operation (μ-op) is the smallest operation performed by the CPU’s control unit during instruction execution. It’s a fundamental step involving simple tasks completed in one clock cycle.

Machine-level instructions are broken down into micro-operations, including:

  1. Data transfer between registers
  2. ALU operations
  3. Memory read/write operations
  4. Program counter updates

[Insert Block Diagram Here – The block diagram would visually represent the registers (AR, BR), ALU, control variables (x, y, z), and logic gates implementing the control function for the given micro-operation x + yz and the register transfer AR ← AR + BR.]