This operation can be performed efficiently on the ARM, using just four instructions. The word to be reversed is held in a1 both on entry and exit of this instruction sequence. ip is used as a temporary register (For more information about these register names see Interfacing Assembly Language and C):
A demonstration program which should help explain how this works has been
provided in source form in the examples directory. To compile this
program and run it under armsd first set your current directory to
be examples and then use the following commands:
EOR ip, a1, a1, ror #16
BIC ip, ip, #&ff0000
MOV a1, a1, ror #8
EOR a1, a1, ip, lsr #8
Note that this program uses ANSI control codes, so should work on most
terminal types under Unix and also on the PC.
>armcc bytedemo.c -o bytedemo -li -apcs 3/32bit
>armsd -li bytedemo
A.R.M. Source-level Debugger, version 4.10 (A.R.M.) [Aug 26 1992]
ARMulator V1.20, 512 Kb RAM, MMU present, Demon 1.01, FPE, Little endian.
Object program file bytedemo
armsd: go
... demonstration program executes ...