Instructions II

Learn about different modes like conditional jumps, register structures, return values, and byte registers.

Conditional jumps

Consider these two C/C++ code fragments:

Press + to interact
if (a == 0) if (a != 0)
{ {
++a; ++a;
} }
else else
{ {
--a; --a;
} }

CPU fetches instructions sequentially, so we must tell the CPU that we want to skip some instructions if some condition is met (or not met)—for example, if a != 0.

The JNZ (jump if not zero) and JZ (jump if zero) instructions test the ZF flag and change %RIP if the ZF bit is cleared for JZN ...