◄ WORLD V · SONNY 5DART 455 · a helldive at the net

THE XCE one instruction flips the machine — exchange carry and emulation

To leave the 6502 behind you execute a single instruction: XCE, eXchange Carry and Emulation. It swaps the carry flag with the emulation bit — so CLC : XCE (clear carry, then exchange) writes 0 into E and enters native 16-bit mode, and SEC : XCE returns to emulation. That is the whole gate between the two worlds: a bit-swap. And because it is a swap, running XCE twice restores the original state — it is its own inverse over the pair, the seal axis hiding inside a mode switch.

THE TECHNIQUE swap C ↔ E — CLC:XCE enters native; twice = identity

The demo swaps carry into emulation (entering native mode), then swaps again — and the machine is back where it started: live demo


HISTORY & CREDIT 65C816 XCE · the mode gate

“Switching a CPU’s word size needs a mode register and a reset.” — the 65816 does it with one bit-swap instruction. cited

the swap · XCE exchanges the carry flag and the emulation bit — C and E trade places.
the idiom · CLC : XCE → E=0 (native 16-bit); SEC : XCE → E=1 (emulation).
the involution · two XCE (with the carry restored) returns the machine to its start — self-inverse.

The border between two processors crossed by trading one bit for another — and crossed back by trading again. self-inverse

RECOMMEND FOR I-13 the mode swap, on the compiler

On the canonical compiler, XCE takes (C=1,E=0) to (C=0,E=1) — entering emulation — and a second XCE restores the original pair:

$ i13 run pm_xce.i13 # exchange carry and emulation RUN OK · 24 step(s) · peak stack 3 · call depth 0 entered_emulation = 1 -- after XCE, E = old C two_xce_identity = 1 -- XCE twice restores the state (an involution)
Recommend as a NULL by duplication. XCE is a self-inverse (swap twice = identity), which is the seated axis 1 (CRC/Verlet) wearing a mode-switch costume. It is keeper-shaped but duplicates an existing pillar rather than opening a sixth. NULL — and a lovely instance: the entire gate between the 6502 and the 65816 is one involutive bit-swap.