|
|
|
|
|
by efas
1142 days ago
|
|
Implicitly, the two signed integers are large enough to fit each other (they are the same size). I would not assume anything about organization in memory though.
x=a, y=b; look at arithmetic in pseudo-ops
x=a, y=(b-a); there will be an overflow here or after the negation step
x=a+(b-a)=b, y=(b-a);
x=b, y=(a-b); negate the unitary value could overflow (and set the carry bit)
x=b, y=(a-b)+b=a; oops, four operations and not as elegant as XORs can be. Or, the compiler would probably use a third register. |
|