05 - Instruction Set of 8085 and Questions
05 - Instruction Set of 8085 and Questions
Gaurav Trivedi
EE Department
IIT Guwahati
[email protected]
Instruction Set of 8085
An instruction is a binary pattern designed inside a
microprocessor to perform a specific function.
Arithmetic Instructions
Logical Instructions
Branching Instructions
Control Instructions
Data Transfer Instructions
These instructions move data between registers, or
between memory and registers.
Example: LDAX B
Data Transfer Instructions
Opcode Operand Description
LXI Reg. pair, 16-bit Load register pair immediate
data
Example: STAX B
Data Transfer Instructions
Opcode Operand Description
SHLD 16-bit address Store H-L registers direct
Example: XCHG
Data Transfer Instructions
Opcode Operand Description
SPHL None Copy H-L pair to the Stack Pointer (SP)
Example: SPHL
Data Transfer Instructions
Opcode Operand Description
XTHL None Exchange H–L with top of stack
Example: XTHL
Data Transfer Instructions
Opcode Operand Description
PCHL None Load program counter with H-L contents
Example: PCHL
Data Transfer Instructions
Opcode Operand Description
PUSH Reg. pair Push register pair onto stack
Example: PUSH B
Data Transfer Instructions
Opcode Operand Description
POP Reg. pair Pop stack to register pair
Example: POP H
Data Transfer Instructions
Opcode Operand Description
OUT 8-bit port Copy data from accumulator to a port with 8-
address bit address
Example: OUT 78 H
Data Transfer Instructions
Opcode Operand Description
IN 8-bit port Copy data to accumulator from a port with 8-
address bit address
Example: IN 8C H
Arithmetic Instructions
These instructions perform the operations like:
Addition
Subtract
Increment
Decrement
Addition
Any 8-bit number, or the contents of register, or the
contents of memory location can be added to the
contents of accumulator.
The contents of register or memory and Carry Flag (CY) are added to
the contents of accumulator.
Example: ADI 45 H
Arithmetic Instructions
Opcode Operand Description
ACI 8-bit data Add immediate to accumulator with carry
The 8-bit data and the Carry Flag (CY) are added to the
contents of accumulator.
Example: ACI 45 H
Arithmetic Instructions
Opcode Operand Description
DAD Reg. pair Add register pair to H-L pair
Example: DAD B
Arithmetic Instructions
Opcode Operand Description
SUB R Subtract register or memory from accumulator
M
The contents of the register or memory location and Borrow Flag (i.e.
CY) are subtracted from the contents of the accumulator.
Example: SUI 45 H
Arithmetic Instructions
Opcode Operand Description
SBI 8-bit data Subtract immediate from accumulator with
borrow
The 8-bit data and the Borrow Flag (i.e. CY) is subtracted
from the contents of the accumulator.
Example: SBI 45 H
Arithmetic Instructions
Opcode Operand Description
INR R Increment register or memory by 1
M
Example: INX H
Arithmetic Instructions
Opcode Operand Description
DCR R Decrement register or memory by 1
M
Example: DCX H
Logical Instructions
These instructions perform logical operations on data
stored in registers, memory and status flags.
AND operation
OR operation
XOR operation
Equality
Greater Than
Less Than
The contents of the accumulator are logically ANDed with the contents
of register or memory.
The result is placed in the accumulator.
If the operand is a memory location, its address is specified by the
contents of H-L pair.
S, Z, P are modified to reflect the result of the operation.
CY is reset and AC is set.
Example: ANA B or ANA M.
Logical Instructions
Opcode Operand Description
ANI 8-bit data Logical AND immediate with accumulator
The contents of the accumulator are XORed with the contents of the register or memory.
If the operand is a memory location, its address is specified by the contents of H-L pair.
The contents of the accumulator are logically ORed with the contents of the register or
memory.
If the operand is a memory location, its address is specified by the contents of H-L pair.
RST 1 0008 H
RST 2 0010 H
RST 3 0018 H
RST 4 0020 H
RST 5 0028 H
RST 6 0030 H
RST 7 0038 H
Control Instructions
The control instructions control the operation of
microprocessor.
Control Instructions
Opcode Operand Description
NOP None No operation
No operation is performed.
The instruction is fetched and decoded but no
operation is executed.
Example: NOP
Control Instructions
Opcode Operand Description
HLT None Halt
LDA n
i=n
MOV B, A
XRA A
Loop: ADD B sum = A A = 0
DCR B sum = sum + i
JNZ Loop i=i-1
STA total
IF i 0 THEN GOTO Loop
total = sum
Programming
1. Write an assembly program to add two numbers
MVI D, 02BH
MVI C, 06FH
MOV A, C
ADD D
STA 4500
HLT
1. Write an assembly program to add two numbers
LXI H, 4500
MOV A, M
INX H
ADD M
STA 4500
HLT
2. Write an Assembly Language Program to add two
numbers ; results contain carry
LXI H, 4500
MOV A, M
INX H
ADD M
JNC LOOP 1
INR C
LOOP1 STA 4500
MOV A, C
STA 4501
HLT
2. Write an Assembly Language Program to add two
numbers ; results contain carry ( write the program
using JC)
LXI H, 4500
MOV A, M
INX H
ADD M
JC LOOP 1
JMP LOOP 2
LOOP1 INR C
STA 4500
LOOP1 MOV A, C
STA 4501
HLT
3. To write an assembly language program for adding two 16
bit numbers using 8085 micro processor.
4. To write an assembly language program to calculate
the sum of datas using 8085 microprocessor
5. To write a assembly language program for subtracting 2 bit
(8) numbers by using- 8085
6. To write an assembly language program for subtracting two
16 bit numbers using 8085 microprocessor kit.
Multiplication ; No carry
LDA 2000 // Load multiplicant to accumulator
MOV B,A // Move multiplicant from A(acc) to B register
LDA 2001 // Load multiplier to accumulator
MOV C,A // Move multiplier from A to C
MVI A,00 // Load immediate value 00 to a
L: ADD B // Add B(multiplier) with A
DCR C // Decrement C, it act as a counter
JNZ L // Jump to L if C reaches 0
STA 2010 // Store result in to memory
HLT // End
Multiplication ; With carry
7. Write an assembly program to multiply a
number by 8
MVI C,OO
LXI H, 4100
MOV B, M
INX H
MOV A, M
DCR B
LOOP 2ADD M
JNC LOOP1
INR C
LOOP 1 DCR B
JNZ LOOP2
STA 4500
HLT
8. Multiplication
9. To write an assembly language program for dividing two 8 bit
numbers using microprocessor
10. To write a program to sort given ‘n’ numbers in ascending order
11. To write a program to sort given ‘n’ numbers in
descending order
12. Write an Assembly Language Program to transfer a
block of data from a series of locations to other.
LXI H, 4500
MOV A, M
INX H
CMP M
JNC LOOP 1
JMP LOOP 2
LOOP1 STA 4500
LOOP2 MOV A, M
STA 4500
HLT
15. Write an Assembly Language Program to find a
smallest number.
LXI H, 4500
MOV A, M
INX H
CMP M
JC LOOP 1
JMP LOOP 2
LOOP1 STA 4500
LOOP2 MOV A, M
STA 4500
HLT
Homework Assignment
1. Write an Assembly Language Program to
count the repetition of a number.