| ||
Comparisons are typically related to decision making. A C programmer is typically familiar with one of the following:
An index into a table is calculated by deciding between multiple factors:
index = (a < b ) ? i : j;
A comparison is used to decide which branch to take:
if (a < b ) { dothis(); } else { dothat(); }
In assembly code, comparisons actually take on multiple forms.
The general-purpose instructions set the EFLAGS/RFLAGS conditional flags to indicate their scalar result. Additional instructions would then utilize individual flags that are reset (cleared) or set, such as branching and bit shifting/rotation. The instructions utilizing packed data store the result of the comparison as packed Boolean values of 0=False and 1=True.
Since the logical AND operation has already been discussed, let us start with the TEST instruction, which has a similar functionality.