Z80 Assembly 06: Rotation and Shifts (Fast Multiplication/Division)

Understanding Shifts and Rotations Shift and rotate instructions move the bits within a register. This is often done to perform arithmetic: shifting a number left by one position is equivalent to multiplying by 2, and shifting right is equivalent to integer dividing by 2. Key Difference: Shift: The bit that leaves one end is discarded, and a new bit (0 or the sign bit) enters the other end. Rotate: The bit that leaves one end wraps around to enter the other end, forming a circle. Arithmetic Shifts (SLA and SRA) Arithmetic shifts are best for multiplication and division because they handle the sign of the number correctly. ...

September 27, 2025