2018-06-02 06:07 PM
4.4.4 REV, REVH, and REVSH
REV reverses the byte order in a data word,For example, if R0 is 0x12345678, in executing the following:
REV R1, R0R1 will become 0x78563412,The Definitive Guide to the ARM� Cortex-M3 by Joseph Yiu
in a C file
Would call this assembler instruction in a function ?
or define it as a macro ?
or inline assembler ?
#endianness2018-06-02 06:24 PM
STM32Cube_FW_L4_V1.11.0\Drivers\CMSIS\Include\cmsis_armcc.h
use
foo = __REVSH(foo);
2018-06-02 09:00 PM
is that for 32bit data ?
is this ok ?
// inline ASM
uint32_t r0 = IncomingData;
uint32_t r1;
__asm
{ rev r1, r0 }RevData = r1;
2018-06-03 06:47 AM
/**
\brief Reverse byte order (32 bit) \details Reverses the byte order in integer value. \param [in] value Value to reverse \return Reversed value */ ♯ define __REV __rev/** \brief Reverse byte order (16 bit) \details Reverses the byte order in two unsigned short values. \param [in] value Value to reverse \return Reversed value */ ♯ ifndef __NO_EMBEDDED_ASM__attribute__((section('.rev16_text'))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t value){ rev16 r0, r0 bx lr} ♯ endif/**
\brief Reverse byte order in signed short value \details Reverses the byte order in a signed short value with sign extension to integer. \param [in] value Value to reverse \return Reversed value */ ♯ ifndef __NO_EMBEDDED_ASM__attribute__((section('.revsh_text'))) __STATIC_INLINE __ASM int32_t __REVSH(int32_t value){ revsh r0, r0 bx lr} ♯ endif2018-06-03 08:12 AM
my blank project compiles except for this section:
when I enable this code:
&sharpifndef __NO_EMBEDDED_ASM
__attribute__((section('.revsh_text'))) __STATIC_INLINE __ASM int32_t __REVSH(int32_t value){ revsh r0, r0 bx lr}&sharpendifI get:
Error expected identifier or '(' before '__asm' TH18 C:\Users\nickm\Documents\VS2018\TH18_Cube\Drivers\CMSIS\Include\cmsis_gcc.h 36
cmsis_gcc.h:
34 /* CMSIS compiler specific defines */
35 &sharpifndef __ASM36 &sharpdefine __ASM __asm37 &sharpendif