| |||
| Home > ARM and Thumb Instructions > General data processing instructions > REV, REV16, REVSH, and RBIT | |||
Reverse bytes or bits within words or halfwords.
op{cond}Rd,Rn
where:
opis any one of the following:
REVReverse byte order in a word.
REV16Reverse byte order in each halfword independently.
REVSHReverse byte order in the bottom halfword, and sign extend to 32 bits.
RBITReverse the bit order in a 32-bit word.
condis an optional condition code.
Rdis the destination register.
Rnis the register holding the operand.
You can use these instructions to change endianness:
REVconverts 32-bit big-endian data into little-endian data or 32-bit little-endian data into big-endian data.
REV16converts 16-bit big-endian data into little-endian data or 16-bit little-endian data into big-endian data.
REVSHconverts either:
16-bit signed big-endian data into 32-bit signed little-endian data
16-bit signed little-endian data into 32-bit signed big-endian data.
You cannot use PC for any register.
You can use SP in ARM instructions but these are deprecated in ARMv6T2 and above. You cannot use SP in Thumb instructions.
The following forms of these instructions are available in Thumb code, and are 16-bit instructions:
REV Rd, Rm and Rd must
both be Lo registers.Rm
REV16 Rd, Rm and Rd must
both be Lo registers.Rm
REVSH Rd, Rm and Rd must
both be Lo registers.Rm
Other than RBIT, these ARM instructions are available
in ARMv6 and above.
The RBIT ARM instruction is available in ARMv6T2
and above.
These 32-bit Thumb instructions are available in ARMv6T2 and above.
These 16-bit Thumb instructions are available in ARMv6 and above.
REV r3, r7
REV16 r0, r0
REVSH r0, r5 ; Reverse Signed Halfword
REVHS r3, r7 ; Reverse with Higher or Same condition
RBIT r7, r8