Instruction Set of 8085


Instruction Set of 8085
An instruction is a binary pattern designed inside a microprocessor to perform a specific function. The entire group of instructions, called the instruction set, determines what functions the microprocessor can perform. These instructions can be classified into the following five functional categories: data transfer (copy)  operations, arithmetic operations, logical operations, branching operations, and machine-control operations.
Data Transfer (Copy) Operations
This group of instructions copy data from a location called a source to another location called a destination, without modifying the contents of the source. In technical manuals, the term data transfer is used for this copying function. However, the term transfer is misleading; it creates the impression that the contents of the source are destroyed when, in fact, the contents are retained without any modification. The various types of data transfer (copy) are listed below together with examples of each type:


Types
Examples
1. Between Registers.
1. Copy the contents of the register B into register D.
2. Specific data byte to a register or a memory location.
2. Load register B with the data byte 32H.
3. Between a memory location and a register.
3. From a memory location 2000H to register B.
4. Between an I/O device and the accumulator.
4. From an input keyboard to the accumulator.

Table: - 8085 Data transfer instruction set summary
Opcode
Operand
Functions
Clock cycle
Number of bytes
MOV
Rd, Rs
Move register to register
4
1
MOV
M, Rs
Move register to memory
7
1
MOV
Rd, M
Move memory to register
7
1
MVI
Rd, Data
Move immediate register
7
2
MVI
M, Data
Move immediate memory
10
2
LDA
16 bit address
Load A direct
13
3
LDAX
B
Load A indirect
7
1
LDAX
D
Load A direct
7
1
LXI
B, 16 bit Data
Load immediate register Pair B & C
10
3
LXI
D, 16 bit Data
Load immediate register Pair D & E
10
3
LXI
H, 16 bit Data
Load immediate register Pair H & L
10
3
LXI
SP, 16 bit Data
Load immediate stack pointer
10
3
LHLD
16 bit address
Load H & L direct
16
3
STA
16 bit address
Load A direct
13
3
STAX
B
Store A indirect
7
1
STAX
D
Store A indirect
7
1
SHLD

Store H & L direct
16
1
XCHG

Exchange D & E H & L registers
4
1


Arithmetic Operations
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.

Table: - 8085 Arithmetic instruction set summary
Opcode
Operand
Functions
Clock cycle
Number of bytes
ADD
R
Add register to A
4
1
ADD
M
Add memory to A
7
1
ADC
R
Add register to A with carry
4
1
ADC
M
Add memory to A with carry
7
1
ADI
8-bit data
Add immediate to A
7
2
ACI
8-bit data
Add immediate to A with carry
7
2
DAD
B
Add B & C to H & L
10
1
DAD
D
Add D & E to H & L
10
1
DAD
H
Add H & L to H & L
10
1
DAD
SP
Add stack pointer to H & L
10
1
SUB
R
Subtract register from A
4
1
SUB
M
Subtract memory from A
7
1
SBB
R
Subtract register from A with borrow
4
1
SBB
M
Subtract memory from A with borrow
7
1
SUI
8-bit data
Subtract immediate from A
7
2
SBI
8-bit data
Subtract immediate from A with borrow
7
2
INR
R
Increment register
4
1
INR
M
Increment memory
10
1
INX
B
Increment B & C registers
6
1
INX
D
Increment D & E registers
6
1
INX
H
Increment H & L registers
6
1
INX
SP
Increment stack pointer
6
1
DCR
R
Decrement register
4
1
DCR
M
Decrement memory
10
1
DCX
B
Decrement B & C registers
6
1
DCX
D
Decrement D & E registers
6
1
DCX
H
Decrement H & L registers
6
1
DCX
SP
Decrement stack pointer
6
1
DAA

Decimal adjustment
4
1



Logical Operations
These instructions perform various logical operations with the contents of the accumulator.
AND, OR Exclusive-OR - Any 8-bit number, or the contents of a register, or of a memory location can be logically ANDed, Ored, or Exclusive-ORed with the contents of the accumulator. The results are stored in the accumulator.
Rotate- Each bit in the accumulator can be shifted either left or right to the next position.
Compare- Any 8-bit number, or the contents of a register, or a memory location can be compared for equality, greater than, or less than, with the contents of the accumulator.
Complement - The contents of the accumulator can be complemented. All 0s are replaced by 1s and all 1s are replaced by 0s.
Table: - 8085 Logical instruction set summary
Opcode
Operand
Functions
Clock cycle
Number of bytes
CMP
R
Compare register with A
4
1
CMP
M
Compare memory with A
7
1
CPI
8 bit data
Compare immediate with A
7
2
ANA
R
AND register with A
4
1
ANA
M
AND memory with A
7
1
ANI
8 bit data
AND immediate with A
7
2
ORA
R
OR register with A
4
1
ORA
M
OR memory with A
7
1
ORI
8 bit data
OR immediate with A
7
2
XRA
R
Exclusive OR register with A
4
1
XRA
M
Exclusive OR memory with A
7
1
XRI
8 bit data
Exclusive OR immediate with A
7
2
RLC

