10 Shift and Rotate Macros


A shift (SHIFT) function moves the bits in a register to the right or to the left. As an example, Figure 10.1 shows a shift right function that retrieves the input data from the source register A and shifts the bits of the source register A toward the right as many numbers as specified by the number of shift, while the serial data are taken from the left through the Boolean input variable shift in bit. The result of the shift operation is stored in a destination register B. In this case, the least significant bit (LSB) is shifted out as many numbers as specified by the number of shift. A shift left function is identical, except that the shift in bit, taken from the right, is moved in the opposite direction toward ...

Get Building a Programmable Logic Controller with a PIC16F648A Microcontroller now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.