| ▲ | flohofwoe 10 hours ago | ||||||||||||||||
That comment is not very useful without pointing to realworld CPUs where SUB is more expensive than XOR ;) E.g. on Z80 and 6502 both have the same cycle count. | |||||||||||||||||
| ▲ | HarHarVeryFunny 6 hours ago | parent | next [-] | ||||||||||||||||
The 6502 doesn't support XOR A or SUB A, and in fact doesn't have a SUB opcode at all, only SBC (subtract with carry, requiring an extra opcode to set the carry flag beforehand). | |||||||||||||||||
| |||||||||||||||||
| ▲ | brigade 10 hours ago | parent | prev | next [-] | ||||||||||||||||
Cortex A8 vsub reads the second source register a cycle earlier than veor, so that can add one cycle latency Not scalar, but still sub vs xor. Though you’d use vmov immediate for zeroing anyway. | |||||||||||||||||
| ▲ | em3rgent0rdr 5 hours ago | parent | prev | next [-] | ||||||||||||||||
With more bits, then SUB is going to be more and more expensive to fit in the same number of clocks as XOR. So with an 8-bit CPU like Z80, it probably makes design sense to have XOR and SUB both take one cycle. But if for instance a CPU uses 128-bit registers, then the propagate-and-carry logic for ADD/SUB might take way much longer than XOR that the designers might not try to fit ADD/SUB into the same single clock cycle as XOR, and so might instead do multi-cycle pipelined ADD/SUB. A real-world CPU example is the Cray-1, where S-Register Scalar Operations (64-bit) take 3 cycles for ADD/SUB but still only 1 cycle for XOR. [1] [1] https://ed-thelen.org/comp-hist/CRAY-1-HardRefMan/CRAY-1-HRM... | |||||||||||||||||
| ▲ | 7 hours ago | parent | prev | next [-] | ||||||||||||||||
| [deleted] | |||||||||||||||||
| ▲ | GoblinSlayer 9 hours ago | parent | prev [-] | ||||||||||||||||
Harvard Mark I? Not sure why people think programming started with Z80. | |||||||||||||||||
| |||||||||||||||||