A fun follow-up to XLAT is LEA (Load Effective Address).
Even people who’ve never written a line of assembly have probably heard that “LEA is the secret x86 instruction every optimizer loves,” and it ticks all three boxes you’re aiming for:
- Historical quirk – In the original 8086 documentation LEA was presented purely as an address-calculation helper. Early compilers and hand-coded DOS demos quickly discovered you could abuse it for free arithmetic because it doesn’t touch the flags.
- Novelty factor – It’s the only general-purpose instruction that can do a three-term add/shift in one go (reg = base + index * scale + disp). That makes it a kind of “one-instruction ALU.”
- Performance angle – Modern out-of-order cores often schedule LEA on the same execution ports as integer ALU ops, but with a dedicated path. You’ll even see multiple-latency versions (“slow” vs “fast” LEA) in Intel’s optimization manuals.
Quick demo (32-bit syntax for readability):
; x = y*5 + 8
lea eax, [ebx + ebx*4 + 8] ; single instruction!
; pointer walk without flag trashing
lea esi, [esi + edi] ; advance pointer by “stride”
Micro-trivia:
• On Intel Atom Silvermont there’s a “3-cycle” and a “1-cycle” LEA; compilers try to pick addressing modes that map to the fast one.
• Some early 286 clones had a bug where LEA with certain complex modes generated an incorrect segment overrun exception.
Why it pairs nicely after XLAT
• XLAT is an old-school string helper; LEA is its modern mathematical cousin. Together they show how x86 let you fold indexing math straight into single ops.
If you want a one-liner teaser for the video card:
“XLAT translates bytes through a mini-table; LEA translates addresses into free math.”
👇 Next ideas to keep the momentum
(You don’t have to cover these now, but they slot logically after LEA.)
• AAM/AAD – the weird “ASCII Adjust Multiply/Divide,” a relic of BCD calculators.
• REP MOVSB – the string move that finally became fast again with REP-MOVSB acceleration in Ice Lake/Zen3.
• LAHF/SAHF – save/restore flags in/out of AH, perfect for tiny call/ret stubs.
• RDRAND – hardware RNG, the first x86 instruction with its own conspiracy theories.
But for #2 in the countdown, LEA is hard to beat.