Bit-reverse a byte on 68HC12

前端 未结 9 1599
挽巷
挽巷 2021-01-18 02:03

I\'m in a microprocessors class and we are using assembly language in Freescale CodeWarrior to program a 68HCS12 micro controller. Our assignment this week is to revers a by

9条回答
  •  离开以前
    2021-01-18 03:01

    This was a comment but I thought WTH!

    To save space over the 256 byte table you can have a 16 byte table containing the values for four bits (nibbles) at a time. The algorithm then would be

    revval=(revdigit[inval&0x0f]<<4)|
            revdigit[inval>>4];
    

    If I were a prof I'd certainly like the two parts where one shift is in the indexing and the other outside.

提交回复
热议问题