源自cmsis_armclang.h:
**
rief Reverse byte order (32 bit)
details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.
param [in] value Value to reverse
eturn Reversed value
*/
#define __REV(value) __builtin_bswap32(value)
/**
rief Reverse byte order (16 bit)
details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856.
param [in] value Value to reverse
eturn Reversed value
*/
#define __REV16(value) __ROR(__REV(value), 16)
/**
rief Reverse byte order (16 bit)
details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.
param [in] value Value to reverse
eturn Reversed value
*/
#define __REVSH(value) (int16_t)__builtin_bswap16(value)
/**
rief Rotate Right in unsigned value (32 bit)
details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
param [in] op1 Value to rotate
param [in] op2 Number of Bits to rotate
eturn Rotated value
*/
__STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
{
op2 %= 32U;
if (op2 == 0U)
{
return op1;
}
return (op1 >> op2) | (op1 << (32U - op2));
}
这种帖子真的没意义,最终都是各行业的说自己好说别人不好。
单片机工程师:汇编是最好的语言!
Web开发:PHP是最好的语言!
有意思么!?
狭隘的工程师永远成为不了大师
其实芯片在一个产品中所占比较很小的,除非量非常大的产品,不然真没有必要纠结这点成本
我理解错了,按字节或者4b翻转我是知道的,但库里貌似不是硬件指令,cortex m3指令集里有对应指令。
按位翻转没有库,也不知道用啥指令
我说的按位翻转是指:
0b10000000 变成0b00000001
源自cmsis_armclang.h:
**
rief Reverse byte order (32 bit)
details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.
param [in] value Value to reverse
eturn Reversed value
*/
#define __REV(value) __builtin_bswap32(value)
/**
rief Reverse byte order (16 bit)
details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856.
param [in] value Value to reverse
eturn Reversed value
*/
#define __REV16(value) __ROR(__REV(value), 16)
/**
rief Reverse byte order (16 bit)
details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.
param [in] value Value to reverse
eturn Reversed value
*/
#define __REVSH(value) (int16_t)__builtin_bswap16(value)
/**
rief Rotate Right in unsigned value (32 bit)
details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
param [in] op1 Value to rotate
param [in] op2 Number of Bits to rotate
eturn Rotated value
*/
__STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
{
op2 %= 32U;
if (op2 == 0U)
{
return op1;
}
return (op1 >> op2) | (op1 << (32U - op2));
}
一周热门 更多>