ARM bit field extract?

前端 未结 1 1861
执笔经年
执笔经年 2021-01-03 08:26

Can someone explain what this instruction does and translate it to C?

ubfx.w          r3, r11, #0xE, #1

According to the ARM reference manu

相关标签:
1条回答
  • 2021-01-03 09:25

    UBFX just extracts a bitfield from the source register and puts it in the least significant bits of the destination register.

    The general form is:

    UBFX dest, src, lsb, width
    

    which in C would be:

    dest = (src >> lsb) & ((1 << width) - 1);
    

    The C equivalent of the example you give would be:

    r3 = (r11 >> 14) & 1;
    

    i.e. r3 will be 1 if bit 14 of r11 is set, otherwise it will be 0.

    See: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0489c/Cjahjhee.html

    0 讨论(0)
提交回复
热议问题