Microprocesser Assignment
Microprocesser Assignment
Microprocesser Assignment
As shown in the below figure, the 8086 CPU is divided into two independent
functional parts
It provides the interface of 8086 to external memory and I/O devices via the
System Bus. It performs various machine cycles such as memory read, I/O
read, etc. to transfer data between memory and I/O devices.
BIU performs the following functions are as follows:
• It generates the 20-bit physical address for memory access.
• It fetches instructions from the memory.
• It transfers data to and from the memory and I/O.
• Maintains the 6-byte pre-fetch instruction queue(supports
pipelining).
BIU mainly contains the 4 Segment registers, the Instruction Pointer, a pre-
fetch queue, and an Address Generation Circuit.
Instruction Pointer (IP):
• It is a 16-bit register. It holds offset of the next instructions in
the Code Segment.
• IP is incremented after every instruction byte is fetched.
• IP gets a new value whenever a branch instruction occurs.
• CS is multiplied by 10H to give the 20-bit physical address of the
Code Segment.
• The address of the next instruction is calculated by using the
formula CS x 10H + IP.
Example:
CS = 4321H IP = 1000H
then CS x 10H = 43210H + offset = 44210H
Here Offset = Instruction Pointer(IP)
This is the address of the next instruction.
Code Segment register: (16 Bit register): CS holds the base address for
the Code Segment. All programs are stored in the Code Segment and
accessed via the IP.
Data Segment register: (16 Bit register): DS holds the base address for the
Data Segment.
Stack Segment register: (16 Bit register): SS holds the base address for
the Stack Segment.
Extra Segment register: (16 Bit register): ES holds the base address for
the Extra Segment.
Address Generation Circuit:
• The BIU has a Physical Address Generation Circuit.
• It generates the 20-bit physical address using Segment and Offset
addresses using the formula:
• In Bus Interface Unit (BIU) the circuit shown by the Σ symbol is
responsible for the calculation unit which is used to calculate the
physical address of an instruction in memory.
Physical Address = Segment Address x 10H + Offset Address
Arithmetic Logic Unit (16-bit): Performs 8 and 16-bit arithmetic and logic
operations.
Special purpose registers (16-bit): Special purpose registers are called
Offset registers also. Which points to specific memory locations under each
segment.
We can understand the concept of segments as Textbook pages. Suppose
there are 10 chapters in one textbook and each chapter takes exactly 100
pages. So, the book will contain 1000 pages. Now suppose we want to
access page number 575 from the book then 500 will be the segment base
address which can be anything in the context of microprocessors like Code,
Data, Stack, and Extra Segment. So, 500 will be segment registers that are
present in Bus Interface Unit (BIU). And 500 + 75 is called an offset register
through which we can reach on specific page number under a specific
segment.
Hence 500 is the segment base address and 75 is an offset address or
(Instruction Pointer, Stack Pointer, Base Pointer, Source Index, Destination
Index) any of the above according to their segment implementation.
• Stack Pointer: Points to Stack top. Stack is in Stack Segment, used
during instructions like PUSH, POP, CALL, RET etc.
• Base Pointer: BP can hold the offset addresses of any location in
the stack segment. It is used to access random locations of the stack.
• Source Index: It holds offset address in Data Segment during
string operations.
• Destination Index: It holds offset address in Extra Segment during
string operations.
Instruction Register and Instruction Decoder:
The EU fetches an opcode from the queue into the instruction register. The
instruction decoder decodes it and sends the information to the control circuit
for execution.
Flag/Status register (16 bits): It has 9 flags that help change or recognize
the state of the microprocessor.
6 Status flags:
1. Carry flag(CF)
2. Parity flag(PF)
3. Auxiliary carry flag(AF)
4. Zero flag(Z)
5. Sign flag(S)
6. Overflow flag (O)
Status flags are updated after every arithmetic and logic operation.
3 Control flags:
1. Trap flag(TF)
2. Interrupt flag(IF)
3. Direction flag(DF)
These flags can be set or reset using control instructions like CLC, STC, CLD,
STD, CLI, STI, etc. The Control flags are used to control certain operations.
Q. Memory segmentation in 8086.
Ans- Segmentation is the process in which the main memory of the
computer is logically divided into different segments and each segment has
its own base address. It is basically used to enhance the speed of execution
of the computer system, so that the processor is able to fetch and execute
the data from the memory easily and fast.
Need for Segmentation –
The Bus Interface Unit (BIU) contains four 16-bit special purpose registers
(mentioned below) called as Segment Registers.
• Code segment register (CS): is used for addressing memory
location in the code segment of the memory, where the executable
program is stored.
• Data segment register (DS): points to the data segment of the
memory where the data is stored.
• Extra Segment Register (ES): also refers to a segment in the
memory which is another data segment in the memory.
• Stack Segment Register (SS): is used for addressing stack
segment of the memory. The stack segment is that segment of
memory which is used to store stack data.
The number of address lines in 8086 is 20, 8086 BIU will send 20bit address,
to access one of the 1MB memory locations. The four segment registers
contain the upper 16 bits of the starting addresses of the four memory
segments of 64 KB each with which the 8086 is working at that instant of
time. A segment is a logical unit of memory that may be up to 64 kilobytes
long. Each segment is made up of contiguous memory locations. It is an
independent, separately addressable unit. Starting address will always be
changing. It will not be fixed.
Note that the 8086 does not work the whole 1MB memory at any given time.
However, it works only with four 64KB segments within the whole 1MB
memory.
Below is the one way of positioning four 64 kilobyte segments within the 1M
byte memory space of an 8086.
Types Of Segmentation –
0 0 0 Interrupt acknowledge
0 1 1 Halt
1 0 0 Code access
1 0 1 Read memory
1 1 0 Write memory
1 1 1 Passive state
0 0 No operation
M/IO’: This signal is used to distinguish between memory and I/O operations.
The M Signal is Active high whereas the IO’ Signal is Active Low. When this
Pin is High, the memory operations take place. On the other hand, when the
Pin is low, the Input/Output operations from the peripheral devices takes
place.
=DT/R : Data Transmit/Receive. This pin is required in minimum systems, that
want to use an 8286 or 8287 data bus transceiver. The direction of data flow
is controlled through the transceiver.
DEN: Data enable. This pin is provided as an output enable for the
8286/8287 in a minimum system which uses transceiver. DEN is active low(0)
during each memory and input-output access and for INTA cycles.
HOLD/HOLDA: HOLD indicates that another master has been requesting a
local bus .This is an active high(1). The microprocessor receiving the HOLD
request will issue HLDA (high) as an acknowledgement in the middle of a T4
or T1 clock cycle.
ALE : Address Latch Enable. ALE is provided by the microprocessor to latch
the address into the 8282 or 8283 address latches. It is an active high(1)
pulse during T1 of any bus cycle. ALE signal is never floated, is always
integer.
• Control signals for all operations are generated by decoding S’2, S’1 and
S’0 using 8288 bus controllers.
• Bus request is done using RQ’ / GT’ lines interfaced with 8086.
RQ0/GT0 has more priority than RQ1/GT1.
• INTA’ is given by 8288, in response to an interrupt on INTR line of 8086.
• In max mode, the advanced write signals get enabled one T-state in
advance as compared to normal write signals. This gives slower devices
more time to get ready to accept the data, therefore it reduces the
number of cycles.
Q. What is Pipelining in 8086.
Ans- Pipelining is the reason processors are so fast. There was a time when
processors took hours to do a simple calculation and now the same
calculations can be done in seconds. Pipelining is the feature of fetching the
next instruction while executing the current instruction.
Advantages:
3. Saves time.