O'Reilly logo

32/64-Bit 80x86 Assembly Language Architecture by James Leiterman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required