Embedded Systems Hardware
(ECE202)
Dr. Rohit Singh 1
8085 Syllabus
Dr. Rohit Singh 2
Introduction to 8085 Instructions
Syllabus
Dr. Rohit Singh 3
The 8085 Instructions
• The instructions of 8085 can be grouped into five different
groups:
✓ Data Transfer Instructions
✓ Arithmetic Instructions
✓ Logic Instructions
✓ Branch Instructions Syllabus
✓ Machine Control Instructions
Dr. Rohit Singh 4
The 8085 Instructions (Data Transfer Instructions)
These operations simply COPY the data from the source to the
destination.
✓ MOV: MOV Rd, Rs
✓ MVI: MVI Rd, data
Syllabus
✓ LDA: LDA 16-bit-address
✓ LDAX: LDAX Reg-pair
✓ STA: STA 16-bit-address
✓ STAX: STAX Reg-pair
Dr. Rohit Singh 5
The 8085 Instructions (Data Transfer Instructions)
✓ LXI: Reg-pair, 16-bit-data
✓ LHLD: LHLD 16-bit-address
✓ SHLD: SHLD 16-bit-address
✓ XCHG: Exchange H and L with D and E
✓ SPHL: Copy H and L register to the stack pointer
✓ XTHL: Exchange H and L with top
Syllabus
of stack
✓ PUSH: Push register pair onto stack
✓ POP: Pop off stack to register pair
✓ OUT: Output data from accumulator to a port with 8-bit address
✓ IN: Input data to accumulator from a port with 8-bit address
Dr. Rohit Singh 6
The 8085 Instructions (Arithmetic Instructions)
❖Addition (ADD, ADI, ADC, ACI, DAD):
➢ Any 8-bit number.
➢ The contents of a register.
➢ The contents of a memory location.
❖Can be added to the contents of the accumulator and the result is
Syllabus
stored in the accumulator.
Dr. Rohit Singh 7
The 8085 Instructions (Arithmetic Instructions)
❖Subtraction (SUB, SUI, SBB, SBI):
➢ Any 8-bit number.
➢ The contents of a register.
➢ The contents of a memory location.
❖Can be subtracted from the contents of the accumulator and the
Syllabus
result is stored in the accumulator.
Dr. Rohit Singh 8
The 8085 Instructions (Arithmetic Instructions)
❑Increment (INR and INX) and Decrement (DCR and DCX)
❑DAA (Decimal adjust accumulator)
❑ The contents of the 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.
Syllabus
❑ If the value of the low-order 4-bits in the accumulator is greater than 9, the
instruction adds 6 to the low-order four bits.
❑ If the value of the high-order 4-bits in the accumulator is greater than 9 or if the
Carry flag is set, the instruction adds 6 to the high-order four bits.
Dr. Rohit Singh 9
The 8085 Instructions (Branching Instructions)
JMP 16-bit-address: (Jump unconditionally) The program sequence is transferred
to the memory location specified by the 16-bit address given in the operand.
Example: JMP 2034H or JMP XYZ
Jump conditionally:
Mnemonics 16-bit-address: This will jump to the specified address if the given
condition is true.
Syllabus
Opcode Description Flag Status
JC Jump on Carry CY = 1
JNC Jump on no Carry CY = 0
JP Jump on positive S=0
JM Jump on minus S=1
JZ Jump on zero Z=1
JNZ Jump on no zero Z=0
JPE Jump on parity even P=1
JPO Jump on parity odd P=0
Dr. Rohit Singh 10
The 8085 Instructions (Branching Instructions)
CALL 16-bit-address: (Unconditional subroutine call) The program sequence is
transferred to the memory location specified by the 16-bit address given in the
operand. Before the transfer, the address of the next instruction after CALL (the
contents of the program counter) is pushed onto the stack. Example: CALL 2034H
or CALL XYZ
Call conditionally:
Mnemonics 16-bit-address: This will only transfer the program sequence to the
specified address if the given conditionSyllabus
is true.
Opcode Description Flag Status
CC Call on Carry CY = 1
CNC Call on no Carry CY = 0
CP Call on positive S=0
CM Call on minus S=1
CZ Call on zero Z=1
CNZ Call on no zero Z=0
CPE Call on parity even P=1
CPO Call on parity odd P=0
Dr. Rohit Singh 11
The 8085 Instructions (Branching Instructions)
RET : (Return from subroutine unconditionally) The program sequence is
transferred from the subroutine to the calling program. 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
Return from subroutine conditionally:
Mnemonics : This will only transfer the program sequence to the calling program if
the given condition is true.
Syllabus
Opcode Description Flag Status
RC Return on Carry CY = 1
RNC Return on no Carry CY = 0
RP Return on positive S=0
RM Return on minus S=1
RZ Return on zero Z=1
RNZ Return on no zero Z=0
RPE Return on parity even P=1
RPO Return on parity odd P=0
Dr. Rohit Singh 12
The 8085 Instructions (Branching Instructions)
PCHL: The contents of registers H and L 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: To jump to the specified interrupt vector.
Instruction Restart Address
RST 0 0000H
RST 1 0008H
RST 2 0010H
RST 3 0018H
RST 4 0020H
RST 5 0028H
RST 6 0030H
RST 7 0038H
Dr. Rohit Singh 13
The 8085 Instructions (Logical Instructions)
CMP/CPI: The register content / second byte (8-bit data) is compared with the
contents of the accumulator. The result of the comparison is shown by setting the
flags of the flag register 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
ANA/ANI: The contents of the accumulatorSyllabusare logically ANDed with the registers
content/8-bit data (operand) and the result is placed in the accumulator. S, Z, P are
modified to reflect the result of the operation. CY is reset. AC is set.
CMA: The contents of the accumulator are complemented. No flags are affected.
CMC: The Carry flag is complemented. No other flags are affected.
STC: The Carry flag is set to 1. No other flags are affected
Dr. Rohit Singh 14
The 8085 Instructions (Control Instructions)
NOP: No operation is performed.
HLT: The CPU finishes executing the current instruction and halts any further
execution. An interrupt or reset is necessary to exit from the halt state.
DI: The interrupt enable flip-flop is reset and all the interrupts except the TRAP are
Syllabus
disabled. No flags are affected.
EI: 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 flip-flop is reset, thus disabling the interrupts. This instruction is necessary to
re-enable the interrupts (except TRAP).
Dr. Rohit Singh 15
The 8085 Instructions (Control Instructions)
SIM: (Set interrupt mask) This is a multipurpose instruction and used to implement the 8085
interrupts 7.5, 6.5, 5.5, and serial data output. The instruction interprets the accumulator
contents as follows. Example: SIM
Syllabus
Dr. Rohit Singh 16
The 8085 Instructions (Control Instructions)
RIM: (Read interrupt mask) 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
Syllabus
Dr. Rohit Singh 17
Addressing modes in 8085
Addressing mode: The way of specifying data to be operated by an instruction is
called addressing mode.
Types of addressing modes:
In 8085 microprocessor there are 5 types of addressing modes:
Syllabus
1. Immediate Addressing Mode
2. Register Addressing Mode
3. Direct Addressing Mode
4. Register Indirect Addressing Mode
5. Implied/Implicit Addressing Mode
Dr. Rohit Singh 18
Addressing modes in 8085
Immediate Addressing Mode: In immediate addressing mode the source operand is always data. If the
data is 8-bit, then the instruction will be of 2 bytes, if the data is of 16-bit then the instruction will be of 3
bytes.
Examples:
MVI B, 45H (move the data 45H immediately to register B)
LXI H, 3050H (load the H-L pair with the operand 3050H immediately)
JMP 3000H (jump to the operand address immediately)
Register Addressing Mode: In register addressing mode, the data to be operated is available inside the
register(s) and register(s) is(are) operands. Therefore, the operation is performed within various registers of
the microprocessor.
Examples: Syllabus
MOV A, B (move the contents of register B to register A)
ADD B (add contents of registers A and B and store the result in register A)
INR A (increment the contents of register A by one)
Direct Addressing Mode: In direct addressing mode, the data to be operated is available inside a memory
location and that memory location is directly specified as an operand. The operand is directly available in
the instruction itself.
Examples:
LDA 2050H (load the contents of memory location into accumulator A)
LHLD 1035H (load contents of 16-bit memory location into H-L register pair)
IN 35H (read the data from port whose address is 35)
Dr. Rohit Singh 19
Addressing modes in 8085
Register Indirect Addressing Mode: In register indirect addressing mode, the data
to be operated is available inside a memory location and that memory location is
indirectly specified by a register pair.
Examples:
MOV A, M (move the contents of the memory location pointed by the H-L pair to
the accumulator)
LDAX B (move contents located by B-C register to the accumulator)
Syllabus
Implied/Implicit Addressing Mode: In implied/implicit addressing mode the
operand is hidden and the data to be operated is available in the instruction itself.
Examples:
CMA (finds and stores the 1’s complement of the contains of accumulator A in A)
RRC (rotate accumulator A right by one bit)
RLC (rotate accumulator A left by one bit)
Dr. Rohit Singh 20
8085 MICROPROCESSOR
Syllabus PROGRAMS
Dr. Rohit Singh 21
Aim: To perform addition of two 8-bit numbers using 8085
Algorithm:
1. Start the program by loading the first data into the Accumulator.
2. Move the data to a register (B register)
3. Get the second data and load into Accumulator.
4. Add the two register contents.
5. Check for carry.
Syllabus
6. Store the value of sum and carry in memory location.
7. Terminate the program.
Content Memory Location
First data 2000H
Second data 2001H
Store sum 2002H
Store carry 2003H
Dr. Rohit Singh 22
Program: To perform addition of two 8-bit
numbers using 8085
MVI C, 00H
LDA 2000H
MOV B, A
LDA 2001H
ADD B
JNC LOOP
INR C
LOOP: STA 2002H
MOV A, C
STA 2003H
HLT
Dr. Rohit Singh 23
Aim: To perform subtraction of two 8-bit numbers using 8085
Algorithm:
1. Start the program by loading the first data into the Accumulator.
2. Move the data to a register (B register)
3. Get the second data and load into Accumulator.
4. Subtract the two register contents.
5. Check for barrow.
Syllabus
6. If barrow is present, take 2’s complement of Accumulator.
7. Store the value of difference and borrow in memory location.
8. Terminate the program.
Content Memory Location
First data 2000H
Second data 2001H
Store difference 2002H
Store borrow 2003H
Dr. Rohit Singh 24
Program: To perform subtraction of two 8-bit
numbers using 8085
MVI C, 00H
LDA 2000H
MOV B, A
LDA 2001H
SUB B
JNC LOOP
CMA
INR A
INR C
LOOP: STA 2002H
MOV A, C
STA 2003H
HLT
Dr. Rohit Singh 25
Aim: To perform multiplication of two 8-bit numbers using 8085
Algorithm:
1. Start the program by loading HL register pair with address of memory
location.
2. Move the data to a register (B register)
3. Get the second data and load into Accumulator.
4. Add the two register contents.
Syllabus
5. Check for carry.
6. Increment the value of carry.
7. Check whether repeated addition is over and store the value of product and
carry in memory location.
8. Terminate the program.
Dr. Rohit Singh 26
Program: To perform multiplication of two 8-bit numbers using 8085
MVI D, 00H
MVI A, 00H
LXI H, 2000H
MOV B, M
INX H
MOV C, M
LOOP: ADD B
JNC NEXT
INR D
NEXT: DCR C
JNZ LOOP
STA 2002H
MOV A, D
STA 2003H
HLT
Dr. Rohit Singh 27
Syllabus
Dr. Rohit Singh 28