A microprocessor can perform all the logic functions of the hard-wired logic through its instruction set. These instructions include:
- AND
- OR
- Exclusive-OR
- Compare
- Rotate Bits
All logic operations are performed in relation to the contents of the accumulator. The complete list of logical instructions in 8085 is described in the following table.
Mnemonic | Description | Example |
---|---|---|
ANA R | This is a 1-byte instruction. Logically ANDs the contents of the register R with the contents of the accumulator. 8085: CY is reset and AC is set |
ANA B |
ANI 8-bit | This is a 2-byte instruction. Logically ANDs the second byte with the contents of the accumulator. 8085: CY is reset and AC is set. |
ANI 2FH |
ANA M | Logically AND the contents of the memory with the contents of A. | ANA M |
ORA R | This is a 1-byte instruction. Logically ORS the contents of the register R with the contents of the accumulator |
ORA B |
ORI 8-bit | This is a 2-byte instruction. Logically ORS the second byte with the contents of the accumulator. |
ORI 37H |
ORA M | Logically OR the contents of the memory with the contents of A. | ORA M |
XRA R | This is a I-byte instruction. Exclusive-ORs the contents of register R with the contents of the accumulator. |
XRA B |
XRI 8-bit | This is a 2-byte instruction. Exclusive-ORs the second byte with the contents of the accumulator. |
XRI 6AH |
XRA M | Exclusive OR the contents of the memory with the contents of A. | XRA M |
CMP R | Compare the contents of register with the contents of A for less than, or equal to, or greater than. | CMP B |
CPI 8-bit | Compare 8-bit data with the contents of register with the contents of A for less than, or equal to, or greater than. | CPI 4FH |
CMA | This is an I-byte instruction that complements the contents of the accumulator No flags are affected |
CMA |
RLC | Rotate Accumulator left by one position. | |
RRC | Rotate Accumulator right by one position. | |
RAL | Rotate Accumulator left by one position through carry flag. | |
RAR | Rotate Accumulator right by one position through carry flag. |
The logic instructions:
- Assume implicitly that the accumulator is one of the operands.
- Reset (clear) the CY flag. The instruction CMA is an exception; it has no effect on any flags.
- Modify the Z, P, and S flags based on the result’s data conditions.
- Store the result into the accumulator.
- Do not change the operand register’s contents.