ARM位域提取? [英] ARM bit field extract?

查看:29
本文介绍了ARM位域提取?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人能解释一下这条指令的作用并将其翻译成 C 吗?

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

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

根据 ARM 参考手册,它执行了有符号和无符号位域提取",但我不擅长所有这些按位的东西.

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.

推荐答案

UBFX 只是从源寄存器中提取一个位域并将其放入目标寄存器的最低有效位中.

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

一般形式为:

UBFX dest, src, lsb, width

在 C 中将是:

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

您给出的示例的 C 等效项是:

The C equivalent of the example you give would be:

r3 = (r11 >> 14) & 1;

即如果设置了 r11 的第 14 位,则 r3 将为 1,否则为 0.

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

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

这篇关于ARM位域提取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