Instruction Set of 8085

Instruction and Data Formats

The various techniques to specify data for instructions are:

  1. 8-bit or 16-bit data may be directly given in the instruction itself.
  2. The address of the memory location, I/O port or I/O device, where data resides, may be given in the instruction itself.
  3. In some instructions, only one register is specified. The content of the specified register is one of the operands.
  4. Some instructions specify two registers. The contents of the registers are the required data.
  5. In some instructions, data is implied. The most instructions of this type operate on the content of the accumulator.

Due to different ways of specifying data for instructions, the machine codes of all instructions are not of the same length. It may 1-byte, 2-byte or 3-byte instruction.


Addressing Modes

Each instruction requires some data on which it has to operate. There are different techniques to specify data for instructions. These techniques are called addressing modes. Intel 8085 uses the following addressing modes:

  • Direct Addressing

In this addressing mode, the address of the operand (data) is given in the instruction itself.

Example

STA 2400H: It stores the content of the accumulator in the memory location 2400H.

32, 00, 24: The above instruction in the code form.

In this instruction, 2400H is the memory address where data is to be stored. It is given in the instruction itself. The 2nd and 3rd bytes of the instruction specify the address of the memory location. Here, it is understood that the source of the data is accumulator.

  • Register Addressing

In register addressing mode, the operand is in one of the general purpose registers. The opcode specifies the address of the register(s) in addition to the operation to be performed.

Example:

MOV A, B: Move the content of B register to register A.

78: The instruction in the code form.

In the above example, MOV A, B is 78H. Besides the operation to be performed the opcode also specifies source and destination registers.

The opcode 78H can be written in binary form as 01111000. The first two bits, i.e. 0 1 are for MOV operation, the next three bits 1 1 1 are the binary code for register A, and the last three bits 000 are the binary code for register B.

  • Register Indirect Addressing

In Register Indirect mode of addressing, the address of the operand is specified by a register pair.

Example

  • LXI H, 2500 H - Load H-L pair with 2500H.
  • MOV A, M - Move the content of the memory location, whose address is in H-L pair (i.e. 2500 H) to the accumulator.
  • HLT - Halt.

In the above program the instruction MOV A, M is an example of register indirect addressing. For this instruction, the operand is in the memory. The address of the memory is not directly given in the instruction. The address of the memory resides in H-L pair and this has already been specified by an earlier instruction in the program, i.e. LXI H, 2500 H.

  • Immediate Addressing

In this addressing mode, the operand is specified within the instruction itself.

Example

LXI H, 2500 is an example of immediate addressing. 2500 is 16-bit data which is given in the instruction itself. It is to be loaded into H-L pair.

  • Implicit Addressing

There are certain instructions which operate on the content of the accumulator. Such instructions do not require the address of the operand.

Example

CMA, RAL, RAR, etc.


Status Flags

There is a set of five flip-flops which indicate status (condition) arising after the execution of arithmetic and logic instructions. These are:

  • Carry Flag (CS)
  • Parity Flag (P)
  • Auxiliary Carry Flags (AC)
  • Zero Flags (Z)
  • Sign Flags (S)

Symbols and Abbreviations

The symbol and abbreviations which have been used while explaining Intel 8085 instructions are as follows:

Symbol/AbbreviationsMeaning
Addr16-bit address of the memory location.
Data8-bit data
data 1616-bit data
r, r1, r2One of the registers A, B, C, D, E, H or L
A, B, C, D, H, L8-bit register
AAccumulator
H-LRegister pair H-L
B-CRegister pair B-C
D-ERegister pair D-E
PSWProgram Status Word
MMemory whose address is in H-L pair
HAppearing at the end of the group of digits specifies hexadecimal, e.g. 2500H
RpOne of the register pairs.
RhThe high order register of a register pair
RlThe low order register of a register pair
PC16 bit program counter, PCH is high order 8 bits and PCL low order 8 bits of register PC.
CSCarry Status
[]The contents of the register identified within bracket
[ [] ]The content of the memory location whose address is in the register pair identified within brackets
^AND operation
OR operation
⊕ or ∀Exclusive OR
Move data in the direction of arrow
Exchange contents

Intel 8085 Instructions

An instruction of a computer is a command given to the computer to perform a specified operation on given data. In microprocessor, the instruction set is the collection of the instructions that the microprocessor is designed to execute.

