@instruction<EOL><INDENT>def XADD(cpu, dest, src):<DEDENT>
MASK = (<NUM_LIT:1> << dest.size) - <NUM_LIT:1><EOL>SIGN_MASK = <NUM_LIT:1> << (dest.size - <NUM_LIT:1>)<EOL>arg0 = dest.read()<EOL>arg1 = src.read()<EOL>temp = (arg1 + arg0) & MASK<EOL>src.write(arg0)<EOL>dest.write(temp)<EOL>tempCF = Operators.OR(Operators.ULT(temp, arg0), Operators.ULT(temp, arg1))<EOL>cpu.CF = tempCF<EOL>cpu.AF = ((arg0 ^ arg1) ^ temp) & <NUM_LIT> != <NUM_LIT:0><EOL>cpu.ZF = temp == <NUM_LIT:0><EOL>cpu.SF = (temp & SIGN_MASK) != <NUM_LIT:0><EOL>cpu.OF = (((arg0 ^ arg1 ^ SIGN_MASK) & (temp ^ arg1)) & SIGN_MASK) != <NUM_LIT:0><EOL>cpu.PF = cpu._calculate_parity_flag(temp)<EOL>
Exchanges and adds.

Exchanges the first operand (destination operand) with the second operand
(source operand), then loads the sum of the two values into the destination
operand. The destination operand can be a register or a memory location;
the source operand is a register.
This instruction can be used with a LOCK prefix::

        TEMP  =  SRC + DEST
        SRC  =  DEST
        DEST  =  TEMP

:param cpu: current CPU.
:param dest: destination operand.
:param src: source operand.