MPMC Module 1&2_ Jan 25
MPMC Module 1&2_ Jan 25
ECPE12
II B. Tech-IV Semester
by
Dr. Srinivasulu Jogi
Assistant Professor, ECE
NIT-Tiruchirappalli
N AT I O N A L I N S T I T U T E O F T E C H N O L O G Y T I R U C H I R A P PA L L I ,
TA M I L N A D U , I N D I A
Microprocessors and Microcontrollers-Module 1-8086
Content
• Microprocessor based personal computer system.
• Software model of 8086.
• Segmented memory operation
• Instruction set.
• Addressing modes.
• Assembly language programming.
• Interrupts.
• Programming with DOS and BIOS function calls.
Microprocessors and Microcontrollers-Module 1-8086
Introduction
• A processor is the logic circuitry that responds to and processes the basic instructions that drives a computer.
• The term processor has generally replaced the term central processing unit. The processor in a ersonal computer or embedded
in small devices is often called a microprocessor.
• Microprocessor is a program-controlled device, which fetches the instructions from memory, decodes and executes the instructions.
Most Micro Processor are single-chip devices.
• A general diagram of processor is shown:
Microprocessors and Microcontrollers-Module 1-8086
Features of 8086
• Intel 8086 microprocessor is the enhanced version of Intel 8085 microprocessor. It was designed by Intel in 1976.
• Intel 8086 is built on a single semiconductor chip and packaged in a 40-pin IC package. The type of package is DIP (Dual
Inline Package).
• The 8086 is a 16-bit microprocessor. The term “16-bit” means that its arithmetic logic unit, internal registers and most of its
instructions are designed to work with 16-bit binary words.
• The 8086 has a 16-bit data bus, so it can read data from or write data to memory and ports either 16 bits or 8 bits at a time.
• The 8086 has a 20-bit address bus, so it can directly access 220 or 10,48,576 (1Mb) memory locations. Each of the 10,48,576 memory
locations is byte. Therefore, a sixteen-bit words are stored in two consecutive memory locations.
• The Features of 8086 Microprocessor can generate 16-bit I/O address, hence it can access 216 = 65536 I/O ports.
• The 8086 provides fourteen 16-bit registers.
• The 8086 has multiplexed address and data bus which reduces the number of pins needed, but does slow down the transfer of data
(drawback).
Microprocessors and Microcontrollers-Module 1-8086
Features of 8086
• The 8086 requires one phase clock with a 33% duty cycle to provide optimized internal timing.
• Range of clock rates are 5MHz, 8MHz, and 10MHz.
• The Features of 8086 Microprocessor is possible to perform bit, byte, word and block operations in 8086. It performs the
arithmetic and logical operations on bit, byte, word and decimal numbers including multiply and divide.
• The Intel 8086 is designed to operate in two modes, namely the minimum mode and the maximum mode. When only one 8086
CPU is to be used in a microcomputer system, the 8086 is used in the minimum mode of operation. In this mode the CPU
issues the control signals required by memory and I/O.
• In multiprocessor (more than one processor in the system) system 8086 operates in maximum mode. In maximum mode,
control signals are generated with the help of external bus controller (8288).
• The Intel 8086 supports multiprogramming. In multiprogramming, the code for two or more processes is in memory at the
same time and is executed in a time-multiplexed fashion.
Microprocessors and Microcontrollers-Module 1-8086
Features of 8086
• An interesting feature of the 8086 is that it fetches up to six instruction bytes (4 instruction bytes for 8088) from memory and
queue stores them in order to speed up instruction execution.
• The Features of 8086 Microprocessor provides powerful instruction set with the following addressing modes: Register,
immediate, direct, indirect through an index or base, indirect through the sum of a base and an index register, relative and
implied.
• It has 256 vectored interrupts.
• Memory is byte addressable - Every byte has a separate address that ranges from 00000H to FFFFFH
Microprocessors and Microcontrollers-Module 1-8086
Architecture of 8086
• Fig. shows a block diagram of the 8086 internal
architecture.
• It is internally divided into two separate
functional units. These are the Bus Interface
Unit (BIU) and the Execution Unit (EU).
• These two functional units can work
simultaneously to increase system speed and
hence the throughput.
• Throughput is a measure of number of
instructions executed per unit time
Microprocessors and Microcontrollers-Module 1-8086
Architecture of 8086
BIU
• The bus interface unit is the 8086 Internal
Architecture to the outside world. It provides a
full 16-bit bidirectional data bus and 20-bit
address bus.
• The bus interface unit is responsible for
performing all external bus operations, such as:
• It sends address of the memory or I/O
• It fetches instruction from memory.
• It reads data from port/memory.
• It writes data into port/memory.
• It supports instruction queuing.
Microprocessors and Microcontrollers-Module 1-8086
Architecture of 8086
BIU
• To implement these functions the BIU contains the instruction queue, segment
registers instruction pointer, address summer and bus control logic.
• Instruction Queue:
• To speed up program execution, the BIU fetches six instruction bytes ahead of time
from the memory. These pre-fetched instruction bytes are held for the execution
unit in a group of registers called Queue.
• With the help of queue it is possible to fetch next instruction when current
instruction is in execution.
• The queue operates on the principle first in first out (FIFO). So that the execution
unit gets the instructions for execution in the order they are fetched.
• Feature of fetching the next instruction while the current instruction is executing is
called pipelining.
Microprocessors and Microcontrollers-Module 1-8086
Architecture of 8086
BIU
Memory Segmentation:
• The physical address of the 8086 Internal Architecture is 20-bits wide to
access 1 Mbyte memory locations. However, its registers and memory
locations which contain logical addresses are just 16-bits wide. Hence 8086
uses memory segmentation.
• The memory in an 8086/88 based system is organized as segmented memory.
The Complete physically available memory may be divided into a number of
logical segments.
• The size of each segment is 64 KB. A segment may be located any where in
the memory. Each of these segments can be used for a specific function.
Microprocessors and Microcontrollers-Module 1-8086
Architecture of 8086
BIU
Memory Segmentation:
• In other words, It treats the 1 Mbyte of memory as divided into segments, with a maximum
size of a segment as 64 Kbytes. Thus any location within the segment can be accessed using
16 bits.
• The 8086 Internal Architecture allows only four active segments at a time, as shown in the
Fig. 6.4. For the selection of the four active segments the 16-bit segment registers are
provided within the BIU of the 8086. These four registers are :
• Code segment (CS) register,
• Data segment (DS) register,
• Stack segment (SS) register,
• Extra segment (ES) register.
Microprocessors and Microcontrollers-Module 1-8086
Architecture of 8086
Memory Segmentation:
• These are used to hold the upper 16-bits of the starting addresses of the four memory
segments, on which 8086 works at a particular time.
• For example, the value in CS identifies the starting address of 64 K-byte segment known as
code segment. By “starting address“, we mean the lowest addressed byte in the active code
segment. The starting address is also known as base address or segment base.
• Function of segment registers:
• The CS register holds the upper 16-bits of the starting address of the segment from
which the BIU is currently fetching the instruction code byte.
• The SS register is used for the upper 16-bits of the starting address for the program
stack (all stack related instructions will operate on stack)
• ES register and DS register are used to hold the upper 16-bits of the starting address of
the two memory segments which are used for data.
Microprocessors and Microcontrollers-Module 1-8086
Architecture of 8086
BIU
Memory Segmentation-Rules:
• The four segments can overlap for small programs. In a minimum system all four segments can start at the address
00000H.
• The segment can begin/start at any memory address which is divisible by 16.
• Advantages:
• It allows the memory addressing capacity to be 1 Mbyte even though the address associated with individual
instruction is only 16-bit.
• It allows instruction code, data, stack, and portion of program to be more than 64 KB long by using more than
one code, data, stack segment, and extra
• It facilitates use of separate memory areas for program, data and stack.
• It permits a program or its data to be put in different areas of memory, each time the program is executed i.e.
program can be relocated which is very useful in multiprogramming.
Microprocessors and Microcontrollers-Module 1-8086
Architecture of 8086
BIU
Instruction Pointer:
• The instruction pointer register holds the 16-bit address of the next Code byte within the code
segment. The value contained in the IP is referred to as an offset. This value must be offset from
(added to) the segment base address in CS to produce the required 20-bit physical address.
• Generation of 20-bit physical address:
• The contents of the CS register are multiplied by 16 i.e. shifted by 4 position to the left by
inserting 4 zero bits and then the offset i.e. the contents of IP register are added to the shifted
contents of CS to generate physical address. As shown in the Fig, the contents of CS register
are 348AH, therefore the shifted contents of CS register are 348A0H. When the BIU adds
the offset of 4214H in the IP to this starting address, the result is 20-bit physical of
38AB4H.
Microprocessors and Microcontrollers-Module 1-8086
Architecture of 8086
BIU
Segment and Offset register combinations:
• The value contained in the instruction pointer is called as an offset
because this value must be added to the base address of the code
segment , which is available in the CS register to find the 20 bit physical
address.
• Few combinations of segment and offset registers in 8086 are as shown:
Microprocessors and Microcontrollers-Module 1-8086
Architecture of 8086
EU
• The execution unit of 8086 Internal Architecture tells the BIU from where to fetch
instructions or data, decodes instructions and executes instructions. It contains
• Control Circuitry
• Instruction Decoder
• Arithmetic Logic Unit (ALU)
• Flag Register
• General Purpose Registers
• Pointers and Index Registers
Microprocessors and Microcontrollers-Module 1-8086
Architecture of 8086
EU
Control Circuitry, Instruction Decoder, ALU::
• The control circuitry in the EU directs the internal operations. A decoder in the EU translates the instructions fetched
from memory into a series of actions which the EU performs. ALU is 16-bit. It can add, subtract, AND, OR, XOR,
increment, decrements, complement and shift binary numbers.
• Flag Register:
• A flag is a flip–flop which indicates some condition produced by the execution of an instruction or controls certain
operations of the EU. The flag register contains nine active flags as shown in the Fig.
Microprocessors and Microcontrollers-Module 1-8086
Architecture of 8086
EU-Flag Register:
• A flag is a flip–flop which indicates some condition produced by the execution of an instruction or controls certain
operations of the EU. The flag register contains nine active flags as shown in the Fig.
Microprocessors and Microcontrollers-Module 1-8086
Architecture of 8086
EU-General Purpose Registers:
• The EU has. 8 general purpose registers labeled AH, AL, BH, BL, CH, CL, DH,
and DL. These registers can be used individually for temporary storage of 8 bit
data. The AL register is also called accumulator. Certain pairs of these general
purpose registers can be used together to store 16-bit data, such as AX, BX, CX
and DX.
EU-Pointers and Index Group Registers:
• All segment registers are 16-bit. But it is necessary to put 20-bit address (physical
address) on the address bus. To get 20-bit physical address one more register is
associated with each segment register the way IP is associated with CS.
• These additional registers belong to the pointer and index group. The pointer and
index group consists of instruction pointer (IP), stack pointer (SP), BP (base
pointer), source index (SI) and destination index (DI) registers.
Microprocessors and Microcontrollers-Module 1-8086
Architecture of 8086
EU-Stack Pointer:
• The stack pointer (SP) register contains the 16-bit
offset from the start of the segment to the top of stack.
For stack operation, physical address is produced by
adding the contents of stack pointer register to the
segment base address in SS. To do this the contents of
the stack segment register are shifted four bits left and
the contents of SP are added to the shifted result. If the
contents of SP are 9F20H and SS are 4000H then the
physical address is calculated as follows
Microprocessors and Microcontrollers-Module 1-8086
Architecture of 8086
EU-Base Pointer, Source Index and Destination Index (BP, SI and DI):
• These three 16-bit registers can be used as general purpose registers. However, their main use is to hold the 16-bit offset of
the data word in one of the segments.
EU-Base Pointer:
• We can use the BP register instead of SP for accessing the stack using the based addressing. mode. In this case, the 20-bit
physical stack address is calculated from BP and SS.
EU-Source Index:
• Source index (SI) can be used to hold the offset of a data word in the data segment. In this case, the 20-bit physical data
address is calculated from SI.
EU-Destination Index:
• The ES register .points to the extra segment in which data is stored. String instructions always use ES and DI to determine
the 20-bit physical address for the destination.
Microprocessors and Microcontrollers-Module 1-8086
Addressing Modes of 8086
Addressing Modes (AM):
• Addressing mode indicates a way of locating data or operands. Depending upon the data types used in the instruction and the
memory addressing modes, any instruction may belong to one or more addressing modes, or some instruction may not
belong to any of the addressing modes. Thus addressing modes describe the types of operands and the way they are accessed
for executing an instruction.
• According to the flow of instruction execution, the instructions may be categorized as:
• Sequential control flow instructions
• Control transfer instructions
Sequential control flow instructions:
• Sequential control flow instructions are the instructions which after execution, transfer control to the next instruction
appearing immediately after it in the program.
• For example, the arithmetic, logical, data transfer and processor control instructions are sequential control flow instructions
Microprocessors and Microcontrollers-Module 1-8086
Addressing Modes of 8086
Control transfer instructions
• The control transfer instructions, on the other hand , transfer control to some predefined address or the address somehow
specified in the instruction, after their execution.
• For example INT, CALL, RET and JUMP instructions fall under this category
• The addressing modes for sequential control flow instructions are explained as follows:
1. Immediate AM:
• In this type of addressing, immediate data is a part of instruction, and appears in the form of successive byte or bytes .
• For example, MOV AX, 6558H;
MOV BL, 54H;
2. Direct AM:
• In the direct addressing mode, a 16-bit memory address (offset) is directly specified in the instruction as a part of it.
• For example, MOV AX, [5000H];
MOV [2000H], BX;
Microprocessors and Microcontrollers-Module 1-8086
Addressing Modes of 8086
3. Register AM:
• In the register addressing mode, the data is stored in a register and it is referred using the particular register. All the registers,
except IP, may be used in this mode
• For example, MOV AX, BX;
MOV BL, CL;
4. Register Indirect AM:
• Sometimes, the address of the memory location which contains data or operand is determined in an indirect way, using the
offset registers. This mode of addressing is known as register indirect mode . In this addressing mode, the offset address of
data is in either BX or SI or DI register.
• The default segment is either DS or ES. The data is supposed to be available at the address pointed to by the content of any
of the above registers in the default data segment.
• For example, MOV AX, [BX];
Microprocessors and Microcontrollers-Module 1-8086
Addressing Modes of 8086
5. Indexed AM:
• In this addressing mode, offset of the operand is stored in one of the Index registers. DS is the default segment for index
registers SI and DI. In the case of string instructions DS and ES are default segments for SI and DI respectively. This mode
is a special case of the above discussed register indirect addressing mode.
• For example, MOV AX, [SI];
MOV BL, [DI];
6. Register Relative AM:
• In this addressing mode, the data is available at an effective address formed by adding an 8-bit or 16-bit displacement with
the content of any one of the registers BX, BP, SI and DI in the default (either DS or ES) segment.
• For example, MOV AX, 50H[SI];
MOV 10H[DI], AX;
Microprocessors and Microcontrollers-Module 1-8086
Addressing Modes of 8086
7. Based Indexed AM:
• The effective address of the data is formed, in this addressing mode, by adding the content of a base register (any one of BX
or BP) to the content of an index register (any one of SI or DI). The default segment register may be DS or ES.
• For example, MOV AX, [BX][SI];
MOV [BX][DI], AX;
8. Register Based Indexed AM:
• The effective address is formed by adding an 8-bit or 16-bit displacement with the sum of contents of anyone of the base
registers (BX or BP) and any one of the index registers (SI or DI), in a default segment.
• For example, MOV AX, 50H[BX][SI];
MOV 10H[BX][DI], AX;
Microprocessors and Microcontrollers-Module 1-8086
Addressing Modes of 8086
The addressing modes for control transfer instructions are explained as follows
Control transfer flow AM:
• For the control transfer instructions, the addressing modes depend upon whether the destination location is within the same
segment or in a different one. It also depends upon the method of passing the destination address to the processor
• Basically there are two addressing modes for the control transfer instructions, viz, intersegment and intrasegment addressing
modes.
• If the location to which the control is to be transferred lies in a different segment other than the current one, the mode is
called intersegment mode. If the destination location lies in the same segment, the mode is called intrasegment mode
Microprocessors and Microcontrollers-Module 1-8086
Addressing Modes of 8086
9. Intrasegment Direct AM:
• In this mode, the address to which the control is to be transferred lies in the same segment in which the control transfer
instruction lies and appears directly in the instruction as an immediate displacement value.
• For example,
JMP SHORT LABEL; LABEL lies -128 to +127 from the current IP content.
10. Intrasegment Indirect AM :
• In this mode, the address to which the control is to be transferred lies in the same segment in which the control transfer
instruction lies but it is passed to the instruction indirectly. Here the branch address is found as the content of a register or a
memory location.
• For example,
JMP [BX]; Jump to effective address stored in BX.
Microprocessors and Microcontrollers-Module 1-8086
Addressing Modes of 8086
11. Intersegment Direct AM:
• In this mode, the address to which the control is to be transferred lies in a different segment. This AM provides a means of
branching from one code segment to another code segment. Here both CS and IP contents are specified directly in the
instruction.
• For example,
JMP 5000H:2000H; Jump to effective address 2000H in segment 5000H.
12. Intersegment Indirect AM :
• In this mode, the address to which the control is to be transferred lies in a different segment and it is passed to the instruction
indirectly, i.e. contents of memory block containing four bytes, i.e. IP(LSB), IP(MSB), CS(LSB), and CS(MSB)
sequentially.
• For example,
JMP [2000H]; Jump to effective address stored in BX.
Microprocessors and Microcontrollers-Module 1-8086
Instruction Set of 8086
Instruction Set:
• 8086 supports 7 types of instructions.
• Data Transfer Instructions
• Arithmetic Instructions
• Logical Instructions
• Branch and Loop Instructions
• String Instructions
• Flag Manipulation Instructions
• Machine Control Instructions
General Syntax:
Label Instruction Mnemonic Operand 1, Operand 2;
Microprocessors and Microcontrollers-Module 1-8086
Instruction Set of 8086
1. Data Transfer Instructions:
• Instructions that are used to transfer data/ address in to registers, memory locations and I/O ports.
• Generally involve two operands: Source operand and Destination operand of the same size.
• Source: Register or a memory location or an immediate data and Destination : Register or a memory location.
• MOV:MOVE
Microprocessors and Microcontrollers-Module 1-8086
Instruction Set of 8086
1. Data Transfer Instructions:
• PUSH:PUSH POP:POP
Microprocessors and Microcontrollers-Module 1-8086
Instruction Set of 8086
1. Data Transfer Instructions:
• XCHG: Exchange XLAT: Translate
Microprocessors and Microcontrollers-Module 1-8086
Instruction Set of 8086
1. Data Transfer Instructions:
• IN: Input & OUT: Output
Microprocessors and Microcontrollers-Module 1-8086
Instruction Set of 8086
1. Data Transfer Instructions:
• LEA: Load effective address LDS/LES: Load data pointer
Microprocessors and Microcontrollers-Module 1-8086
Instruction Set of 8086
1. Data Transfer Instructions:
•
Microprocessors and Microcontrollers-Module 1-8086
Instruction Set of 8086