8085 Instructions
8085 Instructions
8-bit
CPI Compare immediate with accumulator
data
8-bit
ANI Logical AND immediate with accumulator
data
8-bit
ORI Logical OR immediate with accumulator
data
8-bit
XRI XOR immediate with accumulator
data
1) CMP instruction:
Register 1 All 1 4
Memory 1 All 2 7
2) CPI instruction:
It is similar to CMP instruction with the difference that the 8-bit data is
directly given with the instruction. In this instruction the given data is
compared with the accumulator contents. The flags will be modified as per
the result.
3) ANA instruction:
The ANA reg/M instruction clears (resets) the CY flag and all other flags
are modified according to the data conditions of the result. This instruction is
one byte instruction. The possible combinations of this instruction are as
given below:
ANA reg (AND Register)
ANA M (AND Memory)
For example A = 73 H, C = C3 H, CY = 1,
ANA C
Register 1 All,CY=0,AC=1 1 4
Memory 1 All,CY=0,AC=1 2 7
4) ANI instruction:
In this instruction each bit of the given 8-bit data is immediately ANDed
with each bit of the accumulator contents (bit by bit). The result is stored in
the accumulator. The difference between ANA reg and ANI data instruction is
that in ANA reg the data given in the register where as in the ANI data
instruction, the data is given with the instruction itself.
ANI 06H
5) ORA instruction:
The ORA reg/M instruction clears (resets) the CY flag and all other flags
are modified according to the data conditions of the result. This instruction is
one byte instruction. The possible combinations of this instruction are as
given below:
ORA reg (OR Register)
ORA M (OR Memory)
For example A = 73 H, C = C3 H, CY = 1,
ORA C
Register 1 All,CY=0,AC=0 1 4
Memory 1 All,CY=0,AC=0 2 7
6) ORI instruction:
In this instruction each bit of the given 8-bit data is immediately ORed
with each bit of the accumulator contents (bit by bit). The result is stored in
the accumulator. The carry flag will be reset after the execution of this
instruction and other flags will be affected as per the result.
For example A = AB H, CY = 1,
ORI 16H
after the execution of the instruction ORI 16H we get the CY = 0,A = BF
H.
7) XRA instruction:
The XRA reg/M instruction clears (resets) the CY flag and all other flags
are modified according to the data conditions of the result. This instruction is
one byte instruction. The possible combinations of this instruction are as
given below:
XRA reg (Exclusive OR Register)
XRA M (Exclusive OR Memory)
For example A = 19 H, H = 22 H, L = 00 H, M2200 = 37 H and CY = 1,
XRA M
after the execution of the instruction XRA M we get the CY = 0,A = 2E
H.
Register 1 All,CY=0,AC=0 1 4
Memory 1 All,CY=0,AC=0 2 7
8) XRI instruction:
In this instruction each bit of the given 8-bit data is immediately XORed
with each bit of the accumulator contents (bit by bit). The result is stored in
the accumulator. The carry flag will be reset after the execution of this
instruction and other flags will be affected as per the result.
For example A = AB H, CY = 1,
XRI 12H
after the execution of the instruction XRI 12H we get the CY = 0,A = B9
H.
9) RLC instruction:
[An+1] < - [An] , [A0] < - [A7] also [CY] < - [A7]
For example A = AE H, CY = 0,
RLC
MSB is saved in CY flag and also in the LSB of the accumulator. The other bits
are shifted left as shown in figure
None 1 Only CY 1 4
For example A = 93 H, CY = 0,
RRC
LSB is saved in CY flag and also in the MSB of the accumulator. The other bits
are shifted left as shown in figure
None 1 Only CY 1 4
For example A = 6A H, CY = 1,
RAL
None 1 Only CY 1 4
For example A = 76 H, CY = 1,
RAR
after the execution of the instruction RAR we get the A = BB H, CY = 0.
For example, if A = 0B H,
CMA
None 1 None 1 4
None 1 Only CY 1 4
This is mnemonic for Set the carry.It sets the carry flag.
The carry flag will be set (CY = 1) irrespective of the carry flag is set or
reset before the execution of this instruction STC.Only carry flag gets affected
with this instruction.
BRANCHING INSTRUCTIONS
instructions, which are used to for conditional and unconditional jump,
subroutine call and return and restart. The branching instruction alter the
normal sequential flow.
1) JMP instruction:
True 3 None 3 10
1) JNZ instruction:
In this case the address (or label) is copied in the program counter if
zero flag is reset (Z = 0).
For example,
Label Mnemonics Operand
----
----
DCR C
JNZ NEXT
MOV A,M
NEXT STA 2500H
HLT
2) JZ instruction:
The address of the label will be copied in the program counter if Z flag
is set (or result is zero).
3) JC instruction:
In this case the address of the label will be copied in the program
counter if CY = 1 or CY is set.
4) JNC instruction:
This is mnemonic for Jump if no carry.During the execution of this
instruction, it will check up the Carry flag modified by the preceding
instruction. If there is no carry (CY = 0 or CY flag is reset), the program will
jump to the instruction specified by the address (or label) otherwise it will
proceed to the next instruction of the normal sequence.
In this case the address of the label will be copied in the program
counter if CY = 0 or CY is reset.
5) JP instruction:
6) JM instruction:
7) JPE instruction:
This is mnemonic for Jump if Parity is Even.If the parity is even or parity
flag is set (P = 1) as a result of the preceding instruction, the program will jump
to the instruction specified by the address (label) otherwise next instruction
of the normal sequence will be executed.
This is mnemonic for Jump if Parity is Odd.If the parity is odd or parity
flag is reset (P = 0) as a result of the preceding instruction, the program will
jump to the instruction specified by the address (label) otherwise next
instruction of the normal sequence will be executed.
ARITHMETIC INSTRUCTION
R
ADD Add register or memory to accumulator
M
Register
DAD Add register pair to H-L pair
pair
R
INR Increment register or memory by 1
M
Register
INX Increment register pair by 1
pair
R
DCR Decrement register or memory by 1
M
Register
DCX Decrement register pair by 1
pair
1) ADD instruction:
where reg = A, B, C, D, E, H or L
It adds the content stored in given register with the accumulator. The
result of this addition is stored in accumulator.All the flags are affected with
this instruction. For example A = 10101111(AF H), E = 10110101(B5 H), CY = 0
, S = 1, Z = 0 and P = 1,
ADD E
(ii) ADD M
It adds the content of memory location whose address is given in H-L
register pair with the accumulator and the answer is stored in accumulator.
For example A = 40 H H = 21 H L = 00 H, M2100 = 3A H
ADD M
Register 1 All 1 4
Memory 1 All 2 7
2) ADC instruction:
This is mnemonic for Add with carry. It adds the content stored in given
register or memory location whose address is given in H-L register pair and
content of CY flag with the content of accumulator. The result of this addition
is stored in accumulator. All the flags are affected with this instruction
ADC M
after execution of the instruction ADC M will produce the result:A = 8C.
Register 1 All 1 4
Memory 1 All 2 7
3) ADI instruction:
This is mnemonic for Adds immediately the data. It immediately adds
the given 8-bit data with the accumulator and the answer will be stored in
Accumulator.This is a two-byte instruction. All flags will be affected with this
instruction.
For example A = 50 H, after execution of ADI 3AH will produce the result:A =
8A H.
4) ACI instruction:
For example A = 50 H,CY = 1 after execution of ACI 3AH will produce the
result:A = 8B H. if CY = 0 then result: 8A H.
5) DAD instruction:
where rp = BC,DE,HL
This is mnemonic for Double Add. This instruction adds the contents of
given register pair with the contents of H-L register pair. The answer will be
stored in H-L register pair. Only carry flag will be affected in this instruction.
For example D = 2A H, E = B6 H, H = 01 H, L = 27 H,
DAD D
6) SUB instruction:
where reg = A, B, C, D, E, H or L
SUB D
(ii) SUB M
This instruction is one byte instruction and subtracts the contents of
memory location whose address is given in H-L register pair from the
accumulator and the answer is stored in accumulator.
SUB M
Register 1 All 1 4
Memory 1 All 2 7
7) SBB instruction:
SBB H
Register 1 All 1 4
Memory 1 All 2 7
8) SUI instruction:
For example A = 50 H,
SUI 45H
after the execution of the instruction SUI 45H we get the A = 05H.
9) SBI instruction:
SBI data instruction subtracts the given 8-bit data with borrow bit (carry
flag) from the accumulator contents and it stores the answer in
accumulator.The Carry flag is set, when the unsigned value subtracted is
greater than the unsigned value it is subtracted from.
SBI 45H
after the execution of the instruction SBI 45H if CY = 0 then we get the
A = 05H.if CY = 1 then A = 04H.
[A] < - [A] - [8-bit data] - [CY]
For example H = 22 H,
INR H
Register 1 All,except CY 1 4
Memory 1 All,except CY 3 10
For example H = 21 H, L = 02 H,
INX H
For example H = 22 H,
DCR H
Register 1 All,except CY 1 4
Memory 1 All,except CY 3 10
DCX instruction:
DCX rp instruction decrements the contents given in register pair by
one and the result is stored in the given register pair.No flag is affected with
the execution of this instruction.
where rp = BC,DE,HL
For example H = 21 H, L = 02 H,
DCX H
after the execution of the instruction DCX H we get the H = 21 H, L =
01H.
A = 38 H, 0 0 1 1 1 0 0 0
Adds 87 H, 1 0 0 0 0 1 1 1
----------------------------------
1 0 1 1 1 1 1 1 Lower 4-bits
0 0 0 0 0 1 1 0 is > 9
Rd,Data
MVI Move immediate 8-bit
M,Data
1) MOV instruction:
This instruction copies the contents of the source register into the
destination register. The contents of the source register are not altered.If one
of the operands is a memory location, its location is specified by the contents
of the HL registers.These instructions are of one byte instruction and no flag
is affected in these instructions.
where reg = A, B, C, D, E, H or L
This instruction is moves / copies the data in the given register to the given
register.
i.e
This instruction is indirect read instruction. It moves / copies the data stored
in memory location whose address is given in H-L register pair, to the given
register.
i.e
This instruction moves / copies the data in the given register to the memory
location addressed by H-L register pair.
i.e
[MHL] < - [reg]
Rd,Rs 1 None 1 4
Rd,M 1 None 2 7
M,Rs 1 None 2 7
2) MVI instruction:
This an instruction to load register with 8-bit value. This instruction uses
immediate addressing for specifying the data.If the operand is a memory
location, its location is specified by the contents of the H-L registers.These
instructions are two byte instructions and no flag is affected.
This instruction transfers the given data to the memory location pointed by
H-L pair.
i.e
MVI M,2B
Rd,data 2 None 2 7
M,data 2 None 3 10
3) LDA instruction:
LDA 2500H
instruction, then after the execution of this instruction, the data 2AH
will be transferred to accumulator.
4) LDAX instruction:
This is mnemonic for Loads the Accumulator Indirect. the contents
already stored in the memory location addressed by the register pair (rp).
Here rp represents B-C or D-E register pair.
LDAX B
LDAX D
5) LXI instruction:
where rp = BC,DE,HL
LXI H,F850H
Operand Bytes Flags Affected M-Cycles T-States
6) LHLD instruction:
This is mnemonic for Loads the H-L pair direct.This instruction loads the
H-L pair direct with two bytes already stored in two consecutive memory
locations starting at the specified memory address. The contents stored in the
memory location whose address is given with the instruction will be loaded
to the L-register; and the contents stored in the next memory location
(address + 1) will be loaded to the H-register.
LHLD 2100 H
after the execution of the instruction LHLD 2100 H , the L-register will have
2A H and H-register will have 2B H.
7) STA instruction:
16H data is stored in the accumulator before the execution of STA 2100H
instruction
STA 2100 H
after the execution of this instruction, the data 16H will be transferred
to the addressed memory location.
8) STAX instruction:
STAX B
STAX D
STAX B
9) SHLD instruction:
This is mnemonic for Stores the H-L pair direct.This instruction does the
reverse operation of LHLD. The instruction SHLD address stores the contents
of L-register to memory location whose address is given with the instruction;
and the contents of H-register are stored in the next consecutive memory
location (address + 1).
SHLD 2200 H
[M2200H] < - 3A
[M2201H] < - 3B
This is mnemonic for Exchange the contents of H-L register with D-E
register.This is one byte instruction and no operand is needed with it. It
exchanges the contents of H and L register with D and E registers respectively.
XCHG
None 1 None 1 4
SPHL
[SP] < - > [HL] i.e. [SPH] < - > [H] and [SPL] < - > [L]
None 1 None 1 6
PCHL
[PC] < - > [HL] i.e. [PCH] < - > [H] and [PCL] < - > [L]
None 1 None 1 6
-----------------------------
1 1 0 0 0 1 0 1 AC = 1
0 1 1 0 0 0 0 0 Upper 4-bits
---------------------------------- is > 9
100100101
A = 38 H, 0 0 1 1 1 0 0 0
Adds 87 H, 1 0 0 0 0 1 1 1
----------------------------------
1 0 1 1 1 1 1 1 Lower 4-bits
0 0 0 0 0 1 1 0 is > 9
----------------------------------
1 1 0 0 0 1 0 1 AC = 1
0 1 1 0 0 0 0 0 Upper 4-bits
---------------------------------- is > 9
100100101