Lecture 3
Microprocessor Operations
• Microprocessor Operations
• Microprocessor initiated operations Micropr
I/O
• Internal operations ocessor
• Externally or peripherally initiated operations
Memor
y
Microprocessor
initiated operations
• There are 4 Microprocessor-
initiated operations:
• Memory read
• Memory write
• I/O read
• I/O write
Microprocessor
initiated operations
• Procedure
• Identify the memory or I/O
with its address
• Control signals (Provide
timing and synchronization
signals)
• Read operation
• Write operation
• Memory or I/O
• Perform data transfer
• Data bus
These operations takes place inside
the Microprocessor
Storing the data----Registers
Internal
Operations Registers
• General purpose registers
• Segment registers
• Base registers/Point registers
• Index registers
• Instruction pointer
General Purpose Register Name Purpose
Registers AX Accumulator
Used for arithmetic,
logic, and I/O
operations
• Used for data manipulation,
arithmetic, logic, and some I/O BX Base
Used for addressing
data
operations.
• Each can be split into 8-bit halves: Used as loop counter
CX Count and shift/rotate
• AX → AH + AL operations
• BX → BH + BL
Used in
• CX → CH + CL DX Data multiplication/division
• DX → DH + DL and I/O
AX (Accumulator Register)
The primary special function of AX is to serve as the default
destination for arithmetic and logic operations.
Multiplication & Division: In 16-bit multiplication, AX holds
the lower 16 bits of the result. In division, it holds the
quotient.
I/O Operations: For all I/O instructions (like IN or OUT),
data must pass through AX (for 16-bit) or AL (for 8-bit).
BCD Arithmetic: AX is used as an implicit operand for BCD
(Binary Coded Decimal) conversion instructions
like AAA or DAA.
Its primary special function is to act as
a base pointer for memory addressing in
the data segment.
BX (Base Indirect Addressing: Unlike AX, CX, or
DX, BX can hold an offset address to
Register) point to data in memory.
Base for Tables: It is frequently used to
store the starting address of a data table
or array, allowing subsequent data to be
accessed via an index.
CX (Counter Register)
The primary special function of CX is to act as
an automatic loop and shift counter.
•Loop Control: For instructions like LOOP, the
microprocessor automatically decrements CX
by one and jumps until CX reaches zero.
•String Operations: It specifies the number
of times a string operation (like REP) should
repeat.
•Shift & Rotate: In multi-bit shift or rotate
instructions, the CL register (lower half of CX)
holds the count for the operation.
DX (Data Register)
The primary special function of DX is to hold extended
data for multiplication, division, and I/O.
Extended Results: In 32-bit multiplication results, DX holds
the high-order (upper) 16 bits.
Large Division: Before a 32-bit division, the high-order bits
of the dividend must be placed in DX.
I/O Port Addressing: For I/O port addresses exceeding 255
(up to 64K), the address must be stored specifically in the
DX register.
Segment registers
Physical address
00000H
• There are four segment registers
• Code segment
• Data segment
• Stack segment
• Extra segment
• Each register is of 16-bit
• But the physical address is of 20-bit
• How to generate the physical address
from the effective address?
FFFFFH
Code Segment
• Stores the program instructions
• To locate the next instruction, it uses:
• [CS]: It holds the base address of the code segment
• IP (Instruction Pointer): It holds the offset (distance) of the next
instruction within the code segment
Data Segment
• The Data Segment (DS) is used to store data values
(variables, constants, arrays) that a program operates on.
• It is identified by the DS register
• To access data, the 8086 uses:
• DS (Data Segment register): base address of the data segment
• Offset (from registers like BX, SI, or DI)
Extra segment
• To store excess data
• Shared data among multiple users
• String operations
• Offset will be stored in Source Index (SI) and Destination
Index (DI)
Stack segment
High Memory Address
Stack Bottom
│
PUSH → ↓
│
POP ← ↑
│
Stack Top (SP)
Low Memory Address
Base Registers
• The 8086 has two pointer registers:
• SP – Stack Pointer
• BP – Base Pointer
• Both are 16-bit registers and are mainly used for stack
operations.
• What is BP?
• BP (Base Pointer) is a 16-bit register
• Mainly used to access data in the Stack Segment
• Default segment register with BP is SS
BP is part of the Pointer and Index
Registers group. Unlike BX, which is often used for
general data, BP is specialized for stack operations.
Segment Association: By default, BP provides an
offset for the Stack Segment (SS).
Base
Pointer Function in Programs: It is primarily used to
access data (like local variables and function
parameters) stored on the stack without affecting
the Stack Pointer (SP).
Flexibility: While it defaults to the stack, it can be
used to access other segments if explicitly specified
by the programmer.
Stack Pointer
• It is a 16-bit register that tracks the top of the stack memory
• Stack memory: Location where most recent data is stored
• The SP register is automatically updated during specific
operations:
• PUSH: Before data is stored, SP is decremented by 2. The 16-bit
value is then written to the new address.
• POP: After data is read from the stack, SP is incremented by 2.