Instructions to perform compare operation in 8085 Microprocessor

Microprocessor8085

In 8085 Instruction set,we are having a set of instructions to perform compare operation where we shall compare two operands, and which will affect the status flags values depending on the result of the comparison. In this operation, 8085 imposes the restriction that one of the operands must be in the Accumulator. The other operand can be one of the following –

Classifications
Examples
The other operand can be kept in 8-bit immediate data in the instruction.
CPI 43H
CPI FFH
The other 8-bit operand can be kept in a memory location and whose memory address will be pointed by HL register pair.
CMP M


The other 8-bit operand can be kept in a 8-bit register
CMP B
CMP C


The compare instruction actually computes subtraction of the values of the Accumulator contents and the other operand. But after computation, the original values of the operands are not getting changed. The result is stored in a register that is not accessible to the programmer. Based on the result, all the flag bits are affected.

When we compare two data say Data 1 and Data 2. Then as outcome of the comparison operation we can have any one of the three possible results – 

  • Data 1 is greater than Data 2

  • Data 2 is greater than Data 1 and

  • Data 1 and Data 2 are having same values

Here is the list of possible mnemonics falling in this category –

Mnemonics,Operand
Opcode(in HEX)
Bytes
CMP A
BF
1
CMP B
B8
1
CMP C
B9
1
CMP D
BA
1
CMP E
BB
1
CMP H
BC
1
CMP L
BD
1
CMP M
BD
1
CPI Data
FE
2


raja
Published on 27-Dec-2018 10:28:01
Advertisements