Chapter 9. Comparison

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 ...

Get 32/64-Bit 80x86 Assembly Language Architecture now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.