ARMv6 的 Word Swap 指令

ARMv6 加入了幾個好用的 Swap 指令. 不需要用軟體算來算去
請參考 http://www.arm.com/pdfs/ARMv6_Architecture.pdf

REV
REV16
REVSH

ARM_REV

最常用的應該是 REV 吧.

Realview inline assembly 很簡單.

[C]unsigned int tmp = 0x12345678;
__asm{
REV tmp, tmp
}[/C]

GNU C++ inline assembly 為(未測)

[C]
unsigned int tmp = 0x12345678;
__asm__ __volatile__ (
“REV %0,%0;” : “=r”(tmp) : “r”(tmp):”r5”);
);[/C]

On this day..

Comments

comments

Related Posts

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>