x64 Assembly and C++ Tutorial 31: Byte Swap, Setting Flags and Bit Scanning Instructions

In this tutorial we’ll be examining 8 instructions. The BSWAP, or byte swap is used to reverse the order of bytes in a register. It was intended to be used to swap endianness. There’s 5 flag setting instructions, STD, CLD, STC, CLC and CMC which set and clear the direction and carry flags. We will also look at the interesting Bit Scan instructions BSF and BSR. These instructions scan an operand for 1 bits and return the index of the first one they find.
Back to Top