The programmer writes a program in assembly language using these instructions. These instructions have been classified into the following groups:

Data Transfer Group

Instructions which are used to transfer the data from a register to another register from memory to register or register to memory come under this group.

Instruction SetExplanationStatesFlagsAddre-ssingMachine CyclesExample
MOV r1, r2
[r1] ← [r2]
Move the content of the one register to another4noneRegister1MOV A, B
MOV r, M
[r]←[[H-L]]
Move the content of memory to register7noneRegister Indirect2MOV B, M
MOV M, r
[[H-L]]←[r]
Move the content of register to memory7noneRegister Indirect2MOV M, C
MVI r, data
[r] ←data
Move immediate data to register7NoneImmediate Register3MVI M, 08
LXI rp, data 16
[rp] ←data 16 bits, [rh] ←8 MSBs, [rl] ←8 LSBs of data
Load Register pair immediate10NoneImmediate3LXI H, 2500H
LDA addr
[A] ←[addr]
Load Accumulator direct13NoneDirect4LDA 2400 H
STA Addr
[addr] ←[A]
Store accumulator direct13NoneDirect4STA 2000H
LHLD addr
[L] ←[addr], [H] ← [addr + 1 ]
Load H-L pair direct16NoneDirect5LHLD 2500H
SHLD addr
[addr] ←[L], [addr +1] ← [H]
Store H-L pair direct16NoneDirect5SHLD 2500 H
LDAX rp
[A] ←[[rp]]
Load accumulator indirect7NoneRegister Indirect2LDAX B
STAX rp
[[rp]] ←[A]
Store accumulator indirect7NoneRegister Indirect2STAX D
XCHG
[H-L] ↔[D-E]
Change the contents of H-L with D-E pair4NoneRegister1

Arithmetic Group

The instructions of this group perform arithmetic operations such as addition, subtraction, increment or decrement of the content of a register or a memory.

Instruction SetExplanationStatesFlagsAddre-ssingMachine CyclesExample
ADD r
[A] ←[A]+[r]
Add register to accumulator4AllRegister1ADD K
ADD M
[A] ← [A] + [[H-L]]
Add memory to accumulator7AllRegister indirect2ADD K
ACC r
[A] ← [A] + [r] + [CS]
Add register with carry to accumulator4AllRegister1ACC K
ADC M
[A] ← [A] + [[H-L]] [CS]
Add memory with carry to accumulator7AllRegister indirect2ADC K
ADI data
[A] ← [A] + data
Add immediate data to accumulator7AllImmediate2ADI 55K
ACI data
[A] ← [A] + data + [CS]
Add with carry immediate data to accumulator7AllImmediate2ACI 55K
DAD rp
[H-L] ←[H-L] + [rp]
Add register paid to H-L pair10CSRegister3DAD K
SUB r
[A] ←[A]-[r]
Subtract register from accumulator4AllRegister1SUB K
SUB M
[A] ← [A] - [[H-L]]
Subtract memory from accumulator7ALLRegister indirect2SUB K
SBB r
[A] ←[A]-[H-L]] - [CS]
Subtract memory from accumulator with borrow7AllRegister indirect2SBB K
SUI data
[A] ←[A]-data
Subtract immediate data from accumulator7AllImmediate2SUI 55K
SBI data
[A] ←[A]-data-[CS]
Subtract immediate data from accumulator with borrow7AllImmediate2XCHG
INR r
[r] ←[r]+1
Increment register content4All except carry flagRegister1INR K
INR M
[[H-L]] ←[[H-L]]+1
Increment memory content10All except carry flagRegister indirect3INR K
DCR r
[r] ←[r] -1
Decrement register content4All except carry flagRegister1DCR K
DCR M
[[H-L]] ← [[H-L]]-1
Decrement memory content10All except carry flagRegister indirect3DCR K
INX rp
[rp] ←[rp]+1
Increment memory content6NoneRegister1INX K
DCX rp
[rp] ←[rp]-1
Decrement register pair6NoneRegister1DCX K
DAADecimal adjust accumulator41DAA

Logical Group

The instructions in this group perform logical operation such as AND, OR, compare, rotate, etc.

