News for hackers. Stuff that matters.
Re:XOR'ing a register with itself is the idiom for zeroing i... by blywi on Wednesday April 22, 2026 @09:23AM (#47863263)
XOR A absolutely works on Z80 and it's of course faster and shorter than loading a zero value with LD A,0. LD A,0 is encoded to 2 bytes while XOR A is encoded as a single opcode. XOR A has the additional benefit to also clear all the flags to 0. Sub A will clear the accumulator, but it will always set the N flag on Z80.
Re:XOR'ing a register with itself is the idiom for zeroing i... by classichasclass on Wednesday April 22, 2026 @10:41AM (#47864351)
Ah, thanks, I couldn't recall off the top of my head.
Re:XOR'ing a register with itself is the idiom for zeroing i... by eichin on Wednesday April 22, 2026 @02:10PM (#47867162)
Yeah, the article seems to have missed the likely biggest reason that this is the popular x86 idiom - that it was already the popular 8080/Z80 idiom from the CP/M era, and there's a direct line (and a bunch of early 8086 DOS applications were mechanically translated assembly code, so while they are "different" architectures they're still solidly related.)
Re:XOR'ing a register with itself is the idiom for zeroing i... by dmitrygr on Wednesday April 22, 2026 @05:18PM (#47869416)
should set Z too