8086 CMP Instruction Edit
CMP is a logical instruction which compares the desticaion and the source. It compares a byte or word in the specified source with a byte or word in the destination. The destination can be a register or a memory location but the source and the destination cannot both be memory locations. This instruction will not affect the source and destination, only the flags are set to indicate the results of the comparison. AF, OF, SF, ZF, PF, and CF are updated by the CMP instruction.
Types of operands supported
Instruction Operands ---------------------------- CMP REG, memory memory, REG REG, REG memory, immediate REG, immediate
result is not stored anywhere, flags are set (OF, SF, ZF, AF, PF, CF) according to the result.
If you compare CX with BX. Depending on the value of CX and BX the below flags will be set
CF ZF SF CX = BX 0 1 0 Result of subtraction is 0 CX > BX 0 0 0 No borrow required, so CF = 0 CX < BX 1 0 1 Subtraction requires borrow, so CF = 1