Compare with memory
The contents of the memory of the memory location pointed by HL register pair are compared with the contents of the accumulator. The instruction format is
CMP M (A- [ HL])
The contents of the both the operand memory location and the accumulator do not change. The flags are modified similar to subtraction.
Flags : All flags are modified but he conclusion can be made only by CY and Z flag as shown below.
If A> M : CUY and Z flag are reset
IF a = M : Z flag is set and CY flag is reset.
IF A < M : CY is set and Z flag is reset.