If you had a problem of doing circular shift on PICmiro microcontroller especially for mid range and low end microcontroller such PIC10Fxx PIC12Fxx and PIC16Fxx, hopefully this trick will help you.
It is true that low end and mid range PICmicro microcontroller does not provide such a specific instruction to do circular shift. Low end and mid range PICmicro microcontrollers keep doing shift through carry bit, buy there is a way of doing this. The keyword is about copying the bit that is going to be passed through carry. Lets go directly to example.
Example 1: 8-bit circular left shift by one
rlf myreg,w ; copy MSB to carry bit
rlf myreg,f ; circular left shift myreg
Example 2: 8-bit circular right shift by one
rrf myreg,w ; copy LSB to carry bit
rrf myreg,f ; circular left shift myreg
Example 3: 8-bit circular left shift by two
rlf myreg,w ; copy MSB to carry bit
rlf myreg,w ; do circular left shift twice
rlf myreg,w ;
movwf myreg ;
Example 4: 8-bit circular right shift by two
rrf myreg,w ; copy LSB to carry bit
rrf myreg,w ; do circular right shift twice
rrf myreg,w ;
movwf myreg ;
Example 5: 16-bit circular left shift by one
rlf myreg_h,w
rlf myreg_l,f
rlf myreg_h,f
Example 6: 16-bit circular left shift by one
rrf myreg_l,w
rrf myreg_h,f
rrf myreg_l,f
Example 7: 32-bit circular left shift by one
; myreg = [myreg3 | myreg2 | myreg1 | myreg0]
rlf myreg3,w
rlf myreg0,f
rlf myreg1,f
rlf myreg2,f
rlf myreg3,f
That's it, hopefully you can grasp the concept. You can also extend this way for larger circular shifting.