Rotate A left
4
1
RRC

Rotate A right
4
1
RAL

Rotate A left with carry
4
1
RAR

Rotate A right with carry
4
1
CMA

Complement A
4
1
CMC

Complement carry
4
1
STC

Set carry
4
1

Table: - 8085 Stack/PUSH and POP instructions set summary
Opcode
Operand
Functions
Clock cycle
Number of bytes
PUSH
B
Push register pair B and C on stack
12
1
PUSH
D
Push register pair D and E on stack
12
1
PUSH
H
Push register pair H and L on stack
12
1
PUSH
PSW
Push accumulator A and Flags on stack
12
1
POP
B
Pop register pair B and C off stack
10
1
POP
D
Pop register pair D and E off stack
10
1
POP
H
Pop register pair H and L off stack
10
1
POP
PSW
Pop accumulator A and Flags off stack
10
1
XTHL
Exchange top of stack H and L
16
1
SPHL
H and L to stack pointer
6
1


Branching Operations
This group of instructions alters the sequence of program execution either conditionally or unconditionally.
Jump - Conditional jumps are an important aspect of the decision-making process in the programming. These instructions test for a certain conditions (e.g., Zero or Carry flag) and alter the program sequence when the condition is met. In addition, the instruction set includes an instruction called unconditional jump.
Call, Return, and Restart - These instructions change the sequence of a program either by calling a subroutine or returning from a subroutine. The conditional Call and Return instructions also can test condition flags.
Table: - 8085 JUMP instruction set summary

Opcode
Operand
Functions
Clock cycle
Number of bytes
JMP
16-bit address
Jump unconditional
10
3
JC
16-bit address
Jump on Carry
7/10
3
JNC
16-bit address
Jump on no Carry
7/10
3
JP
16-bit address
Jump on positive
7/10
3
JM
16-bit address
Jump on minus
7/10
3
JZ
16-bit address
Jump on zero
7/10
3
JNZ
16-bit address
Jump on no zero
7/10
3
JPE
16-bit address
Jump on parity even
7/10
3
JPO
16-bit address
Jump on parity odd
7/10
3

Table: - 8085 CALL and Return instruction set summary
Opcode
Operand
Functions
Clock cycle
Number of bytes
CALL
16-bit address
Call unconditional
18
3
CC
16-bit address
Call on Carry
9/18
3
CNC
16-bit address
Call on no Carry
9/18
3
CP
16-bit address
Call on positive
9/18
3
CM
16-bit address
Call on minus
9/18
3
CZ
16-bit address
Call on zero
9/18
3
CNZ
16-bit address
Call on no zero
9/18
3
CPE
16-bit address
Call on parity even
9/18
3
CPO
16-bit address
Call on parity odd
9/18
3
RET
Return unconditional
10
1
RC
Return on Carry
6/12
1
RNC
Return on no Carry
6/12
1
RP
Return on positive
6/12
1
RM
Return on minus
6/12
1
RZ
Return on zero
6/12
2
RNZ
Return on no zero
6/12
2
RPE
Return on parity even
6/12
1
RPO
Return on parity odd
6/12
1


Machine Control Operations
These instructions control machine functions such as Halt, Interrupt, or do nothing.
Table: - 8085 I/O and machine control instructions set summary
Opcode
Operand
Functions
Clock cycle
Number of bytes
EI

Enable interrupts
4
1
DI

Disable interrupts
4
1
NOP

No-operation
4
1
HLT

Halt(Power Down)
5
1
RIM

Read interrupt mask
4
1
SIM

Set interrupt musk
4
1
IN

Input
10
1
OUT

output
10
1


The microprocessor operations related to data manipulation can be summarized in four functions:
1.      copying data
2.      performing arithmetic operations
3.      performing logical operations
4.      testing for a given condition and alerting the program sequence
Some important aspects of the instruction set are noted below:
1. In data transfer, the contents of the source are not destroyed; only the contents of the destination are changed. The data copy instructions do not affect the flags.
2. Arithmetic and Logical operations are performed with the contents of the accumulator, and the results are stored in the accumulator (with some expectations). The flags are affected according to the results.
3. Any register including the memory can be used for increment and decrement.
4. A program sequence can be changed either conditionally or by testing for a given data condition.

Comments