Unit-1 MPMC Final
Unit-1 MPMC Final
MICROCONTROLLERS
Subject Code: 2004PC13
Course Outcomes:
• Understands the internal architecture and organization of
8086, 8051 and ARM processors/controllers.
TEXT BOOKS:
1. Advanced Microprocessors and Peripherals – A. K. Ray and K.M. Bhurchandani,
MHE, 2nd Edition 2006.
2. The 8051 Microcontroller, Kenneth. J. Ayala, Cengage Learning, 3rd Ed.
3. ARM System Developers guide, Andrew N SLOSS, Dominic SYMES, Chris
WRIGHT, Elsevier, 2012
REFERENCE BOOKS:
1. Microprocessors and Interfacing, D. V. Hall, MGH, 2nd Edition 2006.
2. Introduction to Embedded Systems, Shibu K.V, MHE, 2009
3. The 8051Microcontrollers, Architecture and Programming and Applications -
K.Uma Rao, Andhe Pallavi, Pearson, 2009.
Features of 8086 Microprocessor
• It is a 16-bit microprocessor.
Control Unit:
– The control unit in 8086 microprocessor produces control
signal after decoding the opcode to inform the general
purpose register to release the value stored in it. And it also
signals the ALU to perform the desired operation.
ALU:
– The arithmetic and logic unit carries out the logical tasks
according to the signal generated by the CU. The result of
the operation is stored in the desired register.
• There are total 9 flags in 8086 and the flag
register/Program Status Word (PSW) is divided into two
types:
• Interrupt Flag (I) – This flag is for interrupts. If interrupt flag is set (1), the
microprocessor will recognize interrupt requests from the peripherals. If
interrupt flag is reset (0), the microprocessor will not recognize any interrupt
requests and will ignore them.
• Trap Flag (T) – This flag is used for on-chip debugging. Setting trap flag puts
the microprocessor into single step mode for debugging.
Register Organization in 8086
• General-purpose registers are used to store temporary
data within the microprocessor.
2. BX: This is the base register. It is of 16 bits and is divided into two 8-bit registers BH and
BL to also perform 8-bit instructions. It is used to store the value of the offset.
Example:
MOV BL, [500] (BL = 500H)
3. CX: This is the counter register. It is of 16 bits and is divided into two 8-bit registers CH
and CL to also perform 8-bit instructions. It is used in looping and rotation.
Example:
MOV CX, 0005 LOOP
4. DX: This is the data register. It is of 16 bits and is divided into two 8-bit registers DH and
DL to also perform 8-bit instructions. It is used in the multiplication and input/output
port addressing.
Example:
MUL BX (DX, AX = AX * BX)
SP: This is the stack pointer. It is of 16 bits. It points to the
topmost item of the stack. If the stack is empty the stack
pointer will be (FFFE)H. Its offset address is relative to the
stack segment.
• The memory chip is equally divided into two parts(banks). One of the
banks contains even addresses called Even bank and the other
contains odd addresses called Odd bank.
• Even bank always gives lower byte So Even bank is also called Lower
bank(LB) and Odd bank is also called Higher bank(HB).
Physical Memory Calculation
Signal Descriptions of 8086 (Pin Diagram)
• 8086 was the first 16-bit microprocessor available in 40-pin
DIP (Dual Inline Package) chip. Let us now discuss in detail
the pin configuration of a 8086 Microprocessor.
Clock signal
• Clock signal is provided through Pin-19. It provides timing to
the processor for operations. Its frequency is different for
different versions, i.e. 5MHz, 8MHz and 10MHz.
Address/data bus
• AD0-AD15. These are 16 address/data bus. AD0-AD7 carries
low order byte data and AD8AD15 carries higher order byte
data. During the first clock cycle, it carries 16-bit address and
after that it carries 16-bit data.
Address/status bus
• A16-A19/S3-S6. These are the 4 address/status buses. During the first
clock cycle, it carries 4-bit address and later it carries status signals.
S7/BHE
• BHE stands for Bus High Enable. It is available at pin 34 and used to
indicate the transfer of data using data bus D8-D15. This signal is low
during the first clock cycle, thereafter it is active.
Read
• It is available at pin 32 and is used to read signal for Read operation.
Ready
• It is available at pin 22. It is an acknowledgement signal from I/O
devices that data is transferred. It is an active high signal. When it is
high, it indicates that the device is ready to transfer data. When it is
low, it indicates wait state.
RESET
• It is available at pin 21 and is used to restart the execution. It causes
the processor to immediately terminate its present activity. This
signal is active high for the first 4 clock cycles to RESET the
microprocessor.
INTR
• It is available at pin 18. It is an interrupt request signal, which is
sampled during the last clock cycle of each instruction to determine if
the processor considered this as an interrupt or not.
NMI
• It stands for non-maskable interrupt and is available at pin 17. It is an
edge triggered input, which causes an interrupt request to the
microprocessor.
TEST
• This signal is like wait state and is available at pin 23. When this signal
is high, then the processor has to wait for IDLE state, else the
execution continues.
MN/MX
• It stands for Minimum/Maximum and is available at pin 33. It
indicates what mode the processor is to operate in; when it is high, it
works in the minimum mode and vice-versa.
INTA
• It is an interrupt acknowledgement signal and id available at pin 24.
When the microprocessor receives this signal, it acknowledges the
interrupt.
ALE
• It stands for address enable latch and is available at pin 25. A positive
pulse is generated each time the processor begins any operation. This
signal indicates the availability of a valid address on the address/data
lines.
DEN
• It stands for Data Enable and is available at pin 26. It is used to enable
Transreceiver 8286. The transreceiver is a device used to separate
data from the address/data bus.
DT/R
• It stands for Data Transmit/Receive signal and is available at pin 27. It
decides the direction of data flow through the transeceiver. When it
is high, data is transmitted out and vice-a-versa.
M/IO
• This signal is used to distinguish between memory and I/O
operations. When it is high, it indicates I/O operation and when it is
low indicates the memory operation. It is available at pin 28.
WR
• It stands for write signal and is available at pin 29. It is used to write
the data into the memory or the output device depending on the
status of M/IO signal.
HLDA
• It stands for Hold Acknowledgement signal and is available at pin 30.
This signal acknowledges the HOLD signal.
HOLD
• This signal indicates to the processor that external devices are
requesting to access the address/data buses. It is available at pin 31.
0 0 No operation
1 1 Subsequent byte
from the queue
S0, S1, S2
• These are the status signals that provide the status of operation, which is
used by the Bus Controller 8288 to generate memory & I/O control signals.
These are available at pin 26, 27, and 28. Following is the table showing
their status −
S2 S1 S0 Status
0 0 0 Interrupt
acknowledgement
0 0 1 I/O Read
0 1 0 I/O Write
0 1 1 Halt
1 0 0 Opcode fetch
1 0 1 Memory read
1 1 0 Memory write
1 1 1 Passive
LOCK
• When this signal is active, it indicates to the other
processors not to ask the CPU to leave the system bus.
It is activated using the LOCK prefix on any instruction
and is available at pin 29.
1) Minimum mode:
• In this 8086 is the only processor in the system . In a minimum mode 8086
system.
• 8086 is operated in minimum mode when MN/MX’ pin to logic 1.
• In this mode, all the control signals are given out by the 8086 itself.
2) Maximum mode:
• In this we can connect more processors to 8086 (8087/8089).
• 8086 max mode is basically for implementation of allocation of global
resources and passing bus control to other coprocessor(i.e. second processor
in the system), because two processors can not access system bus at same
instant.
• All processors execute their own program.
• The resources which are common to all processors are known as global
resources.
• The resources which are allocated to a particular processor are known as
local or private resources.
Minimum mode configuration of 8086
microprocessor
• The 8086 microprocessor operates in minimum mode when MN/MX’ = 1.
• The address bus of 8086 is 20 bits long. By this we can access 220 byte
memory i.e. 1MB . Out of 20 bits, 16 bits A0 to A15(or 16 lines) are
multiplexed with a data bus. By multiplexing, it means they will act as
address lines during the first T state of the machine cycle and in the rest,
they act as data lines. A16 to A19 are multiplexed S3 to S6 and BHE’ is
multiplexed with S7.
Timing diagram of Minimum Mode
The working of min mode can be easily understood by timing
diagrams.
• In T2, the bus is tristated for changing the direction of the bus(
in the case of a data read cycle.)
• In T2, the address is removed from the local bus and is sent to the
addressed device. Then the bus is tristated.
• During T3, data is put on the data bus and the processor reads it.
• The output device makes the READY line high. This means the
output device has performed the data transfer process. When the
processor makes the read signal to 1, then the output device will
again tristate its bus drivers.
Write memory cycle
• At T1 state ALE =1 ,this indicates that a valid address is
latched on the address bus and also M / IO’= 1, which
indicates the memory operation is in progress.
• The BHE’ and A0 signals are used to select the byte or bytes
of memory or I/O word.
• 8288 bus controller- Address form the address bus is latched into
8282 8-bit latch. Three such latches are required because address
bus is 20 bit. The ALE(Address latch enable) is connected to
STB(Strobe) of the latch. The ALE for latch is given by 8288 bus
controller.
• The data bus is operated through 8286 8-bit transceiver. Two such
transceivers are required, because data bus is 16-bit. The
transceivers are enabled the DEN signal, while the direction of data
is controlled by the DT/R signal. DEN is connected to OE’ and DT/
R’ is connected to T. Both DEN and DT/ R’ are given by 8288 bus
controller.
• Control signals for all operations are generated by
decoding S’2, S’1 and S’0 using 8288 bus controller.
• Bus request is done using RQ’ / GT’ lines
interfaced with 8086. RQ0/GT0 has more priority
than RQ1/GT1.
• The size for each interrupt vector is 4 bytes (2 word in 16 bit), where
2 bytes (1 word) for segment and 2 bytes for offset of interrupt
service routine address.
Example:
• MOV CX, 4929 H
• ADD AX, 2387 H
• MOV AL, FFH
2) Register addressing mode:
• It means that the register is the source of an operand for an
instruction.
Example:
• MOV CX, AX ; copies the contents of the 16-bit AX register
into ; the 16-bit CX register)
• ADD BX, AX
Example:
• MOV AX, [1592H]
• MOV AL, [0300H]
4) Register indirect addressing mode:
• This addressing mode allows data to be addressed at any
memory location through an offset address held in any of
the following registers: BP, BX, DI & SI.
Example:
• MOV AX, [BX] ; Suppose the register BX contains 4895H, then
the contents ; 4895H are moved to AX
• ADD CX, {BX}
Example:
• MOV DX, [BX+04]
• ADD CL, [BX+08]
6) Indexed addressing mode:
• In this addressing mode, the operands offset address is
found by adding the contents of SI or DI register and 8-
bit/16-bit displacements.
Example:
• MOV BX, [SI+16]
• ADD AL, [DI+16]
Example:
• ADD CX, [AX+SI]
• MOV AX, [AX+DI]
8) Based indexed with displacement mode:
• In this addressing mode, the operands offset is
computed by adding the base register contents.
An Index registers contents and 8 or 16-bit
displacement.
Example:
• MOV AX, [BX+DI+08]
• ADD CX, [BX+SI+16]
8086 Instruction Set
• The 8086 microprocessor supports 8 types of
instructions −
• LAHF − Used to load AH with the low byte of the flag register.
• SAHF − Used to store AH register to low byte of the flag
register.
• PUSHF − Used to copy the flag register at the top of the stack.
• POPF − Used to copy a word at the top of the stack to the flag
register.
XCHG Instruction:
It exchanges the contents of a register with the
contents of another register or a memory
location but not the immediate operand.
1020H 1000H
XLAT Instruction:
PA = 10000+0400+05 = 10405H
After executing XLAT AL 20H ASCII code equivalent to BCD
2) Arithmetic Instructions
• These instructions are used to perform arithmetic
operations like addition, subtraction, multiplication,
division, etc.
• Following is the list of instructions under this group −
2) MOV AX,0033H
MOV BX,0027H
ADD AX,BX
AAA
● DAA [Decimal Adjust accumulator]
➢ This instruction is used to make sure that the result of adding two BCD numbers is
adjusted to a proper BCD number (BCD code uses four bits to represent 10 decimal
digits 0-9)
➢ If the value of low –order four bits of result(B3-B0) in AL>9 or AF =1, DAA
➢ If (B7-B4) in AH>9 or CF=1, DAA instructs adds 6 to the higher order to make it as
39H – ASCII of 9 39
35H – ASCII of 5 -35
AL 04 Proper BCD
● AAM [ASCII Adjust after Multiplication]
Used to adjust ASCII codes after multiplication
We get 5 X 7 = 35
● AAD [ASCII Adjust before Division]
Used to adjust ASCII codes before division. Converts 2 unpacked BCD
digits to packed.
Ex: MOV AX, 0607H AX = 0607
MOV CH, 09 H CH = 09
AAD Convert unpacked BCD to packed BCD i.e.
0607 → 67 09 → 9
DIV CH 67
9 AX
04(R) 07 (Q)
AH AL
● CBW [Convert byte to word]
Convert a byte in AL to word in AX
AH AX
AL
0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1
● CWD [Convert word to double word]
Converts word in AX to double word. This
instruction copies the sign bit of AX to all the
bits of DX. This operation is done before
unsigned division.