PIC Microcontoller Bit Math Method

From Dmitry Kiryashov [zews at AHA.RU]

a) abcd.efgh -> bcda.fghe

        rlf     X,W
        rlf     X,F     ;bcdefgha

        swapf   X,W     ;...a...e
        xorwf   X,W
        andlw   0x11    ;...<a^e>...<e^a>
        xorwf   X,F     ;bcdafghe

b) abcd.efgh -> dabc.hefg

        rrf     X,W
        rrf     X,F     ;habcdefg

        swapf   X,W     ;d...h...
        xorwf   X,W
        andlw   0x88    ;<d^h>...<h^d>...
        xorwf   X,F     ;dabchefg

Archive: