Shifts and Rotates

This group includes arithmetic (signed) shift, logical (unsigned) shift, and bit rotation.

Arithmetic Operations

Shifts can be either logical or arithmetic. Logical shift right moves the bits right, discarding lower (least significant) bits, and inserting zeros in the most significant positions. Arithmetic shift works the same way except it inserts the value of the most significant bit instead of zeros (this operation is called 'sign extension').

Arithmetic and logical shifts left are identical – strictly speaking, there is no arithmetic shift left. However FlexHEX allows negative shift counts so a left shift may actually shift the bits to the right. In this case arithmetic and logical shifts will work differently.

Rotates perform circular shift, when the bits pushed out are immediately pushed in from another side.

As in the case of a bitwise or arithmetic operation, shift or rotate is performed on the selected block. If there is no selected block, the operation will be performed on the whole file (stream).

The supported operand sizes are byte, word (2 bytes), double word (4 bytes), and quad word (8 bytes). The actual size of the block being processed is rounded according to the operand size.

Shift counts can be obtained from the clipboard, or specified as a set of hex or decimal values. If the number of shift counts is less than the number of items to be processed, the shift counts will be used repetitively. For example, on the screenshot above the actual shift count is an infinite sequence "2,-2,2,-2,2,-1...". A negative count specifies shift in the opposite direction, so the example operation above will shift every even double word two positions to the left, and every odd double word two positions to the right.

Shift counts are always bytes no matter which operand size is selected. The valid range for a byte value is -128 to 255.