8085 Instruction Set and Programming
8085 Instruction Set and Programming
c) Three-Byte Instructions
In a three-byte instruction, the first byte specifies the opcode, and the following
two bytes specify the 16-bit address. Note that the second byte is the low-order
address and the third byte is the high-order address. (opcode + data byte + data
byte)
Example-1:
Load contents of memory 2050H in the accumulator.
Mnemonic- LDA 2050H
Opcode- LDA
Operand- 2050H
Hex Code- 3A 50 20
Example-2:
Transfer the program sequence to the memory location 2050H.
Mnemonic- JMP 2085H
Opcode- JMP
Operand- 2085H
Hex Code- C3 85 20
LHLD 16-bit Load H and L The instruction copies the contents of the
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: LHLD
2040H
SHLD 16-bit Store H and L The contents of register L are stored into
address 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.
Example: SHLD 2470H
LXI Reg. pair, Load register The instruction loads 16-bit data in the
16-bit data pair immediate register pair designated in the operand.
Example: LXI H, 2034H or LXI H, XYZ
XCHG none Exchange H and L The contents of register H are exchanged
with D and E with the contents of register D, and the
contents of register L are exchanged with
the contents of register E. Example:
XCHG
b) Arithmetic Instructions
These instructions perform arithmetic operations such as addition,
subtraction, increment and decrement.
Addition - Any 8-bit number, or the contents of a register or the contents of a
memory location can be added to the contents of the accumulator and the sum is
stored in the accumulator. No two other 8-bit registers can be added directly
(e.g., the contents of register B cannot be added directly to the contents of the
register C). The instruction DAD is an exception; it adds 16-
bit data directly in register pairs.
Subtraction - Any 8-bit number, or the contents of a register, or the contents of
a memory location can be subtracted from the contents of the accumulator and
the results stored in the accumulator. The subtraction is performed in 2's
compliment and the results if negative, are expressed in 2's complement. No two
other registers can be subtracted directly.
Increment/Decrement - The 8-bit contents of a register or a memory location
can be incremented or decrement by 1. Similarly, the 16-bit contents of a register
pair (such as BC) can be incremented or decrement by 1. These increment and
decrement operations differ from addition and subtraction in an important way;
i.e., they can be performed in any one of the registers or in a memory location.
d) Branch instructions
RETURN Instructions
The return instruction transfers the program sequence from the subroutine
to the calling program. Before transferring, the address of the main
program popped from the stack to PC.
Return instructions are two types:
Unconditional Return Instructions
Conditional Return Instructions.
(i) Unconditional Return Instructions:
It transfers the program sequence unconditionally from the subroutine to
the calling program.
OPCODE OPERAND EXPLANATION EXAMPLE
RET none Return from the subroutine RET
unconditionally
(ii) Conditional Return Instructions:
The program sequence is transferred from the subroutine to the calling
program when condition is satisfied.
MVI A, 16H
MVI B, D2H
ADD B
STA 3015H
HLT
Flowchart
Program
Flowchart
4. Write an 8085 program to find the smallest number.
Flowchart
5. Write an 8085 program to find the largest number.
Flowchart
6. Write an 8085 Assembly language program to sort numbers in ascending
order.
Flowchart
7. Write an 8085 Assembly language program to sort numbers in
descending order.
DCX H
MOV M,B
INX H