<i id='XKntK'><tr id='XKntK'><dt id='XKntK'><q id='XKntK'><span id='XKntK'><b id='XKntK'><form id='XKntK'><ins id='XKntK'></ins><ul id='XKntK'></ul><sub id='XKntK'></sub></form><legend id='XKntK'></legend><bdo id='XKntK'><pre id='XKntK'><center id='XKntK'></center></pre></bdo></b><th id='XKntK'></th></span></q></dt></tr></i><div id='XKntK'><tfoot id='XKntK'></tfoot><dl id='XKntK'><fieldset id='XKntK'></fieldset></dl></div>

      <legend id='XKntK'><style id='XKntK'><dir id='XKntK'><q id='XKntK'></q></dir></style></legend>
      • <bdo id='XKntK'></bdo><ul id='XKntK'></ul>

    1. <tfoot id='XKntK'></tfoot>
    2. <small id='XKntK'></small><noframes id='XKntK'>

      在 AVR 中,逻辑右移是否快了 2 的幂?

      时间:2023-09-16
      <legend id='Xwydq'><style id='Xwydq'><dir id='Xwydq'><q id='Xwydq'></q></dir></style></legend>

      1. <i id='Xwydq'><tr id='Xwydq'><dt id='Xwydq'><q id='Xwydq'><span id='Xwydq'><b id='Xwydq'><form id='Xwydq'><ins id='Xwydq'></ins><ul id='Xwydq'></ul><sub id='Xwydq'></sub></form><legend id='Xwydq'></legend><bdo id='Xwydq'><pre id='Xwydq'><center id='Xwydq'></center></pre></bdo></b><th id='Xwydq'></th></span></q></dt></tr></i><div id='Xwydq'><tfoot id='Xwydq'></tfoot><dl id='Xwydq'><fieldset id='Xwydq'></fieldset></dl></div>
          <bdo id='Xwydq'></bdo><ul id='Xwydq'></ul>
              <tbody id='Xwydq'></tbody>
            <tfoot id='Xwydq'></tfoot>

                <small id='Xwydq'></small><noframes id='Xwydq'>

                本文介绍了在 AVR 中,逻辑右移是否快了 2 的幂?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我想知道在移动 2 的幂时执行逻辑右移是否更快

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

                例如是

                myUnsigned >> 4
                

                myUnsigned >> 3
                

                我很欣赏每个人的第一反应是告诉我不要担心这样的小事,它使用正确的算法和集合来减少重要的数量级.我完全同意你的看法,但我真的想尽我所能从嵌入式芯片(ATMega328)中挤出一切——我刚刚得到了一个值得哇哦!"的性能转变.通过用位移替换除法,所以我向你保证这很重要.

                I appreciate that everyone's first response will be to tell me that one shouldn't worry about tiny little things like this, it's using correct algorithms and collections to cut orders of magnitude that matters. I fully agree with you, but I am really trying to squeeze all I can out of an embedded chip (an ATMega328) - I just got a performance shift worthy of a 'woohoo!' by replacing a divide with a bit-shift, so I promise you that this does matter.

                推荐答案

                我们来看看数据表:

                http://atmel.com/dyn/resources/prod_documents/8271S.pdf

                据我所知,ASR(算术右移)总是移位一位,不能取位数移位;执行需要一个周期.因此,右移 n 位需要 n 个周期.二的幂的行为与任何其他数字相同.

                As far as I can see, the ASR (arithmetic shift right) always shifts by one bit and cannot take the number of bits to shift; it takes one cycle to execute. Therefore, shifting right by n bits will take n cycles. Powers of two behave just the same as any other number.

                这篇关于在 AVR 中,逻辑右移是否快了 2 的幂?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:如何优化矩阵乘法 (matmul) 代码以在单个处理器内 下一篇:常用 C++ 优化技术列表

                相关文章

                最新文章

                1. <i id='8vZ6r'><tr id='8vZ6r'><dt id='8vZ6r'><q id='8vZ6r'><span id='8vZ6r'><b id='8vZ6r'><form id='8vZ6r'><ins id='8vZ6r'></ins><ul id='8vZ6r'></ul><sub id='8vZ6r'></sub></form><legend id='8vZ6r'></legend><bdo id='8vZ6r'><pre id='8vZ6r'><center id='8vZ6r'></center></pre></bdo></b><th id='8vZ6r'></th></span></q></dt></tr></i><div id='8vZ6r'><tfoot id='8vZ6r'></tfoot><dl id='8vZ6r'><fieldset id='8vZ6r'></fieldset></dl></div>

                  <small id='8vZ6r'></small><noframes id='8vZ6r'>

                  • <bdo id='8vZ6r'></bdo><ul id='8vZ6r'></ul>
                  1. <tfoot id='8vZ6r'></tfoot>
                    <legend id='8vZ6r'><style id='8vZ6r'><dir id='8vZ6r'><q id='8vZ6r'></q></dir></style></legend>