First page Back Continue Last page Overview Graphics
Shifting bits: Microcontrollers have instructions to shift bits. All bits are simultaneously shifted either to the right or left.
Instructions may rotate the bits through a condition code flag such as carry.
A one-bit left shift doubles a value and a one-bit right shift halves a value.
Generally the term logical shift is used for instructions that move a zero into the bit position getting vacated because of a shift out and shift the remaining bits either to the right or left. The bit value falling off at the other side of the register may be placed in a condition code register flag such as carry.
The term arithmetic shift refers to a shift instruction that moves the sign bit into the vacated bit position on a right shift and moves a zero into the vacated bit position on a left shift. This instruction can maintain sign when using 2’s complement numbers.
The term rotate refers to rotating bits of a register, that is on a left rotate all bits shift left with the most significant bit rotating to the least significant bit position. On a right rotate the least significant bit would rotate to the most significant bit position. The rotated bits may also rotate through the a condition code flag such as carry.