Take
a Swing!
Problem 4What
does the following assembly code do?
xor a,b
xor b,a
xor a,b
Answer: The contents of
register a and register b are swapped after the operation. If we expand
the operations in pseudo C code:
aý = a ^ b
bý = b ^ aý = b ^ (a ^ b) = b ^ b ^ a = a
aýý = aý ^ bý = (a ^ b) ^ a = a ^ a ^ b = b
4-00
|