Comment by to3m

13 years ago

I have no idea what people used BCD for either. I vaguely recall reading that the C64's interrupt routine didn't even bother to clear the D flag, so you had to disable interrupts while using decimal mode! - so obviously most people just weren't expected to be using it.

I only ever saw it used for game scores... and the following, which prints a byte as hex, and is a neat example of cute 6502 code. Saves a few bytes over having a table of hex digits, and you don't need to save X or Y.

    HEX:  PHA
          LSR:LSR:LSR:LSR
          JSR HEX2
          PLA
          AND #15
    HEX2: CLC
          SED:ADC #$90:ADC #$40:CLD
          JMP PUTCH

(PUTCH takes an ASCII character in A.)

The 68000 had BCD as well. Never used it and don't recall ever seeing it used. I think they only included it so they could have an instruction called ABCD.

I would imagine BCD was useful as a bootstrap for a poor ASM programmer's bignum library (especially when 'bignum' was >16 bits).

Also would be useful for 7-segment LED displays.