Chapter 2 8086 Architecture and System Organization
Chapter 2 8086 Architecture and System Organization
To improve the performance by implementing the parallel processing concept the CPU of the 8086 /8088
is divided into two independent sections.
They are
1. Bus Interface Unit (BIU) and
2. Execution Unit.(EI).
The BIU sends out addresses ,fetches instructions ,read data from ports and memory and writes data to
ports and memory.i.e the BIU handles all transfers data and addresses on the buses required by the
execution Unit . Whereas the Execution Unit decodes the instructions and executes the instructions.
The Execution Unit : The Execution Unit consists of a control system , a 16-bit ALU, 16-bit Flag
register and four general purpose registers(AX,BX,CX,DX), pointer registers (SP,BP) and Index
registers(SI,DI) of each 16-bits . The control circuitry controls the internal operations .The decoder in the
execution unit decodes the instructions fetched from the memory into a series of actions. The ALU can
add ,subtract, perform operations like logical AND,OR,XOR, increment, decrement, complement ,and
shifting the binary numbers.
Bus Interface Unit : The BIU consists of a 6-byte long instruction register called Queue. And four stack
segment registers (ES,CS,SS,DS) , one Instruction Pointer(IP) and an adder circuit to calculate the 20bit
physical address of a location. This bus interface unit will perform all the external bus operations. They
are fetching the instructions from the memory, read/write data from/into memory or port and also
supporting the instruction Queue etc. The BIU fetches up to six instruction bytes from the memory and
stores these pre-fetched bytes in a first –in first out register set called Queue. When the execution unit is
ready for the execution of the instruction ,instead of fetching the byte from the memory ,it reads the byte
from the Queue .This will increase the overall speed of microprocessor .Fetching the next instruction
while the current instruction executes is called pipelining or parallel processing.
1 Prepared by Tsegaye A.
Fig.2.1 Architecture of 8086 Microprocessor
The 8086 processor provides a 20-bit address to access any location of the 1 MB memory space. The
memory is organized as a linear array of 1 million bytes, addressed as 00000(H) to FFFFF(H). The
memory is logically divided into code, data, extra data, and stack segments of up to 64K bytes each.
Physically, the memory is organized as a high bank (D15 - D8) and a low bank (D7 –D0) of 512 K 8-
bitbytes addressed in parallel by the processor's address lines A19 -A1. Byte data with even addresses is
transferred on the D7 – D0 bus lines while odd addressed byte data (A0 HIGH) is transferred on the
D15-D8 bus lines. The processor provides two enable signals, BHE and A0 , to selectively allow reading
from or writing into either an odd byte location, even byte location, or both. The instruction stream is
fetched from memory as words and is addressed internally by the processor to the byte level as necessary.
2 Prepared by Tsegaye A.
There are four 16-bit segment registers namely code segment register(CS),Stack segment
register(SS),Data segment register(DS) and Extra segment register(ES).The code segment register is
used for addressing the 64kB memory location in the code segment of the memory ,where the code of
the executable program is stored. Similarly the DS register points to the data segment of the 64kB
memory where the data is stored. The Extra segment register also refers to essentially another data
segment of the memory space. The SS register is useful for addressing stack segment of memory. So, the
CS,DS,SS and ES segment registers respectively contains the segment addresses for the code, data, stack
and extra segments of the memory.
It is a 16-bit register which always points to the next instruction to be executed within the currently
executing code segment. So, this register contains the 16-bit offset address pointing to the next
instruction code within the 64kB of the code segment area. Its content is automatically incremented as
the execution of the next instruction takes place.
This register is also called status register. It is a 16 bit register which contains six status flags and three
control flags. So, only nine bits of the 16 bit register are defined and the remaining seven bits are
undefined. Normally this status flag bits indicate the status of the ALU after the arithmetic or logical
operations. Each bit of the status register is a flip/flop. The Flag register contains Carry flag, Parity flag,
Auxiliary flag Zero flag, Sign flag ,Trap flag, Interrupt flag, Direction flag and overflow flag as shown in
the diagram. The CF,PF,AF,ZF,SF,OF are the status flags and the TF,IF and CF are the control flags.
Flag Register
CF- Carry Flag: This flag is set, when there is a carry out of MSB in case of addition or a borrow in case
of subtraction.
PF - Parity Flag : This flag is set to 1, if the lower byte of the result contains even number of 1’s else (for
odd number of 1s ) set to zero.
AF - Auxilary Carry Flag: This is set, if there is a carry from the lowest nibble, i.e, bit three during
addition, or borrow for the lowest nibble, i.e, bit three, during subtraction.
3 Prepared by Tsegaye A.
ZF- Zero Flag: This flag is set, if the result of the computation or comparison performed by the
previous instruction is zero.
SF- Sign Flag : This flag is set, when the result of any computation is negative
TF - Tarp Flag: If this flag is set, the processor enters the single step execution mode.
IF- Interrupt Flag: If this flag is set, the maskable interrupt INTR of 8086 is enabled and if it is
zero ,the interrupt is disabled.It can be set by using the STI instruction and can be cleared by executing
CLI instruction.
DF- Direction Flag: This is used by string manipulation instructions. If this flag bit is ‘0’, the string is
processed beginning from the lowest address to the highest address, i.e., auto incrementing mode.
Otherwise, the string is processed from the highest address towards the lowest address, i.e., auto
incrementing mode.
OF- Over flow Flag: This flag is set, if an overflow occurs, i.e, if the result of a signed operation is
large enough to accommodate in a destination register. The result is of more than 7-bits in size in case of
8-bit signed operation and more than 15-bits in size in case of 16-bit sign operations, then the overflow
will be set.
CPU Memory
Interconnect
In VNA machines, like the 80x 86 families, the CPU is where all the action takes place. All
computations occur inside the CPU. Data and CPU instructions reside in memory until
required by the CPU. To the CPU, most I/O devices look like memory because the CPU can store data to
an output device and read data from an input device. The major difference between memory and I/O
4 Prepared by Tsegaye A.
locations is the fact that I/O locations are generally associated with external devices in the
outside world.
The system bus is the communication medium for data transfers. Such data transfers are called the bus
transactions. Some examples of bus transactions are memory read, memory write, I/O read, I/O write,
and interrupt. Depending on the processor and the type of bus used, there may be other types of
transactions. Every bus transaction involves a master and a slave. The master is the initiator of the
transaction and the slave is the target of the transaction. For example, when the processor wants to read
data from the memory, it initiates a bus transaction, also called a bus cycle, in which the processor is the
bus master and memory is the slave. The processor usually acts as the master of the system bus, while
components like memory are usually slaves.
The data bus on an 80x86 family processor transfers information between a particular memory location
or I/O device and the CPU. The only question is, “Which memory location or I/O device?” The address
5 Prepared by Tsegaye A.
bus answers that question. To differentiate memory locations and I/O devices, the system designer
assigns a unique memory address to each memory element and I/O device. When the software
wants to access some particular memory location or I/O device, it places the corresponding
address on the address bus. Circuitry associated with the memory or I/O device recognizes this address
and instructs the memory or I/O device to read the data from or place data on the data bus. In either case,
all other memory locations ignore the request. Only the device whose address matches the value on the
address bus responds. With a single address line, a processor could create exactly two unique addresses:
zero and one. With n address lines, the processor can provide 2 n unique addresses (since there are 2 n
unique values in an n-bit binary number). Therefore, the number of bits on the address bus
will determine the maximum number of addressable memory and I/O locations. The 8088 and 8086,
for example, have 20 bit address busses. Therefore, they can access up to 1,048,576 (or 220)
memory locations.
For example, the 8086 processor has a 20-bit address bus and a 16-bit data bus. The amount of physical
memory that this processor can address is 220 bytes and each data transfer involves 16 bits.
The read and write control lines control the direction of data on the data bus. When both contain a
logic one, the CPU and memory-I/O are not communicating with one another. If the read
line is low (logic zero), the CPU is reading data from memory (that is, the system is transferring data
from memory to the CPU). If the write line is low, the system transfers data from the CPU to memory.
6 Prepared by Tsegaye A.
2. Decode the instruction (i.e., identify the instruction);
3. Execute the instruction (i.e., perform the action specified by the instruction).
The system clock defines the speed at which the system operates. All processor operations take multiple
clock cycles. For example, transfer of data from a memory location to Pentium takes three clock cycles.
Thus, the higher the clock rate, the faster the system can work. The clock period is defined as the length
of time taken by one clock cycle.
Time
Fig 2.3 the system clock
2.8 Number of Address
One of the characteristics that shape the architecture of a processor is the number of addresses used in
its instructions. Most processors use either two or three addresses. For example, the MIPS processor uses
three addresses whereas the Pentium uses two addresses. However, it is possible to design systems with
one or even zero address.
Instruction Semantics
add dest,src1,src2 Adds the two values at src1and src2and stores
the result in dest
7 Prepared by Tsegaye A.
mult dest,src1,src2 Multiplies the two values at src1 and src2
and stores the result in dest
Instruction Semantics
Mov dest,src Copies the value at src to dest
add dest,src Adds the two values at src and dest and stores
the result in dest
mult dest,src Multiplies the two values at src and dest and
stores the result in dest
8 Prepared by Tsegaye A.
These registers can be used either as 16- or 32-bit registers. The two index registers play a special role in
string processing instructions. In addition, they can be used as general-purpose data registers.
The pointer registers are mainly used to maintain the stack. Even though they can be used
as general-purpose data registers, they are almost exclusively used for maintaining the stack.
9 Prepared by Tsegaye A.
Fig 2.4 Deletion of data items from the stack: The arrow points to the top-of-stack.
• Only words (i.e., 16-bit data) or double words (i.e., 32-bit data) are saved on the stack, never a single
byte.
• The stack grows toward lower memory addresses. Since we graphically represent memory with
addresses increasing from the bottom of a page to the top, we say that the stack grows “downward.”
• Top-of-stack (TOS) always points to the last data item placed on the stack. TOS always points to the
lower byte of the last word inserted into the stack.
When the stack is initialized, TOS points to the byte just outside the reserved stack area. It is an error to
read from an empty stack, as this causes stack underflow.
When a word is pushed onto the stack, ESP is first decremented by two, and then the word is stored at
SS:ESP. Since the Pentium uses little-endian byte order, the higher-order byte is stored in the higher
memory address. For instance, when we push 21ABH, the stack expands by two bytes, and ESP is
decremented by two to point to the last data item.
The stack full condition is indicated by the zero offset value (i.e., ESP = 0). If we try to insert a data item
into a full stack, stack overflow occurs. Both stack underflow and overflow are programming errors and
should be handled with care. Retrieving a 32-bit data item from the stack causes the offset value to
increase by four to point to the next data item on the stack.
10 Prepared by Tsegaye A.
The Pentium instruction set has several instructions to support stack operations. These include the basic
instructions like push and pop that operate on single registers. In addition, separate instructions are
provided to push and pop the flags register as well as the complete register set.
Basic Instructions
The Pentium allows the push and pop operations on word or doubleword data items.
The syntax is
push source
pop destination
The operand of these two instructions can be a 16- or 32-bit general-purpose register, segment register,
or a word or doubleword in memory. In addition, source for the push instruction can be an immediate
operand of size 8, 16, or 32 bits.
11 Prepared by Tsegaye A.
What if we need to preserve the contents of the EAX and EBX registers? In this case, we need to save
and restore these registers as shown below:
;save EAX and EBX registers on the stack
push EAX
push EBX
;EAX and EBX registers can now be used
mov EAX,value1
mov EBX,value2
mov value1,EBX
mov value2,EAX
;restore EAX and EBX registers from the stack
pop EBX
pop EAX
This code requires eight memory accesses. Because the stack is a LIFO data structure, the sequence of
pop instructions is a mirror image of the push instruction sequence.
12 Prepared by Tsegaye A.