Question: what is the difference between cmp and sub instructions?
Answer: The main difference between cmp and sub is that cmp does not store the result of the subtract operation; it performs subtraction only to set the status flags. Similarly, two registers can be compared to see if they both have the same value.