HACKER Q&A
📣 RetroTechie

Favourite Assembly Instructions?


One for the low-level gurus among you: what is/are your favourite assembly-language instructions, accross the ages & instruction sets?

To get this started: for the good 'ol Z80, I'm torn between Decrement-and-Jump-if-Not-Zero (DJNZ), and Decimal Adjust Accumulator (DAA). Rarely used ComPare, Increment & Repeat (CPIR) could be another contender.

On RISC-V, I much like the Set-Less-Than (SLT..) instructions. Great for replacing conditional branches with branchless, sequential math.

Your favourites?


  👤 absynth Accepted Answer ✓
HCF - Halt and Catch Fire.

👤 gblargg
I always liked rlwimi on PowerPC. It rotates the source n bits, then writes any contiguous section of bits over the corresponding bits in the destination register. This allows copying any bitfield from any position in one register into another. Basically either of these:

  out = (out & ~mask) | (in << shift & mask)
  out = (out & ~mask) | (in >> shift & mask)
Z80's EXX to swap with the shadow registers was interesting (meant for fast interrupt response so you didn't have to save registers to memory).