Unit - 1-1
Unit - 1-1
0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2018/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
1. To teach the architecture and functions a) Restate hardware ,software and programming concepts of
of 8085 and 8086 Microprocessors Microprocessor
2. To impart the concepts of 8051 b) Summarize architecture, instructions and addressing modes
microcontroller of 8086 Microprocessor
3. To convey aspects of I/O and Memory c) Describe addressing modes, Architecture, pins of 8051
Interfacing circuits Microcontroller
4. To train basic knowledge about d) Illustrate interfacing of Serial, parallel, Keyboard ,Display
advanced processors with Microcontroller
e) apply programming concepts to make assembly language
programs
f) Recall features ,registers of Advanced and Pentium
Processors
2 Define mnemonics 2
The short-hand form of describing the instructions is called mnemonics. The
mnemonics are given by the manufacturers of microprocessors and
programmable devices 2 1 K1
PROGRAM:
MVI A, 23H
MVI B, 84H,
4
ADD B
STA 4500
HLT
2 Explain in details about interrupts in 8085 12 1 K2
E.G.S. PILLAY ENGINEERING COLLEGE Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2018/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
Interrupt is signals send by an external device to the processor, to request the processor to perform a particular
task or work.
Mainly in the microprocessor based system the interrupts are used for data transfer between the peripheral and
the microprocessor.
The processor will check the interrupts always at the 2nd T-state of last machine cycle.
If there is any interrupt it accept the interrupt and send the INTA (active low) signal to the peripheral.
The vectored address of particular interrupt is stored in program counter.
The processor executes an interrupt service routine (ISR) addressed in program counter.
It returned to main program by RET instruction.
Types of Interrupts:
It supports two types of interrupts.
Hardware
Software
Software interrupts:
The software interrupts are program instructions. These instructions are inserted at desired locations in a
program.
The 8085 has eight software interrupts from RST 0 to RST 7. The vector address for these interrupts can be
6
calculated as follows.
Interrupt number * 8 = vector address
For RST 5,5 * 8 = 40 = 28H
Vector address for interrupt RST 5 is 0028H
The Table shows the vector addresses of all interrupts.
E.G.S. PILLAY ENGINEERING COLLEGE Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2018/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
Hardware interrupts:
An external device initiates the hardware interrupts and placing an appropriate signal at the interrupt pin of the
processor.
If the interrupt is accepted then the processor executes an interrupt service routine.
The 8085 has five hardware interrupts
(1) TRAP (2) RST 7.5 (3) RST 6.5 (4) RST 5.5 (5) INTR
TRAP:
This interrupt is a non-maskable interrupt. It is unaffected by any mask or interrupt enable.
TRAP bas the highest priority and vectored interrupt.
TRAP interrupt is edge and level triggered. This means hat the TRAP must go high and remain high until it is
acknowledged.
In sudden power failure, it executes a ISR and send the data from main memory to backup memory.
The signal, which overrides the TRAP, is HOLD signal. (i.e., If the processor receives HOLD and TRAP at the
same time then HOLD is recognized first and then TRAP is recognized).
There are two ways to clear TRAP interrupt.
1. By resetting microprocessor (External signal)
2. By giving a high TRAP ACKNOWLEDGE (Internal signal)
RST 7.5:
The RST 7.5 interrupt is a maskable interrupt.
It has the second highest priority.
It is edge sensitive. ie. Input goes to high and no need to maintain high state until it recognized.
Maskable interrupt. It is disabled by,
1.DI instruction 2. System or processor reset. 3.After reorganization of interrupt.
Enabled by EI instruction.
RST 6.5 and 5.5:
The RST 6.5 and RST 5.5 both are level triggered. . ie. Input goes to high and stay high until it recognized.
Maskable interrupt. It is disabled by,
1.DI, SIM instruction 2.System or processor reset. 3.After reorganization of interrupt.
E.G.S. PILLAY ENGINEERING COLLEGE Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2018/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
1. Immediate Addressing
2. Direct Addressing
3. Register Addressing
4. Register Indirect Addressing
5. Implied Addressing
1. IMMEDIATE ADDRESSING:
In immediate addressing mode, the data is specified in the instruction
itself. The data will be a part of the program instruction.
EX. MVI B, 3EH - Move the data 3EH given in the
instruction to B register;
LXI SP, 2700H.
6
2. DIRECT ADDRESSING:
In direct addressing mode, the address of the data is specified in the
instruction. The data will be in memory. In this addressing mode, the program
instructions and data can be stored in different memory.
EX. LDA 1050H - Load the data available in memory
location 1050H in to accumulator;
SHLD 3000H
3. REGISTER ADDRESSING:
In register addressing mode, the instruction specifies the name of the
register in which the data is available.
EX. MOV A, B - Move the content of B register to A
register;
SPHL; ADD C.
4. IMMEDIATE ADDRESSING:
In immediate addressing mode, the data is specified in the instruction
6
itself. The data will be a part of the program instruction.
EX. MVI B, 3EH - Move the data 3EH given in the
E.G.S. PILLAY ENGINEERING COLLEGE Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2018/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
instruction to B register;
LXI SP, 2700H.
5. DIRECT ADDRESSING:
In direct addressing mode, the address of the data is specified in the
instruction. The data will be in memory. In this addressing mode, the program
instructions and data can be stored in different memory.
EX. LDA 1050H - Load the data available in memory
location 1050H in to accumulator;
SHLD 3000H
6. REGISTER ADDRESSING:
In register addressing mode, the instruction specifies the name of the
register in which the data is available.
EX. MOV A, B - Move the content of B register to A
register;
SPHL; ADD C.
7. REGISTER INDIRECT ADDRESSING:
In register indirect addressing mode, the instruction specifies the
name of the register in which the address of the data is available. Here the
data will be in memory and the address will be in the register pair.
EX. MOV A, M - The memory data addressed by H L
pair is moved to A register.
LDAX B.
8. IMPLIED ADDRESSING:
In implied addressing mode, the instruction itself specifies the data to
be operated.
EX. CMA - Complement the content of accumulator;
RAL
4 Explain the various instruction set of 8085? 12 1 K2
The 8085 instruction set can be classified into the following five 6
functional headings.
1. DATA TRANSFER INSTRUCTIONS:
It includes the instructions that move (copies) data between registers
or between memory locations and registers. In all data transfer operations the
E.G.S. PILLAY ENGINEERING COLLEGE Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2018/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
Explanation of
Opcode Operand Description
Instruction
This instruction copies the contents of the
Rd, Rs source register into the destination register;
the contents of the source register are not
Copy from
altered. If one of the operands is a memory
MOV M, Rs source(Rs) to
location, its location is specified by the
destination(Rd)
contents of the HL registers.
Rd, M
Example: MOV B, C or MOV B, M
E.G.S. PILLAY ENGINEERING COLLEGE Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2018/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
Example: LDAX B
The instruction loads 16-bit data in the
Load register pair register pair designated in the operand.
LXI Reg. pair, 16-bit data
immediate
Example: LXI H, 2034H or LXI H, XYZ
The instruction copies the contents of the
memory location pointed out by the 16-bit
address into register L and copies the
Load H and L contents of the next memory location into
LHLD 16-bit address
registers direct register H. The contents of source memory
locations are not altered.
Example: STAX B
SHLD 16-bit address Store H and L The contents of register L are stored into
registers direct the memory location specified by the 16-
bit address in the operand and the contents
of H register are stored into the next
memory location by incrementing the
operand. The contents of registers HL are
not altered. This is a 3-byte instruction, the
second byte specifies the low-order address
and the third byte specifies the high-order
address.
E.G.S. PILLAY ENGINEERING COLLEGE Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2018/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
Example: XCHG
The instruction loads the contents of the H
and L registers into
the stack pointer register, the contents of
the H register provide the high-order
Copy H and L
address and the contents of the L register
SPHL none registers to the stack
provide the low-order address. The
pointer
contents of the H
and L registers are not altered.
Example: SPHL
The contents of the L register are
exchanged with the stack location pointed
out by the contents of the stack pointer
register. The contents of the H register are
Exchange H and L
XTHL none exchanged with the next stack location
with top of stack
(SP+1); however, the contents of the stack
pointer register are not altered.
Example: XTHL
The contents of the register pair designated in the
operand are copied onto the stack in the following
sequence. The stack pointer register is decremented
and the contents of the highorder register (B, D, H,
Push register pair A) are copied into that location. The stack pointer
PUSH Reg. pair
onto stack register is decremented again and the contents of
the low-order register (C, E, L, flags) are copied to
that location.
ARITHMETIC INSTRUCTIONS
Explanation of
Operand Description
Opcode Instruction
The contents of the operand
(register or memory) are
added to the contents of the
accumulator and the result
is stored in the accumulator.
If the operand is a memory
R Add register or
location, its location is
ADD memory, to
specified by the contents of
M accumulator
the HL registers. All flags
are modified to reflect the
result of the addition.
Example: DAD H
The contents of the operand
(register or memory ) are
subtracted from the
contents of the
accumulator, and the result
is stored in the accumulator.
R Subtract register or If the operand is a memory
SUB memory from location, its location is
M accumulator specified by the contents of
the HL registers. All flags
are modified to reflect the
result of the subtraction.
Example: XCHG
The contents of the
designated register or
memory) are incremented
by 1 and the result is stored
in the same place. If the
R
Increment register or operand is a memory
INR
memory by 1 location, its location is
M
specified by the contents of
the HL registers.
Example: INX H
The contents of the
designated register or
memory are M decremented
by 1 and the result is stored
in the same place. If the
R
Decrement register or operand is a memory
DCR
memory by 1 location, its location is
M
specified by the contents of
the HL registers.
Example: DCX H
DAA none Decimal adjust The contents of the
accumulator accumulator are changed
from a binary value to two
4-bit binary coded decimal
(BCD) digits. This is the
only instruction that uses
the auxiliary flag to
perform the binary to BCD
conversion, and the
conversion procedure is
described below. S, Z, AC,
P, CY flags are altered to
reflect the results of the
operation.
Example: DAA
BRANCHING INSTRUCTIONS
Explanation of
Opcode Operand Description
Instruction
The program sequence
is transferred to the
memory location
specified by the 16-bit
16-bit Jump
JMP address given in the
address unconditionally
operand.
Example: JMP
2034H or JMP XYZ
Example: CALL
2034H or CALL XYZ
The program sequence
is transferred from the
subroutine to the
calling program. The
two bytes from the top
Return from
of the stack are copied
RET none subroutine
into the program
unconditionally
counter, and program
execution begins at the
new address.
Example: RET
The program sequence
Opcode Description Flag Status is transferred from the
subroutine to the
RC Return on Carry CY = 1 calling program based
RNC Return on no Carry CY = 0 on the specified flag of
the PSW as described
RP Return on positive S=0
Return from below. The two bytes
RM Return on minus S=1 none subroutine from the top of the
conditionally stack are copied into
RZ Return on zero Z=1
the program counter,
RNZ Return on no zero Z=0 and program execution
RPE Return on parity even P=1 begins at the new
address.
RPO Return on parity odd P=0
Example: RZ
The contents of
registers H and L are
copied into the
program counter. The
Load program contents of H are
PCHL none counter with HL placed as the high-
contents order byte and the
contents of L as the
low-order byte.
Example: PCHL
RST 0-7 Restart The RST instruction is
equivalent to a 1-byte
call instruction to one
of eight memory
locations depending
upon the number. The
instructions are
generally used in
conjunction with
interrupts and inserted
using external
hardware. However
these can be used as
software instructions in
a program to transfer
program execution to
one of the eight
locations. The
addresses are:
E.G.S. PILLAY ENGINEERING COLLEGE Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2018/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
Restart
Instruction
Address
RST 0 0000H
RST1 0008H
RST 2 0010H
RST 3 0018H
RST 4 0020H
RST 5 0028H
RST 6 0030H
RST 7 0038H
Restart
Interrupt
Address
TRAP 0024H
RST 5.5 002CH
RST 6.5 0034H
RST 7.5 003CH
LOGICAL INSTRUCTIONS
Explanation of
Opcode Operand Description
Instruction
The contents of the operand (register or memory) are
M compared with the contents of the accumulator.
Both contents are preserved . The result of the
comparison is shown by setting the flags of the PSW
R Compare register as follows:
CMP or memory with
M accumulator if (A) < (reg/mem): carry flag is set
if (A) = (reg/mem): zero flag is set
if (A) > (reg/mem): carry and zero flags are reset
as follows:
Example: RLC
Each binary bit of the accumulator is rotated right by
one position. Bit D0 is placed in the position of D7
Rotate as well as in the Carry flag. CY is modified
RRC none
accumulator right according to bit D0. S, Z, P, AC are not affected.
Example: RRC
Each binary bit of the accumulator is rotated left by
one position through the Carry flag. Bit D7 is placed
Rotate in the Carry flag, and the Carry flag is placed in the
RAL none accumulator left least significant position D0. CY is modified
through carry according to bit D7. S, Z, P, AC are not affected.
Example: RAL
Each binary bit of the accumulator is rotated right by
one position through the Carry flag. Bit D0 is placed
Rotate in the Carry flag, and the Carry flag is placed in the
RAR none accumulator right most significant position D7. CY is modified
through carry according to bit D0. S, Z, P, AC are not affected.
Example: RAR
The contents of the accumulator are complemented.
Complement No flags are affected.
CMA none
accumulator
Example: CMA
The Carry flag is complemented. No other flags are
affected.
CMC none Complement carry
Example: CMC
Set Carry
STC none Set Carry
Example: STC
CONTROL INSTRUCTIONS
E.G.S. PILLAY ENGINEERING COLLEGE Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2018/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
Explanation of
Opcode Operand Description
Instruction
No operation is performed. The instruction is fetched and
NOP none No operation decoded. However no operation is executed.
Example: NOP
HLT none Halt and enter The CPU finishes executing the current instruction and
wait state halts any further execution. An interrupt or reset is
necessary to exit from the halt state.
Example: HLT
The interrupt enable flip-flop is reset and all the interrupts
except the TRAP are disabled. No flags are affected.
DI none Disable interrupts
Example: DI
The interrupt enable flip-flop is set and all interrupts are
enabled. No flags are affected. After a system reset or the
acknowledgement of an interrupt, the interrupt enable
flipflop is reset, thus disabling the interrupts. This
EI none Enable interrupts
instruction is
necessary to reenable the interrupts (except TRAP).
Example: EI
This is a multipurpose instruction used to read the status
of interrupts 7.5, 6.5, 5.5 and read serial data input bit.
The instruction loads eight bits in the accumulator with
the following interpretations.
Example: RIM
Read interrupt
RIM none
mas
Example: SIM
Set interrupt
SIM none
mask
E.G.S. PILLAY ENGINEERING COLLEGE Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2018/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
Instruction Cycle:
Machine Cycle:
T-State:
The machine cycle and instruction cycle takes multiple clock periods.
The 8085 microprocessor has 5 (seven) basic machine cycles. They are
The processor takes a definite time to execute the machine cycles. The
time taken by the processor to execute a machine cycle is expressed in T-
states. One T-state is equal to the time period of the internal clock signal of
the processor. The T-state starts at the falling edge of a clock.
8085 is a 40 pin IC, DIP package. The signals from the pins can be grouped as
follows
1. Power supply and clock signals
2. Address bus
3. Data bus
E.G.S. PILLAY ENGINEERING COLLEGE Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2018/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
3 output states are high & low states and additionally a high
impedance state.
When enable E is high the gate is enabled and the output Q can be 1
or 0 (if A is 0, Q is 1, otherwise Q is 0). However, when E is low the
gate is disabled and the output Q enters into a high impedance state.
Fig (a) - Pin Diagram of 8085 & Fig(b) - logical schematic of Pin diagram.
For both high and low states, the output Q draws a current from the
input of the OR gate.
When E is low, Q enters a high impedance state; high impedance
E.G.S. PILLAY ENGINEERING COLLEGE Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2018/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
10
DATA BUS:
The data bus is a group of eight lines used for data flow.
These lines are bi-directional - data flow in both directions
between the MPU and memory and peripheral devices.
The MPU uses the data bus to perform the second function:
transferring binary information.
The eight data lines enable the MPU to manipulate 8-bit data
ranging from 00 to FF (28 = 256 numbers).
The largest number that can appear on the data bus is 11111111.
CONTROL BUS:
The control bus carries synchronization signals and providing
timing signals.
The MPU generates specific control signals for every operation it
performs. These signals are used to identify a device type with
which the MPU wants to communicate.
REGISTERS OF 8085:
The 8085 have six general-purpose registers to store 8-bit data
during program execution.
These registers are identified as B, C, D, E, H, and L.
They can be combined as register pairs-BC, DE, and HL-to
perform some 16-bit operations.
E.G.S. PILLAY ENGINEERING COLLEGE Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2018/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
ACCUMULATOR (A):
The accumulator is an 8-bit register that is part of the
arithmetic/logic unit (ALU).
This register is used to store 8-bit data and to perform arithmetic
and logical operations.
The result of an operation is stored in the accumulator.
FLAGS REGISTER:
The ALU includes five flip-flops that are set or reset according to
the result of an operation.
The microprocessor uses the flags for testing the data conditions.
They are Zero (Z), Carry (CY), Sign (S), Parity (P), and Auxiliary
Carry (AC) flags. The most commonly used flags are Sign, Zero,
and Carry.
The bit position for the flags in flag register is,
TEMPORARY REGISTER:
It is used to hold the data during the arithmetic and logical operations.
INSTRUCTION REGISTER:
When an instruction is fetched from the memory, it is loaded in the
instruction register.
E.G.S. PILLAY ENGINEERING COLLEGE Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2018/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
Mnemonics :
LDA 4500
MOV B,A
DCR B
LXI H, 4500
MOV C,M
DCR C
E.G.S. PILLAY ENGINEERING COLLEGE Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2018/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
INX H
MOV A,M
INX H
CMP M
JC
MOV D,M
MOV M,A
DCX H
MOV M,D
INX H
DCR C
JNZ Loop 1
DCR B
JNZ Loop 2
HLT
To write a program to sort given ‘n’ numbers in descending order 10
Algorithm:
Step 1 : Start the microprocessor
Step 2 : Load the number of values into
accumulator and save the
number of values in register ‘B’
Step 3 : Decrement register ‘B’ for (N-1)
Repetitions
Step 4 : Set ‘HL’ register pair as data array
address pointer and load the data of
array in accumulator
Step 5 : Set ‘C’ register as counter for (N-1)
repetitions
Step 6 : Increment ‘HL’ pair (data address
pointer)
Step 7 : Compare the data pointed by ‘HL’ with
accumulator
Step 8 : If the value of accumulator is larger
than memory, then jump to step 10,
otherwise next step.
Step 9 : Exchange the contents of memory
pointed by ‘HL’ and
accumulator
Step 10 : Decrement ‘C’ register, if the of ‘C’
is not zero go to step 6, otherwise
next step.
Step 11 : Decrement ‘B’ register, if ‘B’ is not
zero, go step 3, otherwise
E.G.S. PILLAY ENGINEERING COLLEGE Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2018/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
next step.
Step 12 : Stop the program execution
Mnemonics:
LDA 4500
MOV B,A
DCR B
LXI H, 4500
MOV C,M
DCR C
E.G.S. PILLAY ENGINEERING COLLEGE Rev.0
(An Autonomous Institution, Affiliated to Anna University, Chennai)
COE/2018/QB
Nagore Post, Nagapattinam – 611 002, Tamilnadu.
INX H
MOV A,M
INX H
CMP M
ICE, Loop 1
MOV D,M
MOV M,A
DCX H
MOV M,D
INX H
DCR C
JNZ Loop 2
DCR B
JNZ Loop 3
HLT