MP-Notes
MP-Notes
Architecture of 8086
1. B.I.U:
a. The BIU sends an address, fetches instructions from memory, reads data
from memory and writes data to memory.
b. In other words, B.I.U handles transfer of data and address on buses for
execution unit
c. It consists of following parts:
1. Queue:
2. Segment registers:
This register works with the Code Segment (CS) register to keep track
of where the next instruction in the program is located.
The IP holds a 16-bit address that tells the CPU where to find the next
byte of code to execute within the code segment.
a. Execution unit tells BIU from where to fetch the data and then decode and execute
those instructions.
b. Its function is to control operations on data using the instruction decoder & ALU.
c. It consist of following functional parts:
i. ALU
It handles all arithmetic and logical operations, like +, −, ×, /, OR, AND, NOT
operations.
It is a 16-bit register that behaves like a flip-flop, i.e. it changes its status
according to the result stored in the accumulator. It has 9 flags and they are
divided into 2 groups −
It is a 16-bit register, which holds the address from the start of the segment to
the memory location, where a word was most recently stored on the stack.
The flag register is a special purpose register that behaves like a flip-flop, i.e. it changes its
status according to the result stored in the accumulator.
8086 has 16-bit flag register, and there are 9 valid flag bits. The format of flag register is like
below.
The programming model of the 8086 microprocessor consists of various registers that are
crucial for data manipulation and program execution. These registers are categorized into
four main groups, each serving specific functions:
Each of these 16-bit registers can also be accessed as two 8-bit registers, e.g., AX
can be split into AH (high byte) and AL (low byte).
2. Segment Registers:
a. ES (Extra Segment): An additional data segment register.
b. CS (Code Segment): Points to the segment containing the code.
c. DS (Data Segment): Points to the segment containing data.
d. SS (Stack Segment): Points to the segment containing the stack.
These registers define the locations of code, data, and stack segments, facilitating
the segmented memory architecture of the 8086.
These pointers are critical for memory addressing and execution control.
4. Flag Register
a. The Flag Register contains status flags that reflect the outcomes of
operations. Key flags include Zero, Carry, Sign, and Overflow flags.
b. This register provides information about the state of the processor and the
outcome of operations, which is essential for decision-making in programs.
Q5) - Draw and Explain interrupt vector table (IVT) and explain/differentiate btw hardware
and software interrupts.
1. The Interrupt Vector Table (IVT) in the 8086 microprocessor is a critical structure
located at the beginning of the memory address space, ranging from 0000H to
03FFH.
2. It consists of 256 entries, each occupying 4 bytes, totaling 1 KB in size.
3. Each entry in the IVT stores the segment (CS) and offset (IP) addresses of the
corresponding Interrupt Service Routine (ISR).
4. Key points about the IVT:
a. Address Range: 0000H to 03FFH.
b. Entry Size: Each entry is 4 bytes (32 bits).
c. Total Entries: 256 interrupt pointers.
d. Structure: Each pointer comprises a CS pair that points to the ISR.
e. Dedicated Pointers:
i. Type 0 (0000H): Divide Error.
ii. Type 1 (0004H): Single Step.
iii. Type 2 (0008H): Non-Maskable Interrupt (NMI).
iv. Type 3 (000CH): Breakpoint.
v. Type 4 (0010H): Overflow.
f. Reserved Pointers: Certain pointers, like Types 5 through 31, are reserved for
future or specific use.
g. Available Pointers: Pointers from Type 32 to Type 255 are available for
user-defined interrupts.
h. Function: The IVT allows the CPU to quickly locate and execute the
appropriate ISR when an interrupt occurs, ensuring efficient interrupt
handling.
5. This organization facilitates the handling of both hardware and software interrupts by
providing a direct and structured approach to accessing interrupt service routines.
4. For example, with a segment address of 1000H and an offset of 2345H, the physical
address would be 12345H.
5. This system allows the use of efficient, byte-compatible 16-bit addresses while still
accessing a larger 1MB memory space.
6. Segmentation prevents data overriding by keeping each type of data within its
designated segment, ensuring that program instructions, stack data, and other data
do not interfere with each other.
7. This organized approach is crucial for managing the larger memory space of the
8086 compared to the 8085, which only had a 16-bit address bus for its 64KB
memory.
8. Segmentation not only makes memory management more efficient but also simplifies
it for programmers, as they work with segment and offset addresses rather than the
full 20-bit physical addresses.
Below is the one way of positioning four segments within the memory space of an
8086.
Q7) - What is advantage of memory banking in 8086 mp? justify with example
Example:
Let's consider a scenario where a 8086 MP system needs to address more than 1
MB of memory for a multimedia application. Without memory banking, the system
would be limited to the 1 MB address space provided by the 8086 architecture, which
might not be sufficient for storing large multimedia files or handling complex video
processing tasks.
By implementing memory banking, the system can divide the extended memory into
multiple banks, each containing a portion of the multimedia data. For example, one
bank could store video frames, another bank could store audio samples, and
additional banks could be allocated for buffers and intermediate processing stages.
Q9) - IMP MAM Draw & explain the Read or write operation timing diagram of 8086 in
maximum mode
Read Cycle
a. Address Latch Enable (ALE): The address is placed on the address bus (AD0-AD19)
and latched by the external latches at the beginning of T1.
b. Status Signals (SO, S1, S2): In T2, the status signals (SO=1, S1=0, S2=1) are
asserted to indicate a memory read operation.
c. Data Transceiver (DT/R): The DT/R signal goes high in T2 indicating that the data will
be read from the memory onto the data bus.
d. Memory Read Command (MRDC): The MRDC signal is asserted in T3 to initiate the
memory read operation.
e. Data Enable (DEN): The DEN signal goes high in T4 to enable the data transceivers
onto the data bus.
f. Data Read (D0-D15): The data read from memory is placed on the data bus
(D0-D15) in T4 and can be retrieved by the processor.
Unlike a write cycle, the DT/R signal is high during a read cycle to indicate the direction of
the data flow.
Write cycle
a. Address Latch Enable (ALE): The address is placed on the address bus (AD0-AD19)
and latched by the external latches at the beginning of T1.
b. Status Signals (SO, S1, S2): In T2, the status signals (SO=0, S1=1, S2=1) are
asserted to indicate a memory write operation.
c. Data Transceiver (DT/R): The DT/R signal goes low in T2 indicating that the data will
be placed on the data bus from the processor.
d. Memory Write Control (MWTC): The MWTC signal is asserted in T3 to initiate the
memory write operation.
e. Data Enable (DEN): The DEN signal goes high in T4 to enable the data transceivers
onto the data bus.
f. Data Write (D0-D15): The actual data to be written is placed on the data bus
(D0-D15) in T4.
Q10) - IMP Draw & explain the Read or write operation timing diagram of 8086 in minimum
mode
1. Address Latch Enable (ALE): A pulse is generated on the Address Latch Enable
(ALE) line at the beginning of T1. This pulse instructs external latches to capture the
valid address from the address bus (AD0-AD19).
2. Memory/IO (M/IO): The M/IO signal remains low during T1 to T4 indicating a memory
operation is in progress.
3. Data Transfer/Receive (DT/R): The DT/R signal goes low in T2 signifying the
processor is ready to receive data.
4. Data Enable (DEN): The DEN signal goes low in T2 as well to enable the data
transceivers onto the data bus.
5. Read (RD): The Read (RD) signal is asserted low in T2 to initiate the memory read
operation.
6. Data Available (READY): The memory or I/O device asserts the READY signal high
in T3 to indicate the data is valid and ready to be placed on the data bus.
7. Data Read (D0-D15): The data from memory is placed on the data bus (D0-D15) in
T3 and can be retrieved by the processor.
In essence, the 8086 microprocessor in minimum mode initiates a read cycle by placing the
address on the bus and asserting the ALE signal. It then waits for the memory to indicate it
has the data ready (READY signal) before reading it from the data bus.
Write cycle
1. Addressing modes in the microprocessor define how operands are accessed for
instructions.
2. Addressing modes of 8086 are as follow:
OR
1. MOV AX, [BX+SI] (Based Indexed Addressing): Effective address is calculated by
adding BX and SI registers; operand accessed and stored in AX.
2. AND CL, [2000] (Direct Addressing): Operand accessed directly from memory
address 2000h and ANDed with CL register.
3. IN AL, DX (I/O Addressing): Reads input from port specified in DX and stores in AL
register.
5. ADD AX, [BX+SI+5] (Based Indexed Addressing with Displacement): Adds value at
memory location obtained by adding BX, SI, and 5 to AX register.
Example
MOV BX, OFFSET table
MOV AL, 2
XLAT ; AL = table[2]
Example
MOV AL, 90 ; AL = 90 (BCD)
ADD AL, 25 ; AL = BCD addition
DAA ; AL = 15 (BCD corrected)
Example
MOV AL, 5
MOV DI, 1000h
STOSB ; [1000h] = 5, DI = 1001h or 0FFFh
Example
ADD AL, 1 ; Affect flags
LAHF ; Load flags into AH
Example
MOV SI, 2000h
LODSB ; AL = [2000h], SI = 2001h or 1FFFh
This example loads the byte at memory location 2000h into AL and updates SI.
This example compares AL with the byte at memory location 3000h and updates DI.
1. The assembler directives are special instructions used to indicate to the assembler
how a program is to be assembled and executed in a proper way.
2. These are also called as pseudo-operations which are not executable by the
processor.
3. Some commonly used assembler directives are listed below:
a. ASSUME:
i. The 8086 processor has four physical segments: DS (Data Segment),
CS (Code Segment), SS (Stack Segment), and ES (Extra Segment). It
also supports several logical segments.
ii. The ASSUME directive assigns a logical segment to a physical
segment.
iii. Example
ASSUME CS:CODE
It refers the logical segment as code
b. ALIGN:
i. This directive aligns the next variable or instruction to a specified
boundary.
ii. Example
ALIGN 4
This will force the assembler to align the next segment at an address
that is divisible by 4.
c. ORG:(originate):
This directive is used to set the starting offset address for the data or code.
Example: ORG 100H
This example sets the starting offset address to 100H.
d. EVEN:
This directive aligns the next instruction or variable to an even byte boundary.
e. PAGE:
This directive helps control the format of the listing of an assembled program.
Syntax: PAGE [LENGTH], [WIDTH]
f. .CODE:
This directive indicates the start of the code segment.
It is Shortcut for defining the code segment.
g. .DATA:
This directive indicates the start of the data segment.
Shortcut for defining the data segment.
These directives help organize code, manage memory, define constants, and control the
assembly process, making the assembly language program more structured and easier to
understand.
======================================================================
In summary, these chips help the 8086 efficiently manage input/output operations, data
transfers, and interrupt handling, improving overall system performance and responsiveness.
======================================================================
Q14) - IMP Draw block diagram and Explain DMA controller 8257
Q15) - IMP MAM Explain ICW and OCW (initial/operational command word) of 8259 PIC
In conclusion, ICW and OCW together facilitate the initialization and ongoing
operation of the 8259 PIC, ensuring effective interrupt management within the
system.
Q16) - 8255
The 8255 is a general purpose programmable IO device. It is designed to interface the CPU
with some external devices like ADC, DAC, keyboard etc. We can program the device
according to the given condition.
There are three 8-bit bi-directional IO ports. The Port-A, Port-B, and Port-C. These ports are
assigned as input or output port.
The 8255 Programmable Peripheral Interface (PPI) operates in three primary modes
to interface with peripheral devices. These modes allow for flexible data transfer and
control operations:
=====================================================================
80386
The 80386 microprocessor has several important registers that play key roles in its
operation. These registers can be categorized into the following types:
1. Data Registers
a. The 80386 has eight 32-bit general-purpose data registers named EAX, EBX,
ECX, EDX, ESI, EDI, EBP, and ESP.
b. These registers are used for general arithmetic and data manipulation
operations.
2. Pointer and Index Registers
a. EIP (Instruction Pointer): This 32-bit register holds the offset address of the
next instruction to be executed.
b. ESP (Stack Pointer): It points to the top of the stack.
c. EBP (Base Pointer): It is used to reference parameters and local variables on
the stack.
3. Segment Registers
a. CS (Code Segment): Points to the segment where the instruction resides.
b. DS (Data Segment): Points to the segment where data is located.
c. SS (Stack Segment): Points to the segment of the stack.
d. ES (Extra Segment): An additional segment register for data.
4. Control Registers
a. CR0, CR2, CR3: These are control registers used for controlling and
managing the operation of the processor.
5. Status Registers
a. EFLAGS: This register contains status flags that indicate the result of
arithmetic and logical operations.
6. Debug Registers
a. DR0-DR7: These registers are used for debugging purposes.
3. Among these 32 bits, D31 to D18, D15, D5 and D3 are reserved by Intel and D1 is
always 1.
4. Flags are imp because they are the conditions for conditional branching instructions.
5. These flags can be grouped into status flags, control flags, and system flags.
A. Status Flags
a. Carry Flag (CF): This flag is set if carry is produced by the most significant bit
during the execution of an arithmetic operation. In subtraction carry serves as
a borrow flag.
b. Parity Flag (PF): This flag is set to 1, if the result stored in the accumulator
contains even parity i.e. even number of 1’s. If accumulator contains odd
number of 1’s the flag is 0
c. Auxiliary Carry Flag (AF): In an arithmetic operation when carry is generated
from bit D3 to D4, the auxiliary carry flag is set to 1. This flag is only available
internally and used for BCD operations and not available for programmers.
d. Zero Flag (ZF): After performing arithmetic or logic operation, if the result is
zero, then zero flag is set to 1, else it is reset.
e. Sign Flag (SF):After execution of arithmetic and logic operation if the most
significant bit of the result is 1, then the sign flag is set to 1 otherwise 0. Ig
MSB is 1, the number will be negative and if it is 0, the number will be positive
f. Overflow Flag (OF): This flag will be set (1) if the result of a signed operation
is too large to fit in the number of bits available to represent it, otherwise reset
(0).
B. Control Flags
a. Direction Flag (DF): This flag is utilized in string instructions to determine the
direction of data access; when set (1), string data is accessed from higher
memory locations towards lower memory locations, and when reset (0), data
is accessed from lower memory locations towards higher memory locations.
b. Interrupt Enable Flag (IF): This flag governs the enabling or disabling of
maskable interrupts; when set, interrupts are enabled, permitting the
processor to respond to external interrupt requests, and when cleared,
interrupts are disabled.
c. Trap Flag (TF): Used for debugging purposes, this flag activates single-step
mode; when set, it triggers a trap after the execution of each instruction,
facilitating debugging by allowing step-by-step execution of code.
C. System Flags
a. I/O Privilege Level (IOPL): This flag register determines the privilege level
required for executing input/output (I/O) instructions. It consists of two bits
(Bits 12 and 13), allowing for four privilege levels ranging from 0 to 3, with 0
being the highest privilege level and 3 the lowest.
b. RF (Resume Flag) This is the first bit in the extended EFLAGS register. It is
used with the debug register breakpoints. At the starting of each instruction
cycle, the status of RF is always checked. If RF = 1, any debug fault will be
ignored while executing any instruction. This flag is automatically reset after
execution of instructions except IRET and POPE.
c. VM (Virtual Mode Flag) When this flag is set, the 80386 enters in the virtual
8086 mode within the protected mode. If VF is set, 80386 operates in
protected mode. When this flag is cleared or reset, the 80386 operates in real
address mode.
q4) - Virtual mode, protected mode, Real mode short note and Difference btw in 80386
Real Mode:
Protected Mode:
1. Virtual mode is a unique feature of the 80386 processor that enables it to emulate
multiple virtual 8086 environments simultaneously.
2. In this mode, the processor can create and manage multiple virtual machines, each
running its own instance of the 8086 instruction set architecture.
3. These virtual machines operate independently of each other, with their own virtual
memory space and system resources.
MAM
1. Limit Check
The limit check ensures that any memory access stays within the bounds defined by
the segment descriptor.
This is crucial to prevent processes from accessing memory regions outside their
allocated space, which could lead to system instability or security breaches.
2. Type Check
The type check ensures that the type of memory access (data, code, or stack
segment) matches the permissions defined for that segment.
a. Type of Segment:
i. Data Segment: Can be read or written.
ii. Code Segment: Can be executed.
iii. Stack Segment: Used for stack operations.
b. Operations Checked:
i. Read and Write permissions.
ii. Executable permissions.
3. Privilege Check
The privilege check enforces a hierarchy of access levels, ensuring that higher
privilege levels have broader access to system resources, while lower levels are
more restricted.
PL 1: System services
PL 2: Custom extensions
Uses:
1. The Pentium 4 NetBurst microarchitecture was designed by Intel to achieve very high
clock speeds, allowing processors to perform tasks faster.
2. One of its key features was its deep instruction pipeline, which had up to 31 stages.
3. This meant that instructions went through many steps before they were fully
processed. This allowed the processor to handle more instructions at higher speeds.
4. Another significant feature of NetBurst was Hyper-Threading technology.
a. This innovation enabled a single processor to handle multiple threads, or
sequences of instructions, simultaneously.
b. As a result, the processor could perform multiple tasks at the same time,
improving multitasking and the performance of applications.
5. NetBurst was also optimized for high clock speeds, meaning the processor could
complete many cycles per second, which theoretically increased performance.
6. This high clock speed was complemented by the Rapid Execution Engine, which
allowed the processor to execute certain types of instructions twice per clock cycle,
further enhancing performance.
7. To manage these high speeds, NetBurst included advanced branch prediction
capabilities, which helped the processor make better guesses about which
instructions to execute next. This reduced the delays caused by incorrect guesses,
known as branch mispredictions, and kept the pipeline flowing smoothly.
8. Thus NetBurst played a crucial role in advancing processor technology and laid the
groundwork for future innovations in Intel's processor lineup.
1. The MESI protocol, commonly used in cache coherency mechanisms, stands for
Modified, Exclusive, Shared, and Invalid.
2. When one processor modifies data stored in its cache, other processors accessing
the same data need to be aware of this modification to prevent data inconsistency.
Cache coherence protocols, like MESI (Modified, Exclusive, Shared, Invalid),
maintain data consistency by coordinating cache accesses and updates across
multiple processors.
3. In Pentium microprocessors, including those using the NetBurst architecture, the
MESI protocol helps maintain data consistency between caches in a multiprocessor
system.
4. The protocol operates through four main states:
a. Modified (M): Indicates that the cache line is present in the current cache and
has been modified, reflecting a difference from the main memory. This state
holds the most recent data version.
b. Exclusive (E): Denotes that the cache line exists only in the current cache and
matches the data in main memory. It hasn't been modified, setting it apart
from the Modified state.
c. Shared (S): Represents a cache line present in multiple caches, all containing
identical data as stored in main memory. This state facilitates efficient data
sharing among multiple processors.
d. Invalid (I): Signifies that the cache line is invalid or absent in the cache,
necessitating data retrieval from main memory
a. Any modifications made to a memory location by one processor are visible to other
processors.
b. Reads by any processor return the most recent data.
c. Data shared between multiple processors is kept consistent to prevent conflicts and
errors.
6. When a processor needs to read or write data, the protocol determines the state of the
cache line and coordinates updates to maintain data consistency across caches.
7. This optimization minimizes unnecessary data transfers between caches and main
memory, enhancing overall system performance.
8. This optimization reduces unnecessary data transfers between caches and main
memory, thereby enhancing overall system performance.
The Internal Architecture of Pentium Processor has been designed based on Superscalar. In
Superscalar architecture, two instructions are executed in parallel. Figure 12.2 shows the
superscalar architecture. Two independent integer pipelines are depicted in Fig. 12.2. In the
PF and D1 stages, the microprocessor can fetch instructions, decode instructions and
generate control words. In this stage, decoded instructions issue them to two parallel U and
V pipelines. For complex instructions, D1 generates microcoded sequences for U and V
pipelines. Several techniques are used to resolve the pairing of instructions.
Q7) - Integer Pipelines U and V
The Pentium processor's architecture allowed for parallel execution of integer and
floating-point instructions, improving overall performance. This parallelism enabled
the processor to execute multiple instructions simultaneously, increasing throughput
and efficiency. By dedicating separate pipelines to integer and floating-point
operations, the Pentium processor could handle a wide range of computational tasks
efficiently, making it well-suited for both general-purpose computing and scientific
applications requiring high-performance floating-point arithmetic.