ASSIGNMENT 1
ASSIGNMENT 1
Ans. 16-bit Data Bus: The 8086 has a 16-bit data bus, which means it can transfer 16 bits of
data at a time, making it faster than its 8-bit predecessors.
20-bit Address Bus: The 8086 uses a 20-bit address bus, which allows it to access up to 1MB
(2^20) of memory.
Segmented Memory Architecture: The 8086 uses a segmented memory model, dividing
memory into different segments (code, data, stack, and extra). This allows for easier
management of memory in larger programs and enables access to more memory beyond the
typical 64KB limits of earlier processors.
Pipelined Architecture: The 8086 uses a pipeline to fetch and decode instructions while
executing other instructions. This improves the efficiency and performance of the processor.
Instruction Set: The 8086 has a rich and versatile instruction set, including arithmetic, logic,
control, and data transfer instructions, making it suitable for a wide range of applications.
Multiplexed Address and Data Bus: The address and data buses share the same physical
pins, with the higher-order address bits being multiplexed with the data lines, which reduces the
number of pins on the microprocessor.
Clock Speed: The 8086 operates at clock speeds ranging from 5 MHz to 10 MHz, allowing it
to process more instructions per second than older processors.
Interrupt System: The 8086 supports hardware interrupts with a priority system, allowing it
to handle multiple external interrupt requests.
Two Modes of Operation: The 8086 operates in two modes—minimum mode and maximum
mode. Minimum mode is used for single-processor systems, while maximum mode supports
multiprocessor configurations.
Registers: The 8086 has 14 registers, including general-purpose registers (AX, BX, CX, DX),
segment registers (CS, DS, ES, SS), and pointer registers (SP, BP, SI, DI). These help in
managing data and addressing memory.
Ans. Pipelining is a technique used in microprocessor design where multiple instruction phases
(such as fetch, decode, execute, and write-back) are overlapped. Instead of executing one
instruction completely before starting the next, pipelining allows the processor to work on
different stages of multiple instructions simultaneously. This results in more efficient use of the
processor's resources and faster processing of instructions.
Advantages of Pipelining:
1. Increased Instruction Throughput: Pipelining allows multiple instructions to be in
different stages of execution at the same time. As a result, more instructions can be
processed in a given period, increasing the throughput of the processor.
2. Improved CPU Efficiency: By overlapping instruction stages, the processor can avoid
idle times that would otherwise occur if only one instruction was being processed at a
time. This leads to better overall utilization of the processor’s execution units, improving
efficiency.
3. Faster Execution: Pipelining reduces the time it takes to complete a set of instructions
by processing parts of multiple instructions in parallel, thereby speeding up the overall
execution time for programs.
4. Better Resource Utilization: Pipelining helps ensure that different functional units
within the processor (like the ALU, registers, and memory) are always in use, reducing
bottlenecks and underutilization of resources.
Ans. The 8086 microprocessor has several 16-bit registers that are used for various operations
such as data manipulation, memory addressing, and control. Here are the 16-bit registers in the
8086:
Ans. The Flag Register in the 8086 microprocessor is a 16-bit register that contains several
individual flags which indicate the status of the processor after an operation. It is used to reflect
the outcome of arithmetic, logical, and control operations. The flags in the 8086 are divided into
status flags, control flags, and system flags.
Flags Description:
Pin Functions:
1. Address/Data Bus (AD0-AD15): These 16 pins are multiplexed to carry both address
and data. They are used to transfer data between the processor and memory or I/O
devices.
2. Address Bus (A16-A19): These 4 pins carry the higher order bits (address lines) for
addressing memory in the 1MB address space.
3. Control Signals:
o /RD: Read signal, used to read data from memory or I/O.
o /WR: Write signal, used to write data to memory or I/O.
o /M/IO: Memory or I/O control signal, determines whether the operation involves
memory or I/O.
o /ALE: Address Latch Enable, used to latch the address into the address buffer.
o /INTA: Interrupt Acknowledge, used in response to interrupts.
o /S0, /S1, /S2: Status signals, indicating the type of operation being performed
(memory, I/O, etc.).
o READY: Indicates that the processor is ready to proceed with the next operation.
4. Clock Pin (CLK): Provides the clock signal to synchronize the operations of the
processor.
5. Reset Pin (RESET): Resets the processor, returning it to its initial state.
6. Interrupts:
o /NMI: Non-maskable interrupt, used for high-priority interrupts.
o /INTR: Interrupt request, used for normal interrupt handling.
7. Power Supply Pins:
o VCC: Positive supply voltage (typically +5V).
o GND: Ground.
In the 8086 microprocessor, pipelining divides the instruction execution process into multiple
stages. The main stages are:
Pipelining works by overlapping these stages. While one instruction is being executed, the next
instruction is being decoded, and the one after that is being fetched. By the time the first
instruction finishes, the second instruction is already in the execution stage, and the third is in the
decode stage.
This overlap minimizes idle time and maximizes the processor's efficiency.
Time Instruction 1: MOV AX, Instruction 2: ADD AX, Instruction 3: MOV CX,
Cycle 05h BX AX
Cycle 1 Fetch
Cycle 2 Decode Fetch
Cycle 3 Execute Decode Fetch
Cycle 4 Write Back Execute Decode
Cycle 5 Write Back Execute
1. Fetch (F):
o The instruction is fetched from memory. The program counter (PC) points to the
next instruction.
2. Decode (D):
o The instruction is decoded to determine what operation is to be performed and
which operands are required.
3. Execute (E):
o The operation is executed. This could involve arithmetic or logic operations, or it
could involve reading or writing to memory.
4. Write Back (WB):
o The result of the operation is written back to the destination register or memory.
Diagram of Pipelining:
Advantages of Pipelining:
1. Increased Throughput: Since multiple instructions are in various stages at the same
time, more instructions are processed per clock cycle, leading to higher throughput.
2. Faster Execution: By overlapping the execution of instructions, the overall execution
time for a set of instructions is reduced.
3. Better CPU Utilization: Pipelining helps keep different parts of the processor busy.
While one part is executing, other parts (like the fetch or decode stages) are working on
other instructions.
Disadvantages of Pipelining:
1. Pipeline Hazards:
o Data Hazards: When an instruction depends on the result of the previous one
(e.g., using the value of a register before it’s updated).
o Control Hazards: When there’s a branch instruction, it’s hard to know which
instruction to fetch next.
o Structural Hazards: Occur when hardware resources are insufficient to support
the simultaneous execution of multiple stages.
2. Complexity: Pipelining adds complexity to the processor design, requiring sophisticated
control logic to handle hazards and ensure that the pipeline operates efficiently.
Ans. The Bus Interface Unit (BIU) is a critical component of the 8086 microprocessor
architecture. Its primary role is to manage the communication between the processor and the
external memory or I/O devices. The BIU handles all the bus operations required for instruction
fetch, data transfer, and memory access. Below are the important functions of the BIU:
1. Address Generation:
o The BIU generates the physical address that is sent to the memory or I/O. It
combines the segment base address (from the segment registers) and the effective
address (from the instruction or data) to create the physical address.
2. Instruction Fetching:
o The BIU is responsible for fetching instructions from memory. It pre-fetches
instructions into an instruction queue (which can hold up to 6 bytes of
instructions). This allows the processor to access instructions faster and ensures
smoother instruction flow in the pipeline.
3. Segmentation:
o The BIU handles the segmented memory model of the 8086. It manages the
segment registers (CS, DS, ES, SS) and uses them to calculate the segment base
address and combine it with the offset to form the physical address.
4. Memory and I/O Access:
o It manages the read and write operations to memory and I/O devices. The BIU
communicates with external memory or I/O using the data bus and address bus,
facilitating data transfer between the CPU and the outside world.
5. Data Transfer:
o The BIU handles the transfer of data between the processor and memory or I/O.
It controls the data bus (AD0-AD15) and ensures the correct data is placed on the
bus for reading or writing.
6. Instruction Queue:
o The BIU manages the instruction queue, which is a 6-byte FIFO queue that
stores instructions to be executed. This allows for pre-fetching of instructions
while other instructions are being decoded and executed, optimizing the overall
processor speed and efficiency.
7. Control Signals Generation:
o The BIU generates control signals required for various operations, such as
Memory Read (RD), Memory Write (WR), and I/O operations. These signals
help the Execution Unit (EU) and external devices to synchronize with the
microprocessor.
8. Segment Addressing:
oIt uses the segment registers to divide memory into segments and handle memory
addressing. Each segment can be up to 64KB in size, and the BIU helps the
processor access the required memory location using segment base + offset.
9. Synchronization with Execution Unit (EU):
o The BIU works in conjunction with the Execution Unit (EU) to ensure proper
synchronization of operations. While the EU executes instructions, the BIU is
responsible for pre-fetching the next instructions and managing data transfer,
ensuring a smooth flow of execution.
Ans. The Execution Unit (EU) is a critical part of the 8086 microprocessor architecture. Its
primary function is to execute the instructions fetched by the Bus Interface Unit (BIU). The EU
handles all arithmetic, logic, control, and data processing tasks, and it interacts with various
registers, flags, and memory. Below are the important functions of the Execution Unit (EU):
1. Instruction Execution:
o The EU is responsible for executing the decoded instructions. These could
involve arithmetic operations (e.g., addition, subtraction), logical operations (e.g.,
AND, OR), data movement (e.g., MOV), or control operations (e.g., jumps,
loops).
o It performs these operations based on the instruction provided by the BIU.
2. Arithmetic and Logic Operations:
o The EU contains the Arithmetic Logic Unit (ALU), which performs arithmetic
and logical operations. These include:
Arithmetic: Addition, subtraction, multiplication (in certain cases), and
division (in certain cases).
Logical: AND, OR, NOT, XOR.
o The results of these operations are stored in the general-purpose registers (AX,
BX, CX, DX) or the status flags.
3. Data Transfer:
o The EU is responsible for transferring data between the processor's internal
registers and the Bus Interface Unit (BIU).
o It can move data between general-purpose registers, segment registers,
memory, and I/O devices.
4. Control Operations:
o The EU handles control operations like:
Conditional Branching: Based on flags like the Zero Flag (ZF), Carry
Flag (CF), etc., it can perform jumps (conditional or unconditional) or
loops.
Interrupt Handling: The EU checks and handles interrupts, including
processing the interrupt request and managing the interrupt response.
5. Flag Manipulation:
o The EU modifies the Flag Register based on the outcome of the instructions
executed. It updates flags such as:
Zero Flag (ZF): Set if the result of an operation is zero.
Carry Flag (CF): Set if there is a carry or borrow during arithmetic
operations.
Sign Flag (SF): Set if the result is negative.
Overflow Flag (OF): Set if there is a signed overflow.
Auxiliary Carry Flag (AF): Used for binary-coded decimal (BCD)
arithmetic.
Parity Flag (PF): Set if the result has an even number of 1s in the binary
representation.
6. Stack Operations:
o The EU performs stack operations by interacting with the Stack Pointer (SP)
and Base Pointer (BP) registers. It supports operations such as:
PUSH: Pushing data onto the stack.
POP: Popping data from the stack.
CALL and RETURN: Used in function calls and returns, typically
updating the stack and Program Counter (PC).
7. Managing Conditional and Unconditional Jumps:
o The EU evaluates the flags set by previous instructions to make decisions about
branching in the code.
o It handles conditional jumps based on the state of the flags (e.g., jump if zero,
jump if carry) and unconditional jumps to alter the flow of execution.
8. Handling I/O Operations:
o The EU coordinates the transfer of data to and from I/O ports. While the BIU
manages the actual bus operations, the EU generates the necessary control signals
and ensures the right registers are used for I/O communication.
9. Instruction Decoding:
o The EU works in conjunction with the BIU to decode instructions. Once the BIU
fetches the instruction from memory, the EU decodes the instruction to determine
what operation needs to be performed.
10. Efficient Pipelining:
o The EU works alongside the BIU in a pipelined fashion, ensuring that while one
instruction is being executed, the next instruction is already being decoded, and
the one after that is being fetched. This helps improve the overall speed and
performance of the microprocessor.
The 8086 microprocessor uses a segmented memory model to address memory. This memory
segmentation allows the processor to access a larger memory space beyond the 16-bit address
limitation by dividing memory into different segments. Each segment can be up to 64 KB in size,
and the total addressable memory is 1 MB (1024 KB), which is achieved by combining multiple
segments.
In the 8086, the segment registers are used to point to different parts of memory. These segment
registers allow the microprocessor to access memory efficiently, even though it uses a 16-bit
address bus. The segmentation mechanism divides memory into code, data, stack, and extra
segments, allowing the 8086 to work with more than 64 KB of memory.
Code Segment (CS): Holds the base address of the code (program) stored in memory.
Data Segment (DS): Holds the base address of data used by the program.
Stack Segment (SS): Holds the base address of the stack.
Extra Segment (ES): Used for extra data storage, often used in string operations.
Each of these segment registers holds a 16-bit value, but the effective memory addressing in
8086 is 20-bit. This is achieved by shifting the 16-bit value of the segment register 4 bits to the
left and then adding the 16-bit offset to form a 20-bit physical address.
For example:
If the CS register contains 0x2000 (the base address of the code segment), and the
instruction pointer (IP) contains 0x0050 (the offset), the physical address would be
calculated as:
1. Code Segment (CS): This segment contains the program's executable code. The CS
register holds the base address of the code segment. The program's instructions are
fetched from this segment.
2. Data Segment (DS): This segment holds the data used by the program. The DS register
points to the base address of the data segment. It is used for accessing variables, arrays,
and data structures.
3. Stack Segment (SS): The stack segment is used for stack operations such as function
calls, returns, and storing local variables. The SS register points to the base address of the
stack. The stack grows downwards in memory.
4. Extra Segment (ES): The ES register is used to hold the base address of an extra data
segment. This segment is often used in string operations, where data may need to be
transferred between different memory locations.
The 8086 microprocessor uses a segmented memory model to access memory beyond its 16-
bit address limit. The processor generates a 20-bit physical address by combining the contents
of a 16-bit segment register and a 16-bit offset. This method allows the 8086 to address up to 1
MB (1024 KB) of memory, which would not be possible with a simple 16-bit address bus.
The process of generating the physical address in the 8086 involves the following steps:
2. Offset: An offset is the displacement within the segment. The offset is generally given by
the instruction pointer (IP) for the code segment or by the specified memory address for
data and stack segments.
The physical address is calculated by combining the contents of a segment register and an
offset. The physical address is generated by the formula:
css
Copy
Physical Address = (Segment Register × 16) + Offset
Steps to Generate the Physical Address:
1. Segment Register: The value in the segment register (CS, DS, SS, or ES) is
taken as a 16-bit value.
2. Shift Left by 4: The segment register value is shifted left by 4 bits (i.e.,
multiplied by 16). This gives the base address for the segment.
3. Add the Offset: The 16-bit offset value (which is the address within the
segment) is added to the shifted segment value to obtain the physical
address.
Step-by-Step Calculation:
Copy
Segment × 16 = 0x2000 × 16 = 0x20000
css
Copy
Physical Address = Segment × 16 + Offset
Physical Address = 0x20000 + 0x0050 = 0x20050
Similarly, the same calculation method applies to the Data Segment (DS), Stack Segment (SS),
and Extra Segment (ES).
Data Segment (DS) could point to a memory area where data is stored.
Stack Segment (SS) could point to the area where the stack grows or
shrinks.
Extra Segment (ES) is often used for string operations and can point to
another data area.
1. Segment Register (e.g., CS for the code segment) holds the base address
of the segment.
2. Shift Left by 4 Bits: The segment base is shifted left by 4 bits, which is the
same as multiplying by 16, to get the starting address of the segment in
memory.
3. Offset: The offset is the address within the segment (e.g., IP or another
pointer).
4. The final result is the physical address, which is a 20-bit address that
uniquely identifies the memory location.
1. Logical Address:
The logical address is the address generated by the Instruction Pointer (IP) or any other offset
combined with a segment register (such as CS, DS, SS, or ES). It refers to the address in a
segment before it's translated into a physical address.
Segment: The base address of the segment (e.g., CS, DS, SS, ES).
Offset: The position of the data or instruction within the segment (e.g., IP for
instructions).
less
Copy
Logical Address = (Segment: Offset)
2. Effective Address:
The effective address refers to the offset within the segment. In 8086 terminology, the effective
address is simply the offset value that refers to the location of data or code within a segment.
It’s calculated directly by using the offset from the instruction and the segment for code/data,
typically used to access memory locations during execution.
3. Physical Address:
The physical address is the actual address in memory that the processor accesses. The physical
address is calculated by combining the segment base address and the offset to generate a 20-bit
address.
The physical address in the 8086 microprocessor is calculated using the formula:
css
Copy
Physical Address = (Segment × 16) + Offset
Where:
Given:
Step-by-Step Calculation:
*END*