Laboratory Manual Microprocessor 8085: SL - No. Name of The Experiments No
Laboratory Manual Microprocessor 8085: SL - No. Name of The Experiments No
Laboratory Manual Microprocessor 8085: SL - No. Name of The Experiments No
Microprocessor 8085
Electronics Lab
Department of Physics
Gauhati University
Page
Sl.No. Day Name of the Experiments
No.
1 1 Induction to 8085 Microprocessor
2
4
2
4
5
6 3
1
7
8
9
10
11 4
13
14
5
15
16
6
17
18
7
19
20 8
2
It is an 8 bit register i.e. B, C, D, E, H, L. The combination of 8 bit register is known
as register pair, which can hold 16 bit data. The HL pair is used to act as memory pointer is
accessible to program.
b) Accumulator
It is an 8 bit register which hold one of the data to be processed by ALU and stored
the result of the operation.
It is a 16 bit special purpose register which is used to hold line memory address for
line next instruction to be executed.
It carries out arithmetic and logical operation by 8 bit address it uses the accumulator
content as input the ALU result is stored back into accumulator.
f) Temporary register
It is an 8 bit register associated with ALU hold data, entering an operation, used by
the microprocessor and not accessible to programs.
g) Flags
Flag register is a group of fire, individual flip flops line content of line flag register
will change after execution of arithmetic and logic operation. The line states flags are
3
h) Timing and control unit
Synchronous all microprocessor, operation with the clock and generator and control
signal from it necessary to communicate between controller and peripherals.
Instruction is fetched from line memory and stored in line instruction register decoder
the stored information.
j) Register Array
These are used to store 8 bit data during execution of some instruction
PIN Description
Address Bus
1. The pins Ao – A15 denote the address bus.
2. They are used for most significant bit
1. The signal goes high during the first clock cycle and enables the lower order
address bits.
IO / M
1. This distinguishes whether the address is for memory or input.
2. When this pins go high, the address is for an I/O device.
S0 – S1
S0 and S1 are status signal which provides different status and functions.
4
RD
1. This is an active low signal
2. This signal is used to control READ operation of the microprocessor.
WR
1. WR is also an active low signal
2. Controls the write operation of the microprocessor.
HOLD
1. This indicates if any other device is requesting the use of address and data bus.
HLDA
1. HLDA is the acknowledgement signal for HOLD
2. It indicates whether the hold signal is received or not.
INTR
1. INTE is an interrupt request signal
2. IT can be enabled or disabled by using software
INTA
1. Whenever the microprocessor receives interrupt signal
2. It has to be acknowledged.
TRAP
1. Trap is the only non-maskable interrupt
2. It cannot be enabled (or) disabled using program.
RESET IN
5
1. This pin resets the program counter to 0 to 1 and results interrupt enable and
HLDA flip flops.
X1, X2
These are the terminals which are connected to external oscillator to produce the
necessary and suitable clock operation.
SID
This pin provides serial input data
SOD
This pin provides serial output data
6
INSTRUCTION SETS OF 8085:
7
1. Control
2. Logical
3. Branching
4. Arithmetic
5. Data Transfer
CONTROL INSTRUCTIONS:
Opcode Operand Explanation Description
of
Instruction
NOP none No No operation is performed. The instruction is fetched
operation and decoded. However no operation is executed.
Example: NOP
HLT none Halt and The CPU finishes executing the current instruction and
enter wait halts any further execution. An interrupt or reset is
state necessary to exit from the halt state.
Example: HLT
DI none Disable The interrupt enable flip-flop is reset and all the
interrupts interrupts except the TRAP are disabled. No flags are
affected.
Example: DI
EI none Enable The interrupt enable flip-flop is set and all interrupts
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 instruction is necessary to reenable the interrupts
(except TRAP).
Example: EI
RIM none Read This is a multipurpose instruction used to read the
interrupt status of interrupts 7.5, 6.5, 5.5 and read serial data
mas input bit. The instruction loads eight bits in the
accumulator with the following interpretations.
Example: RIM
SIM none Set interrupt This is a multipurpose instruction and used to
mask implement the 8085 interrupts 7.5, 6.5, 5.5, and serial
data output. The instruction interprets the accumulator
contents as follows.
Example: SIM
LOGICAL INSTRUCTIONS:
8
Opcode Operand Explanation of Description
Instruction
CMP R Compare The contents of the operand (register or memory) are
register or M compared with the contents of the accumulator.
M memory with Both contents are preserved . The result of the
accumulator comparison is shown by setting the flags of the PSW
as follows:
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
Example: CMP B or CMP M
CPI 8-bit data Compare The second byte (8-bit data) is compared with the
immediate with contents of the accumulator. The values being
accumulator compared remain unchanged. The result of the
comparison is shown by setting the flags of the PSW
as follows:
if (A) < data: carry flag is set
if (A) = data: zero flag is set
if (A) > data: carry and zero flags are reset
Example: CPI 89H
ANA R Logical AND The contents of the accumulator are logically ANDed
register or with M the contents of the operand (register or
M memory with memory), and the result is placed in the accumulator.
accumulator If the operand is a memory location, its address is
specified by the contents of HL registers. S, Z, P are
modified to reflect the result of the operation. CY is
reset. AC is set.
Example: ANA B or ANA M
ANI 8-bit data Logical AND The contents of the accumulator are logically ANDed
immediate with with the 8-bit data (operand) and the result is placed
accumulator in the accumulator. S, Z, P are modified to reflect the
result of the operation. CY is reset. AC is set.
Example: ANI 86H
XRA R Exclusive OR The contents of the accumulator are Exclusive ORed
register or with M the contents of the operand (register or
M memory with memory), and the result is placed in the accumulator.
accumulator If the operand is a memory location, its address is
specified by the contents of HL registers. S, Z, P are
modified to reflect the result of the operation. CY and
AC are reset.
Example: XRA B or XRA M
XRI 8-bit data Exclusive OR The contents of the accumulator are Exclusive ORed
immediate with with the 8-bit data (operand) and the result is placed
accumulator in the accumulator. S, Z, P are modified to reflect the
result of the operation. CY and AC are reset.
9
accumulator If the operand is a memory location, its address is
specified by the contents of HL registers. S, Z, P are
modified to reflect the result of the operation. CY and
AC are reset.
Example: RLC
RRC none Rotate Each binary bit of the accumulator is rotated right by
accumulator one position. Bit D0 is placed in the position of D7 as
right well as in the Carry flag. CY is modified according to
bit D0. S, Z, P, AC are not affected.
Example: RRC
RAL none Rotate Each binary bit of the accumulator is rotated left by
accumulator one position through the Carry flag. Bit D7 is placed
left through in the Carry flag, and the Carry flag is placed in the
carry least significant position D0. CY is modified
according to bit D7. S, Z, P, AC are not affected.
Example: RAL
RAR none Rotate Each binary bit of the accumulator is rotated right by
accumulator one position through the Carry flag. Bit D0 is placed
right through in the Carry flag, and the Carry flag is placed in the
carry most significant position D7. CY is modified
according to bit D0. S, Z, P, AC are not affected.
Example: RAR
CMA none Complement The contents of the accumulator are complemented.
accumulator No flags are affected.
Example: CMA
CMC none Complement The Carry flag is complemented. No other flags are
carry affected.
Example: CMC
STC none Set Carry Set Carry
Example: STC
BRANCHING INSTRUCTIONS:
10
Opcode Operan Explanation Description
d of Instruction
JMP 16-bit Jump The program
address unconditionall sequence is
y transferred to the
memory location
specified by the 16-
bit address given in
the operand.
Example: JMP
2034H or JMP XYZ
Flag 16-bit Jump The program
Opcode Description address conditionally sequence is
Status
transferred to the
JC Jump on Carry CY = 1 memory location
JNC Jump on no Carry CY = 0 specified by the 16-
bit address given in
JP Jump on positive S=0
the operand based
JM Jump on minus S=1 on the specified flag
JZ Jump on zero Z=1 of the PSW as
described below.
JNZ Jump on no zero Z=0
Jump on parity Example: JZ 2034H
JPE P=1 or JZ XYZ
even
JPO Jump on parity odd P = 0
Opcode Description Flag Status 16-bit Unconditional The program
address subroutine call sequence is
CC Call on Carry CY = 1 transferred to the
CNC Call on no Carry CY = 0 memory location
specified by the 16-
CP Call on positive S=0
bit address given in
CM Call on minus S=1 the operand. Before
CZ Call on zero Z=1 the transfer, the
address of the next
CNZ Call on no zero Z=0 instruction after
CPE Call on parity even P = 1 CALL (the contents
of the program
CPO Call on parity odd P = 0 counter) is pushed
onto the stack.
Example: CALL
2034H or CALL
XYZ
RET none Return from The program
subroutine sequence is
unconditionall transferred from the
y subroutine to the
calling program.
11
The two bytes from
the top of the stack
are copied into the
program
counter,and
program execution
begins at the new
address.
Example: RET
Flag none Return from The program
Opcode Description subroutine sequence is
Status
conditionally transferred from the
RC Return on Carry CY = 1 subroutine to the
RNC Return on no Carry CY = 0 calling program
based on the
RP Return on positive S=0
specified flag of the
RM Return on minus S=1 PSW as described
RZ Return on zero Z=1 below. The two
bytes from the top
RNZ Return on no zero Z=0 of the stack are
Return on parity copied into the
RPE P=1 program counter,
even
and program
Return on parity execution begins at
RPO P=0
odd the new address.
Example: RZ
PCHL none Load program The contents of
counter with registers H and L
HL contents are copied into the
program counter.
The contents of H
are placed as the
high-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
12
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:
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
ARITHMATIC INSTRUCTIONS:
13
Opcode Operand Explanation Description
of Instruction
ADD R Add register or The contents of the operand (register or memory)
memory, to are added to the contents of the accumulator and the
M accumulator result is stored in the accumulator. If the operand is
a memory location, its location is specified by the
contents of the HL registers. All flags are modified
to reflect the result of the addition.
Example: DAD H
SUB R Subtract The contents of the operand (register or memory )
register or are subtracted from the contents of the accumulator,
M memory from and the result is stored in the accumulator. If the
accumulator operand is a memory location, its location is
specified by the contents of the HL registers. All
flags are modified to reflect the result of the
14
subtraction.
Example: INX H
DCR R Decrement The contents of the designated register or memory
register or are M decremented by 1 and the result is stored in
M memory by 1 the same place. If the operand is a memory location,
its location is specified by the contents of the HL
registers.
Example: DCX H
DAA none Decimal adjust The contents of the accumulator are changed from a
accumulator binary value to two 4-bit binary coded decimal
(BCD) digits. This is the only instruction that uses
15
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
Example: LDAX B
LXI Reg. Load register The instruction loads 16-bit data in the register
pair, 16- pair immediate pair designated in the operand.
bit data
Example: LXI H, 2034H or LXI H, XYZ
LHLD 16-bit Load H and L The instruction copies the contents of the
16
address registers direct memory location pointed out by the 16-bit address
into register L and copies the contents of the next
memory location into register H. The contents of
source memory locations are not altered.
Example: STAX B
SHLD 16-bit Store H and L The contents of register L are stored into the
address registers direct 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.
Example: XCHG
SPHL none Copy H and L The instruction loads the contents of the H and L
registers to the registers into
stack pointer the stack pointer register, the contents of the H
register provide the high-order address and the
contents of the L register provide the low-order
address. The contents of the H
and L registers are not altered.
Example: SPHL
XTHL none Exchange H and The contents of the L register are exchanged with
L with top of the stack location pointed out by the contents of
stack the stack pointer register. The contents of the H
register are exchanged with the next stack location
(SP+1); however, the contents of the stack pointer
17
register are not altered.
Example: XTHL
PUSH Reg. Push register The contents of the register pair designated in the
pair pair onto stack 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, A) are copied into that location.
The stack pointer register is decremented again
and the contents of the low-order register (C, E, L,
flags) are copied to that location.
18
PROGRAMS:
19
AIM: SUBTRACT TWO NUMBERS:
20
AIM: ADD TWO 8-BIT NUMBERS AND SAVE THE RESULT
MEMORY LABEL MNEMONICS HEX COMMENT
LOCATION OPCODE OPERAND CODE
8000 LXI H,9000H 21 Load HL
8001 00 pair
8002 90 immediately
with 9000H
8003 MOV A,M 7E Move data
from
memory to
A
8004 INX H 23 Increment
the content
of HL pair
8005 MOV B,M 46 Move data
from
memory to B
8006 ADD B 80 Add the
content of B
with the
content of A
8007 STA 8050 32 Store the
8008 50 result in
8009 80 memory
location
8050
800A HLT 76 Stop
21
AIM: ADD TWO 8-BIT NUMBERS AND SAVE THE RESULT AND
CARRY IN TWO CONSECUTIVE MEMORY LOCATIONS:
MEMORY MNEMONICS HEX
LABEL COMMENT
LOCATION OPCODE OPERAND CODE
8000 OE
MVI C,00H Move immediately 00H in to C
8001 00
8002 21
8003 LXI H,8000H 00 Load HL pair with 8000H
8004 80
8005 MVI A,M 7E Move the content of memory to A
8006 INX H 23 Increment content of HL pair
8007 MOV B,M 46 Move memory content to B
8008 ADD B 80 Add the content of B with A
8009 D2
Jump to memory location 800D if
800A JNC GO 800D 0D
carry is not zero
800B 90
800C INR C 0C Increment the content of C
800D 32
Store the content of A in memory
800E GO STA 8050H 50
location 8050
800F 80
8010 MOV A,C 79 Move data from C to A
8011 32
Store the content of A in memory
8012 STA 8051H 51
location 8051
8013 80
8014 HLT 76 Stop
22
AIM: ADD FIVE 8-BIT DATA STORED IN FIVE CONSECUTIVE
MEMORY LOCATIONS
MEMORY MNEMONICS HEX
LABEL COMMENT
LOCATION OPCODE OPERAND CODE
9000 0E
MVI C,00H Initialize C register
9001 00
9002 21
Load memory location with the
9003 LXI H,8000H 00
memory location 8000
9004 80
9005 MVI A,M 7E Move memory content to A
9006 INX H 23 Increment HL pair
9007 MOV B,M 46 Move data from memory to B
9008 ADD B 80 Add the content of B to A
9009 INX H 23 Increment HL pair
900A MOV B,M 46 Move data from memory to B
900B ADD B 80 Add the content of B to A
900C INX H 23 Increment HL pair
900D MOV B,M 46 Move data from memory to B
900E ADD B 80
900F INX H 23 Increment HL pair
9010 MOV B,M 46 Move data from memory to B
9011 ADD B 80
9012 INX H 23 Increment HL pair
9013 MOV B,M 46 Move data from memory to B
9014 ADD B 80 Add the content of B to A
9015 D2
9016 JNC GO 9019 19 Jump if carry is not zero
9017 90
9018 INR C 0C Increment the content of C
9019 32
Store the content of A in the
901A GO STA 8050 50
memory location 8050
901B 80
901C 79
MOV A,C Move data from C to A
901D 32
901E 32
Store the content of A in the
901F STA 8001H 01
memory location 8001
9020 80
9021 HLT 76 Stop
23
6. Then press “NEXT” and enter the HEX Code for the corresponding OPERAND
7. Repeat the steps 4 and 5 up to the end of the program.
8. Then press “NEXT”
9. Then press “RESET”
10. Then press “GO”
11. Then type the starting address of the program , i.e. 9000 in this case
12. Then press “EXECUTE”
13. Then press “RESET”
14. Then press “Exam Memory”
15. Enter the memory location assigned for the result.
16. Press “NEXT”
24
MULTIPLY TWO 8-BIT NUMBERS AND SAVE THE RESULT AND CARRY IN
TWO CONSECUTIVE MEMORY LOCATIONS:
25