| ▲ | classichasclass 5 hours ago | |||||||||||||
Unfortunately, 6502 can't XOR the accumulator with itself. I don't recall if the Z80 can, and loading an immediate 0 would be most efficient on those anyway. | ||||||||||||||
| ▲ | blywi 5 hours ago | parent | next [-] | |||||||||||||
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. | ||||||||||||||
| ||||||||||||||
| ▲ | repelsteeltje 4 hours ago | parent | prev | next [-] | |||||||||||||
You're absolutely right, I stand corrected. The 6502 gets by doing immediate load: 2 clock cycles, 2 bytes (frequently followed by single byte register transfer instruction). Out of curiosity I did a quick scan of the MOS 1.20 rom of the BBC micro: | ||||||||||||||
| ▲ | bonzini 5 hours ago | parent | prev [-] | |||||||||||||
The Z80 can do either LD A,0 or SUB A or XOR A, but the LD is slower due to the extra memory cycle to load the second byte of the instruction. | ||||||||||||||