4 ms·
Hm, so the post mentions two approaches to BCD addition -- using a DAA instruction, and using a decimal mode like the 6502. It's funny because neither of these
by Sniffnoy 4y ago
Hm, so the post mentions two approaches to BCD addition -- using a DAA instruction, and using a decimal mode like the 6502. It's funny because neither of these are what I would have thought of as the obvious way, namely, having an "add as BCD" instruction (equivalent to an ADD followed by a DAA, or on the 6502 to an ADD in decimal mode). Did any processors take that approach?
- kens 4y agoIBM System/360 (1964) had separate instructions for decimal arithmetic. The Z80 had a DAA instruction, but a separate status bit tracked if the previous operation was addition or subtraction.
- flohofwoe 4y agoI guess the reason is better composability and fewer wasted opcode "slots". E.g. arithmetic instructions output their result and status flags, and the DAA instruction takes that as input. Separate BCD instruction would require to duplicate all instructions that are "compatible" with DAA, and there might not have been enough room in the instruction set for those.
- tom_ 4y agoThe 68000 has the ABCD instruction: http://68k.hax.com/ABCD http://68k.hax.com/ABCD (and SBCD, and NBCD) The ABCD -(An),-(An) form is presumably for big-endian multi-byte BCD values, as the X flag participates.