On 12/8/2005 at 11:43 PM Pete Turnbull wrote:
There's no (visible) equivalent in a 6502 because
of the way its
special Decimal Mode for BCD arithmetic works. Ditto for a 68000.
The 68K decides instead to dedicate special instructions (ABCD, SBCD,
NBCD). Not a bad solution, particularly with auto-increment and decrement
on the source and destination addresses.
The whole business of BCD arithmetic probably stems from the binary
paranoia exhibited in the 50's-70's by the business community. COBOL
features arithmetic directly on character strings, or in the case of IBM
comp-3 numbers, packed strings. PL/I displays the same thing. Gotta have
it because you can't represent 1/10 as a non-continuing binary fraction and
that gives rise to the story about the fellow who collected binary "round
off" error in his own bank account and got very wealthy. Forget that even
BCD has roundoff/truncation/loss of significance problems too, just give us
our decimal!
When I was designing a BASIC compiler and run-time in the 70's, it was made
very clear to me that BCD floating point was a given. No binary--it gives
business types the willies no matter how much precision you attach to it
(I'd proposed as an alternative binary with a decimal fixed point). When
8087 support was added to Supercalc, numbers were still stored internally
as BCD floating point, in spite of being handled as binary inside in the
8087.
Hopefully, we're all past that now. Maybe we can jettison the DAA, DAS,
AAM and AAD from the x86 instruction set.
ZAP,
Chuck