News for hackers. Stuff that matters.
Re:Z80 arithmetic: also surprisingly terrible (2018) by Doctor_Fegg on Monday January 14, 2019 @04:32AM (#18901821)
Like any 8-bit CPU, the Z80 had plenty of coding optimisations you soon learned. First one that came to mind reading this: instead of ld bc,4; ldir, it’s faster just to do ldi; ldi; ldi; ldi.

There’s also a set of “alternate registers” you could swap in with exx, which sometimes enabled faster arithmetic without hitting memory.

Re:Z80 arithmetic: also surprisingly terrible (2018) by jgrahamc on Monday January 14, 2019 @04:40AM (#18901851)
Yep. The trade off is that takes 3 more bytes but it's a great example of the thinking that went into writing 'tight' code for these processors. You're doing a loop unroll for speed and taking up more space, depending on what evil trick you're up to (e.g. hiding code inside a 128 byte unused spot in the BDOS) one might be better than the other.