16 bit Assembly
Home Site Map Instruction Index
The CMP instruction compares the second operand to the first operand.
When called this instruction sets the flags to indicate the result of the comparison.
This command has 3 parts, Instruction, Register, then either a Register, Immediate value, or a memory address.
Additional instructions can be used to compare data at both SI and DI addresses with each other.
SI and DI are incremented or decremented depending on the direction flag.
Assembly Sample | Description | 16 bit Machine Code |
---|---|---|
CMP AX, 0x00F2 | ; Compare an immediate number to a Register | 3D F2 00 |
CMP AH, AL | ; Compare two 8 bit Registers | 3A C4 |
CMP BX, AX | ; Compare two 16 bit Registers | 3B C3 |
CMP [BX], AX | ; Compare a Register with a memory address | 39 07 |
CMP AX, [BX] | ; Compare a memory address with a Register | 3B 07 |