fetch-and-add
An atomic operation that adds to a memory value and hands back what it was before: lock xadd on x86-64, ldadd on ARM64.
Fetch-and-add atomically replaces *p with *p + v and returns the old value (x86-64 lock xadd; ARM64 LSE ldadd; RISC-V amoadd; C++ std::atomic::fetch_add).
Examples
lock xadd [rdi], eaxaddseaxto memory and leaves the old memory value ineax.