XlogicX Blog

Assembly_is_Too_High_Level_-_Redundant_Bit_commands

Compared to some of the most recent posts in this series, this one is a pretty basic example of a redundancy. This redundancy applies to the bit shifting instructions of: RCL, RCR, ROL, ROR, SAL, SAR, SHL, and SHR.

These instructions can take an 8-bit immediate value, but there is also dedicated encoding for the operand to just be the value '1'. This is a very common operand for these type of instructions anyway, so it makes sense.

So the thing is, if we 'rcl eax, 1', there are two ways to encode this, but our assembler will only pick one of them. It sensibly picks the form where the encoding bakes in the implied '1' operand; the other form would require an extra byte of machine code (0x01) for the immediate value.

Below is a screenshot of the collection: