embeded/ARM2023. 9. 14. 12:33

 

On ARMv6 and above, you can just use the rev instruction, but I assume that you're not allowed to do that for whatever reason.

[링크 : https://stackoverflow.com/questions/2755171/arm-assembly-converting-endianness]

 

REV
Reverse the byte order in a word.

Syntax
REV{cond} Rd, Rn

where:

cond
is an optional condition code.

Rd
is the destination register.

Rn
is the register holding the operand.

[링크 : https://developer.arm.com/documentation/dui0473/m/arm-and-thumb-instructions/rev]

 

unsigned int foo(unsigned int a)
{
  return __builtin_bswap32(a);
}

[링크 : https://stackoverflow.com/questions/35133829/does-arm-gcc-have-a-builtin-function-for-the-assembly-rev-instruction]

[링크 : https://teus.me/726]

 

gcc built-in function 이고 자매품(?) 으로 __builtin_bswap16 이라는 녀석도 있다.

Built-in Function: uint32_t __builtin_bswap32 (uint32_t x)
Similar to __builtin_bswap16, except the argument and return types are 32-bit.

[링크 : https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html]

 

어.. vertorized 안되면.. 그냥 쌩으로 for 돌려야 하는건데...?! 이럼 나가리인데?!?!?

지원되는 GCC 비벡터 내장 함수
마지막 업데이트 날짜: 2023-07-13

IBM® Open XL C/C++ for AIX® 17.1.1 는 다음 GCC 비벡터 내장 함수를 지원합니다.

[링크 : https://www.ibm.com/docs/en/openxl-c-and-cpp-aix/17.1.0?topic=functions-supported-gcc-non-vector-built-in]

'embeded > ARM' 카테고리의 다른 글

emmc 파티션 정렬  (0) 2024.02.07
cortex-a53  (0) 2023.08.31
aarch64 vector register  (0) 2023.08.23
arm vsub operator  (0) 2023.08.09
ARM NEON SLP  (0) 2023.08.07
Posted by 구차니