Generally, when it is required to compare numeric values CMP
instruction is used (it does the same as SUB (subtract) instruction, but
does not keep the result, just affects the flags).
The logic is very simple, for example:
it's required to compare 5 and 2,
5 - 2 = 3
the result is not zero (Zero Flag is set to 0).
Another example:
it's required to compare 7 and 7,
7 - 7 = 0