News for hackers. Stuff that matters.
Re:Understanding the x86's Decimal Adjust after Addition (DA... by Sniffnoy on Tuesday January 31, 2023 @03:13AM (#34592614)
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?
Re:Understanding the x86's Decimal Adjust after Addition (DA... by flohofwoe on Tuesday January 31, 2023 @03:24AM (#34592677)
I 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.

Re:Understanding the x86's Decimal Adjust after Addition (DA... by kens on Tuesday January 31, 2023 @03:20AM (#34592655)
IBM 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.
Re:Understanding the x86's Decimal Adjust after Addition (DA... by tom_ on Tuesday January 31, 2023 @08:21AM (#34594686)
The 68000 has the ABCD instruction: 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.