Assembly Language Programming 7
Compare
The 'Compare' Instruction is
CMP destination,source
This instruction 'pretends' to subtract the source from the destination, and sets the flags as if it had done so, but does not in fact alter the number in the register.
Example
| MOV | AL,65 |
| CMP | AL,65 |
This program would set the Zero flag
Another Example.
A program which inputs a sequence of characters, until the 'Enter' key is pressed.
| MOV | AH,1 | {Initialise interrupt for Input} | |
| @loop | INT | 21H | {Input a character into AL} |
| CMP | AL,13 | {Is character a carriage return?} | |
| JNZ | @loop | {If not, then go and input another} |