News for hackers. Stuff that matters.
Re:Understanding the x86's Decimal Adjust after Addition (DA... by segfaultbuserr on Tuesday January 31, 2023 @11:41AM (#34597443)
On these early CPUs, conversion from binary to decimal could be very expensive. It required an integer division by 10, and the division must be done in software. Replacing it with shift-and-add calculations is not a solution, since fast bitshifts was only possible with a barrel shifter, which was also nonexistent on an early 8-bit CPU. Earlier discrete logic circuits and calculators used BCD for the same reason. Conversion from BCD to readable formats like a 7-segment display or ASCII output was simple and only requires simple combinational logic.

Supporting BCD arithmetic was not just for compatibility, but necessity. If the number is frequently updated, storing it in BCD was the fastest solution.

It's fortunate that computers are advanced enough today that we usually don't need to worry about the overhead of printf("%d", integer) anymore.

Re:Understanding the x86's Decimal Adjust after Addition (DA... by awesomedad on Tuesday January 31, 2023 @05:09PM (#34602986)
Advanced enough, or are we brute forcing it?
Re:Understanding the x86's Decimal Adjust after Addition (DA... by segfaultbuserr on Tuesday January 31, 2023 @07:03PM (#34604233)
Excellent question. I'd say it's "advanced enough" in terms of semiconductor process node, "brute-force enough" in terms of circuit logic. A barrel shifter is definitely one of the most "brute-force" kind of logic circuits - you want to shift many bits in a word, but at the same time in a single cycle? Just use a large matrix to connect every possible input bits to every possible output bits. Early chips simply couldn't afford the die area on this non-essential but nice-to-have feature.