Instruction SetExplanationStatesFlagsAddressingMachine Cycles
ANA r
[A] ←[A]∧[r]
AND register with accumulator4AllRegister1
ANA M
[A] ←[A]∧[[H-]]
AND memory with accumulator4AllRegister indirect2
ANI data
[A] ← [A] ∧ [data]
AND immediate data with accumulator7AllImmediate2
ORA r
[A] ←[A]∨[r]
OR-register with accumulator4AllRegister1
ORA M
[A] ←[A]∨[[H-L]]
OR-memory with accumulator7AllRegister indirect2
ORI data
[A] ← [A] ∨ [data]
OR -immediate data with accumulator7AllImmediate2
XRA r [A] ← [A]∀[r]XOR register with accumulator4AllRegister1
XRA M [A] ← [A] ∀ [[H-L]]XOR memory with accumulator7AllRegister indirect2
XRI data [A] ←[A] ∀ [data]XOR immediate data with accumulator7AllImmediate2
CMA [A] ←[A]Complement the accumulator4NoneImplicit1
CMC
[CS] ←[CS]
Complement the carry status4CS1
STC
[CS] ← 1
Set carry status4CS1
CMP r
[A]-[r]
Compare register with accumulator4AllRegister1
CMP M
[A] - [[H-L]]
Compare memory with accumulator7AllRegister indirect2
CPI data
[A] - data
Compare immediate data with accumulator7AllImmediate2
RLC
[An+1] ←[An], [A0] ←[A7], [CS] ←[A7]
Rotate accumulator left4CsImplicit1
RRC
[A7] ←[A0], [CS] ←[A0], [An] ←[An+1]
Rotate accumulator rightCSImplicit1
RAL
[An+1] ←[An], [CS] ←[A7], [A0] ←[CS]
Rotate accumulator left through carryCSImplicit1
RAR
[An] ←[An+1], [CS] ←[A0], [A7] ←[CS]
Rotate accumulator right through carryCSImplicit1

Branch Control Group

This group contains the instructions for conditional and unconditional jump, subroutine call and return, and restart.

Unconditional Jump

Instruction SetExplanationStatesFlagsAddressingMachine Cycles
JMP addr(label)
[PC] ← Label
Unconditional jump: jump to the instruction specified by the address10NoneImmediate3

Conditional Jump

Instruction SetExplanationStatesMachine Cycles
Jump addr (label)
[PC] ← Label
Conditional jump: jump to the instruction specified by the address if the specified condition is fulfilled10, if true and
7, if not true
3, if true and
2, if not true
Instruction SetExplanationStatusStatesFlagsAddressingMachine Cycles
JZ addr (label) [PC] ← address (label)Jump, if the result is zeroJump if Z=17/10NoneImmediate2/3
JNZ addr (label)
[PC] ← address (label)
Jump if the result is not zeroJump if Z=07/10NoneImmediate2/3
JC addr (label)
[PC] ← address (label)
Jump if there is a carryJump if CS =17/10NoneImmediate2/3
JNC addr (label)
[PC] ← address (label)
Jump if there is no carryJump if CS =07/10NoneImmediate2/3
JP addr (label)
[PC] ← address (label)
Jump if result is plusJump if S=07/10NoneImmediate2/3
JM addr (label)
[PC] ← address (label)
Jump if result is minusJump if S=17/10NoneImmediate2/3
JPE addr (label)
[PC] ← address (label)
Jump if even parityThe parity status P =17/10NoneImmediate2/3
JPO addr (label)
[PC] ← address (label)
Jump if odd parityThe parity status P =07/10NoneImmediate2/3

Unconditional CALL

