Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ARM bit field extract?

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

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

According to the ARM reference manual, it does a "signed and unsigned bit field extract" but I'm not good with all that bitwise stuff.

like image 430
Kristina Brooks Avatar asked Oct 31 '25 23:10

Kristina Brooks


1 Answers

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

like image 61
Paul R Avatar answered Nov 04 '25 06:11

Paul R



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!