| |||
| Home > Compiler-specific Features > __swp intrinsic | |||
This intrinsic inserts a SWP{size} instruction
into the instruction stream generated by the compiler. It enables
you to swap data between memory locations from your C or C++ code.
The use of SWP and SWPB is deprecated
in ARMv6 and above.
unsigned int __swp(unsigned intval, volatile void *ptr)
Where:
valIs the data value to be written to memory.
ptrThe __swp intrinsic returns the data
value that previously, is in the memory address pointed to by ,
before this value is overwritten by ptr.val
int foo(void)
{
int loc=0xff;
return(__swp(0x20, (volatile int *)loc));
}
Compiling this code produces
||foo|| PROC MOV r1, #0xff MOV r0, #0x20 SWP r0, r0, [r1] BX lr ENDP
SWP and SWPB in the Assembler Reference.