0
votes

The below is code for X86-64 code which contains some assembly can you please help us to convert assembly for ARMv8 aarch64

__asm__ __volatile__ ("lock; cmpxchgw %1,%2"
                      : "=a"(sPrev)
                      : "q"(aWith),
                        "m"(*(volatile acp_sint16_t *)aAddr),
                        "0"(aCmp)
                      : "memory");

__asm__ __volatile__ ("mov %%ebx,%%eax\n\t"
                      "mov %%ecx,%%edx\n\t"
                      "lock; cmpxchg8b %1"
                      : "=&A"(sVal)
                      : "m"(*(volatile acp_sint64_t *)aAddr)
                      : "cc");

__asm__ __volatile__ ("lock; xaddq %0,%1"
                      : "+r"(sPrev), "+m"(*(volatile acp_sint64_t *)aAddr)
                      :
                      : "memory");
1

1 Answers

0
votes

Your development environment already has the equivalents in some variant of stdatomic.h. The critical concepts are the same, except you have to choose between incomprehensible variants such as “weak” and “strong”...

At the least, maintain your programs protocol based approach to these variables; that is treat them like magic cookies that can only be operated on by mysterious libraries. The standard-du-jour encourages a sadly vague definition to be implemented directly by the compiler; the best outcome I can imagine is many hours of debugging the compiler/runtime.....

It is always good software engineering to isolate machine or execution specific dependencies.