Files
linux-kernel-module-cheat/userland/arch/x86_64/cmpxchg.S
Ciro Santilli 六四事件 法轮功 3fdd83c2c5 Rationalize -mcpu for emulators, compilers and assemblers on ARM
Move SVE example in from arm-assembly-cheat.

atomic.cpp aarch64 add LSE ldadd placeholder, not compiling yet
2019-06-26 00:00:00 +00:00

28 lines
580 B
ArmAsm

/* https://github.com/cirosantilli/linux-kernel-module-cheat#x86-cmpxchg-instruction */
#include <lkmc.h>
LKMC_PROLOGUE
/* rax != r13 */
mov $0, %rax
mov $1, %r13
mov $2, %r14
cmpxchg %r14, %r13
mov %rax, %r12
LKMC_ASSERT(jnz)
LKMC_ASSERT_EQ(%rax, $1)
LKMC_ASSERT_EQ(%r13, $1)
LKMC_ASSERT_EQ(%r14, $2)
/* rax == r13 */
mov $0, %rax
mov $0, %r13
mov $2, %r14
cmpxchg %r14, %r13
mov %rax, %r12
LKMC_ASSERT(jz)
LKMC_ASSERT_EQ(%rax, $0)
LKMC_ASSERT_EQ(%r13, $2)
LKMC_ASSERT_EQ(%r14, $2)
LKMC_EPILOGUE