Is a logical right shift by a power of 2 faster in AVR?

后端 未结 9 1586
栀梦
栀梦 2020-12-06 19:21

I would like to know if performing a logical right shift is faster when shifting by a power of 2

For example, is

myUnsigned >> 4
9条回答
  •  没有蜡笔的小新
    2020-12-06 19:47

    In the AVR instruction set, arithmetic shift right and left happen one bit at a time. So, for this particular microcontroller, shifting >> n means the compiler actually makes n many individual asr ops, and I guess >>3 is one faster than >>4.

    This makes the AVR fairly unsual, by the way.

提交回复
热议问题