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 1=True.

Since the logical AND operation has already been discussed, let us start with the TEST instruction, which has a similar functionality.

32.64-Bit 80X86 Assembly Language Architecture
32/64-Bit 80x86 Assembly Language Architecture
ISBN: 1598220020
EAN: 2147483647
Year: 2003
Pages: 191

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: