How should I write such an if statement in assembly?
if ((a == b AND a > c) OR c == b) { ...
Platform: Intel 32-bit machine, NASM syntax.
Update
For variable types and value, use whatever is more easy to understand. Integers would works fine for me, I guess.
For a simple expression with no side effects (such as the one given), the order of evaluation does not matter(1). That means you can check the "quick" cases first (those that decide with least code executed,
c == bin this case).In generic assembly, it will be basically something like this (assume
ainax,binbx,cincx):If there’s no false bit, it can be simplified to something like:
(1) If the expression contained side-effects then order of evaluation may become important due to the possibility of short-circuiting evaluations. By that, I mean consider an expression such as (pseudo-code):
In that case, once you establish that
aandbare equal, there is no need to comparecandd.I haven’t covered that (other than in this footnote) since:
no source language was specified in the question (making it unclear whether it even has short-circuiting operations); and
the expression appears to have no side effects anyway.