Instruction SetExplanationStatesFlagsAddressingMachine Cycles
CALL addr (label)
[SP]-1] ← [PCH] ,[[SP-2] ← [PCL], [SP] ← [SP]-2, [PC] ← addr(label)
Unconditional CALL: Call the subroutine identified by the address18NoneImmediate /register5

Conditional CALL

Instruction SetExplanationStatesMachine Cycles
CALL addr (label)
[SP]-1] ← [PCH] , [[SP-2] ← [PCL], [PC] ← addr (label), [SP] ← [SP]-2
Unconditional CALL: Call the subroutine identified by the address if the specified condition is fulfilled18, if true and
9, if not true
5, if true and
2, if not true
Instruction SetExplanationStatusStatesFlagsAddressingMachine Cycles
CC addr(label)Call subroutine if carry status CS=1CS =19/18NoneImmediate /register2/5
CNC addr (label)Call subroutine if carry status CS=0CS =09/18NoneImmediate /register2/5
CZ addr (label)Call Subroutine if the result is zeroZero status Z=19/18NoneImmediate /register2/5
CNZ addr (label)Call Subroutine if the result is not zeroZero status Z=09/18NoneImmediate /register2/5
CP addr (label)Call Subroutine if the result is plusSign status S=09/18NoneImmediate /register2/5
CM addr (label)Call Subroutine if the result is minusSign status S= 19/18NoneImmediate /register2/5
CPE addr(label)Call subroutine if even parityParity Status P=19/18NoneImmediate /register2/5
CPO addr(label)Call subroutine if odd parityParity Status P= 09/18NoneImmediate /register2/5

Unconditional Return

Instruction SetExplanationStatesFlagsAddressingMachine Cycles
RET
[PCL] ← [[SP]], [PCH] ← [[SP] + 1], [SP] ← [SP] + 2
Unconditional RET: Return from subroutine10NoneIndirect3

Conditional Return

Instruction SetExplanationStatesMachine Cycles
RET
[PCL] ← [[SP]],
[PCH] ← [[SP] + 1],
[SP] ← [SP] + 2
Conditional RET: Return from subroutine12, if true and 6, if not true3, if true and 1, if not true
Instruction SetExplanationStatusStatesFlagsAddressingMachine Cycles
RCReturn from subroutine if carry status is zero.CS =16/12NoneRegister indirect1/3
RNCReturn from subroutine if carry status is not zero.CS = 06/12NoneRegister indirect1/3
RZReturn from subroutine if result is zero.Zero status Z=16/12NoneRegister indirect1/3
RNZReturn from subroutine if result is not zero.Zero status Z= 06/12NoneRegister indirect1/3
RPReturn from subroutine if result is not plus.Sign Status S= 06/12NoneRegister indirect1/3
RMReturn from subroutine if result is not minus.Sign Status S= 06/12NoneRegister indirect1/3
RPEReturn from subroutine if even parity.Parity Status P= 16/12NoneRegister indirect1/3
RPOReturn from subroutine if odd parity.Parity Status P= 16/12NoneRegister indirect1/3

Restart

Instruction SetExplanationStatesFlagsAddressingMachine Cycles
RST
[[SP]-1] ← [PCH], [[SP]-2] ← [PCL],
[SP] ← [SP] - 2,
[PC] ← 8 times n
Restart is a one word CALL instruction.12NoneRegister Indirect3

The restart instructions and locations are as follows:

InstructionOpcodeRestart Locations
RST 0C70000
RST 1CF0008
RST 2D70010
RST 3DF0018
RST 4E70020
RST 5EF0028
RST 6F70030
RST 7FF0038

PCHL

Instruction SetExplanationStatesFlagsAddressingMachine Cycles
PCHL
[PC] ← [H-L],
[PCH] ←[H], [PCL] ←[L]
Jump address specified by H-L pair6NoneRegister1

Stack, I/O and Machine Control Group

This group contains the instructions for input/output ports, stack and machine control.

Instruction SetExplanationStatesFlagsAddressingMachine Cycles
IN port - address
[A] ← [Port]
Input to accumulator from I/O port10NoneDirect3
OUT port-address
[Port] ← [A]
Output from accumulator to I/O port10NoneDirect3
PUSH rp
[[SP] - 1] ← [rh],
[[SP] - 2] ← [rh],
[SP] ← [SP] - 2
Push the content of register pair to stack12NoneRegister(source)/register Indirect(destination)3
PUSH PSW
[SP]-1] ← [A],
[[SP] -2] ← PSW,
[SP] ← [SP] - 2
Push processor word12NoneRegister(source)/register Indirect(destination)3
POP rp
[rl] ← [ [ SP ] ],
[rh] ← [[SP]+1],
[SP] ← [SP] + 2
Pop the content of register pair, which was saved, from the stack10NoneRegister(source)/register Indirect(destination)3
HLTHalt5None1
XTHL
[L] ↔ [[SP]],
[H] ↔ [[SP] + 1]
Exchange top stack with H-L16NoneRegister indirect5
SPHL
[H-L] → [SP]
Moves the contents of H-L pair to stack pointer6NoneRegister1
EIEnable Interrupts4None1
SIMSet Interrupts Masks4None1
RIMRead Interrupts Masks4None1
NOPNo Operation4None1





Latest Courses