BCD is a special mode in the 6502 that holds decimal numbers in Bytes as two 4 bit digits. So that maximum value is 99 and minimum is 00.

In BCD mode only ADC and SBC behave appropriately like setting carry if the result of the ADC takes the number over 99.

I can't use LSR since it doesn't operate in the right way. For example 99/2 in BCD mode using LSR would give me 4C which is clearly wrong, and should be 49.

I tried using a simple loop like this preloading A with the BCD number..

Code: Select all

```
LDX #00
SED
SEC
loop1 INX
SBC #02
BCS loop1
CLD
```

The only way i can see is this..

Code: Select all

```
STA BCDNumber
SED
LDA #00
STA Result
CLC
loop1 LDA Result
ADC #00
STA Result
LDA BCDNumber
SEC
SBC #02
STA BCDNumber
BCS loop1
CLD
```