Unit 2 8086 MP Part 1
Unit 2 8086 MP Part 1
16-bit Microprocessors
Why Transition :- Transition
S.No. 8085 Microprocessor 8086 Microprocessor
1. 8085 has 16 address line with 8 to 20 address with 16 to these lines also
these line also being used for data being used for data
2. 8 bit accumulator & six 8 bit All register 16 bit wide
general purpose register which
can be combined to form 16 bit
register for addressing
3. A program counter & stack 5 pointer register
pointer
4. Address 64 KB of memory 16 segments each with a length of 64 K
these memory segments are addressed
through four segment register
- Code Segment
- Stack Segment
- Data Segment
- Extra Segment
5. Single processing capability Multiprocessing capability
6. Only 256 instructions 64 K or 65536 instructions more than one
opcode can be used for the same
instruction
8086 Registers and Internal Architecture
• There are two main functional logic
blocks in the 8086/88 processors:
– EU Execution Unit - execution of program
instructions
– BIU Bus Interface Unit - provides interface
to memory and I/O
1. controls the address, data, and control busses.
2. handles instruction fetch and data read/write
functions
Bus Interface Unit
• BIU is the 8086’s interface to the outside world.
• It is responsible for performing all external bus
operations.
• BIU contains the segment registers, Instruction
pointer and bus control logic
• BIU has a mechanism called Instruction Stream
Queue to implement a Pipeline Architecture that
permits pre-fetch of up to 6 bytes of code.
Control Unit
• Responsible for decoding and executing all
instructions
• Generates operand addresses
• Requests BIU to perform RD or WR cycles
to Memory or I/O
• After execution the EU tests and updates
the status flags
• Handles Jumps
Execution Unit – Multipurpose Registers
• EAX Accumulator: AX is good at collecting the results of arithmetic and logic
operations. It is very strongly tied to the ALU (arithmetic and logic unit) and
can serve as the source and destination of instructions that use the ALU Thus when
you operate on a program variable over and over,AX can be used to hold the variable
during the long chain of instructions being executed and accumulate the end
result. So AX is called the accumulator.
C-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. For example, when two
numbers are added, a carry may be generated out of the most significant bit
position. The carry flag, in this case, will be set to ‘1’, In case, no carry is
generated, it will be ‘0’.
• Parity Flag (PF) - this flag is set to 1 when there is even number of one bits in
result, and to 0 when there is odd number of one bits.
• AC-Auxiliary 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.
Execution Unit – Flag Register
• Z Zero: Zero Flag (ZF) - set to 1 when result is zero. For non-zero result this
flag is set to 0.
• Sign Flag (SF) - set to 1 when result is negative. When result is positive
it is set to 0. (This flag takes the value of the most significant bit.)
• T Trap: If this flag is set, the processor enters the single step
execution mode. In other words, a trap interrupt is generated
after execution of each instruction. The processor executes the
current instruction and the control is transferred to the Trap
interrupt service routine.
• Interrupt enable Flag (IF) - when this flag is set to 1 CPU reacts to
interrupts from external devices.
•D-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
decrementing mode.
O-Overflow Flag
This flag is set, if an overflow occurs, i.e. if the result of a signed operation is large
enough to be accommodated in a destination register. For example, in case of the
addition of two signed numbers, if the result overflows into the sign bit, i.e. the
result is of more than 7 -bits in size in case of 8-bit signed operations and more
than I5-bits in size in case of I6-bit signed operations, then the overflow flag will
be set.
BIS – Segment Registers
• CS Code Segment: Used to compute the starting address of the
section of memory holding code (restricted to 64K in REAL mode).
• DS Data Segment: Used to compute the starting address of the
section of memory holding data (restricted to 64K in REAL mode).
• SS Stack Segment: Used to compute the starting address of the
section of memory holding the stack (restricted to 64K in REAL
mode).
• ES Extra Segment: Additional data segment used by some string
instructions.
• FS&GS Additional segment registers in the 80386 (and up) for
program use.
Segmented Memory:-
Two types of memory organization are in popular use.
These are linear addressing & segmented addressing.
EA (Effective Address)
20-bit (5-byte) 64 KB +
Physical Segment
16-bit
Memory address
Appended byte 0H
Warning: A very common mistake people make when performing this computation is to
forget they are working in hexadecimal, not decimal. It is surprising to see how many
people add 9+1 and get 10h rather than the correct answer 0Ah.
8086 Generating Physical
Addresses
CS
Memory System ES
Address Lines
SS
DS
19 0
Physical Address Dedicated Segment Registers
ADD BP
15 0 15 0
DI
Index Reg. Segment Reg. 0000
SI
SP
IP
Portion of BIU Circuitry
Dedicated Index Registers
In the 8086 chip architecture, the addressable memory space is divided into segments,
each of which can contain up to 64K of memory. Segments can only start on a
paragraph address. A paragraph address is a byte location that is evenly divisible by
16 bytes. Every 16th byte in memory contains segment number n. To access specific
bytes or words in memory, you must use an offset relative to the beginning of a
specified segment.
Together, a segment and an offset provide a segmented address that can locate any
byte in the 1 megabyte of address space in the 8086 processor.
CS
ES
physical address memory
SS
00000h
DS
paragraph 1
00010h
paragraph 2
00020h
paragraph 3 BP
DI
SI
SP
IP
offset
072CH 18H AD5FCH
or • Segment Address = ACEDH
072BH A3H AD5FBH
logical • Logical Address = 0724H
072AH 7EH AD5FAH
address 0729H 69H AD5F9H • Physical Address
0728H AAH AD5F8H = ACED0H + 0724H
0727H 2EH AD5F7H = AD5F4H
0726H 00H AD5F6H • M[ACED:0724]
0725H 55H AD5F5H = M[AD5F4] (word read)
0724H 02H AD5F4H = 5502H
0723H 72H AD5F3H
increasing 0722H 11H AD5F2H
0724H 0725H
0H 2H 5H 5H hex
0000 0010 0101 0101 binary
Register Transfer Language
Byte Read:
offset al M[0724h]
072CH 18H AD5FCH
or after: al = 02h
072BH A3H AD5FBH
logical
072AH 7EH AD5FAH
address 0729H 69H AD5F9H Word Read:
0728H AAH AD5F8H ax M[0724h]
0727H 2EH AD5F7H
after: ax = 5502h
0726H 00H AD5F6H
before: after:
072CH 18H AD5FCH
072CH 18H AD5FCH
072BH A3H AD5FBH 072BH A3H AD5FBH
072AH 7EH AD5FAH
072AH 7EH AD5FAH
0729H 69H AD5F9H
0729H 69H AD5F9H
0728H AAH AD5F8H 0728H AAH AD5F8H
0727H 2EH AD5F7H
0727H 2EH AD5F7H
0726H 00H AD5F6H
0726H 00H AD5F6H
0725H 55H AD5F5H 0725H 55H AD5F5H
0724H 7BH AD5F4H
0724H 02H AD5F4H
0723H 72H AD5F3H
0723H 72H AD5F3H
0722H 11H AD5F2H 0722H 11H AD5F2H
Memory Write Operations
(cont.)
Assume EAX = FAC4237B h
Word Write: M[0724h] ax
before: after:
072CH 18H AD5FCH
072CH 18H AD5FCH
072BH A3H AD5FBH 072BH A3H AD5FBH
072AH 7EH AD5FAH
072AH 7EH AD5FAH
0729H 69H AD5F9H
0729H 69H AD5F9H
0728H AAH AD5F8H 0728H AAH AD5F8H
0727H 2EH AD5F7H
0727H 2EH AD5F7H
0726H 00H AD5F6H
0726H 00H AD5F6H
0725H 55H AD5F5H 0725H 23H AD5F5H
0724H 7BH AD5F4H
0724H 02H AD5F4H
0723H 72H AD5F3H
0723H 72H AD5F3H
0722H 11H AD5F2H 0722H 11H AD5F2H
Memory Write Operations
(cont.)
Assume EAX = FAC4237B h
DWord Write: M[0724h] eax
before: after:
072CH 18H AD5FCH
072CH 18H AD5FCH
072BH A3H AD5FBH 072BH A3H AD5FBH
072AH 7EH AD5FAH
072AH 7EH AD5FAH
0729H 69H AD5F9H
0729H 69H AD5F9H
0728H AAH AD5F8H 0728H AAH AD5F8H
0727H FAH AD5F7H
0727H 2EH AD5F7H
0726H C4H AD5F6H
0726H 00H AD5F6H
0725H 55H AD5F5H 0725H 23H AD5F5H
0724H 7BH AD5F4H
0724H 02H AD5F4H
0723H 72H AD5F3H
0723H 72H AD5F3H
0722H 11H AD5F2H 0722H 11H AD5F2H
Default Segment/Index Pairs
Type of Memory Reference Default Segment Base Alternate Segment Base Offset
1. A pulse one clock wide from another bus master requests the
bus access to 8086.
2. During T4 (current) or T 1 (next) clock cycle, a pulse one clock
wide from 8086 to the requesting master, indicates that the
8086 has allowed the local bus to float and that it will enter the
"hold acknowledge" state at next clock cycle. The CPU's bus
interface unit is likely to be disconnected from the local bus of
the system.
3. A one clock wide pulse from the another master indicates to
8086 that the 'hold' request is about to end and the 8086 may
regain control of the local bus at the next clock cycle.
Thus each master to master exchange of the local bus is a
sequence of 3 pulses. There must be at least one dead
clock cycle after each bus exchange. The request and grant
pulses are active low. For the bus requests those are
received while 8086 is performing memory or I/O cycle, the
granting of the bus is governed by the rules as discussed in
case of HOLD, and HLDA in minimum mode.
8086 Addressing Modes
• Microprocessor needs
memory address to
access data from the
memory.
• Assembly language
may use several
addressing modes to
accomplish this task.
8086 Register Addressing Modes
Most 8086 instructions can operate on the 8086's general
purpose register set. By specifying the name of the register as
an operand to the instruction, you may access the contents of
that register. Consider the 8086 mov (move) instruction:
mov destination, source
This instruction copies the data from the source operand to the
destination operand. The eight and 16 bit registers are
certainly valid operands for this instruction. The only restriction
is that both operands must be the same size. Now let's look at
some actual 8086 mov instructions:
mov ax, bx ;Copies the value from BX into AX
mov dl, al ;Copies the value from AL into DL
Remember, the registers are the best place to keep often used
variables.
Mov makes a copy of Source and stores this value into Dest.
This instruction does not affect the original contents of Source.
It overwrites the previous value in Dest.
• The P has a set of rules that apply whenever memory is addressed,
which define the segment and offset register combination used by
certain addressing modes[By Default].
Addressing Modes
1 Direct (absolute) memory addressing
– Instruction specifies the address of the data
– The data address (in the instruction) can be the full
physical address on the memory architecture in use
Addressing Modes
2 Register addressing
– When operands are held in the registers, e.g. MOV A, B
– Register addressing instructions are the fastest and use
the fewest bits compared to others
– Some call it inherent addressing also
3 Immediate addressing
– Used for constant values know when the program is written
– Data (i.e. constant values) can immediately follow the instruction
4.The Register Indirect Addressing Modes
• Register indirect addressing– Also called pointer register addressing
– Instruction contains address of the register that contains the address of the
needed data
– A 2-level addressing mode
There are four forms of this addressing mode on the 8086, best demonstrated
by the following instructions:
mov al, [bx]
mov al, [bp]
mov al, [si]
mov al, [di]
You can use the segment override prefix symbols if you wish to access data in
different segments. The following instructions demonstrate the use of these
overrides:
mov al, cs:[bx]
mov al, ds:[bp]
mov al, ss:[si]
mov al, es:[di]
5 Indexed addressing
– Finds a memory location based on an index
– Instruction contains the starting address of the array,the index
register contains the offset to reach the data being addressed
The indexed addressing modes use the following syntax:
mov al,disp[bx]
mov al,disp[bp]
mov al,disp[si]
mov al,disp[di]
The offsets generated by these addressing modes are the sum of the constant and the
specified register. The addressing modes involving bx, si, and di all use the data
segment, the disp[bp] addressing mode uses the stack segment by default. As with the
register indirect addressing modes, you can use the segment override prefixes to specify
a different segment
mov al,[bx][si]
mov al,[bx][di]
mov al,[bp][si]
mov al,[bp][di]
7.Based Indexed Plus Displacement Addressing Mode
These addressing modes are a slight modification of the base/indexed addressing modes with the
addition of an eight bit or sixteen bit constant. The following are some examples of these
addressing modes:
10 • Stack addressing
– Saves the return address when the program calls a subroutine
– After fetching the jump op code and subroutine address, the PC is
made to point to the next op code (the return address)
– This return address is pushed onto the stack by the program
– The “return” instruction at the end of the subroutine pops the
return address from the stack, incrementing the stack pointer