## Crossing

In a three-dimensional universe, wires can cross over each other without connecting. But on the two-dimensional playfield, a cross requires a planar device that mutually exchanges inputs. That device implements the XOR swap algorithm. It stores the XOR of inputs A and B into a temporary variable, C:

C = A ⊕ B

Then it XORs the inputs with that temporary variable, which swaps them:

A ⊕ C = A ⊕ A ⊕ B = B

B ⊕ C = B ⊕ A ⊕ B = A

Those steps suggests this circuit:

Since two-dimensional XOR gates exist and the circuit does not contain any cross-overs, it achieves a planar swap.

In following actualization, the lower XOR gate of the schematic is made from three NORs and a horizontal I-tetromino operating as an OR. The other pieces function as wires.

```swap.t
ih -2
ih 2
ll -4
jr 3
ih -5
ih 5
_norLeft 0 1
lu -2
ju 1
_norLeft -3 5
_norRight 3 5
ih -2
ih 2
iv -7
iv 6 7
ih 0
jd -6
ld 5
xor -4 10
xor 4 10

in i1 -4..-1 0
in i0 0..3 0
out o1 -6..-3 21
out o0 2..5 21
```

As demonstrated below, the outputs equal the inputs positionally exchanged.

The following animation shows a diagonal wire crossing over multiple vertical wires via repeated application of the swap circuit.