7.7 Introduction to Decisions

In its most basic form, a decision is some sort of branch within the code that switches between two possible execution paths based on some condition. Normally (though not always), conditional instruction sequences are implemented with the conditional jump instructions. Conditional instructions correspond to the if..then..endif statement in HLA:

if( expression ) then
          << statements >>
     endif;

Assembly language, as usual, offers much more flexibility when dealing with conditional statements. Consider the following C/C++ statement:

if( (( x < y ) && ( z > t )) || ( a != b ) )
          stmt1;

A "brute force" approach to converting this statement into assembly language might produce the following:

mov( x, eax ); cmp( eax, y ); setl( bl ...

Get The Art of Assembly Language, 2nd Edition 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.