[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Recreate 6502 Bug II



"Bryan Parkoff" <spam> writes:
>    How do 6502 programmers survive with 6502 bug using BCD?  If they try
>this example below.

>    CLC
>    SED
>    LDA    #$20
>    ADC    #$FA
>    CLD
>    EOR    #$80
>    BMI    +$03
>    STA    2000
>    RTS

The above is not a valid example of using BCD. $FA is not a valid BCD value
so anyone actually doing BCD arithmetic would not be affected.

According to my Rockwell data book, only the ADC instruction is listed with
"(4) if in decimal mode, Z flag is invalid. Accumulator must be checked for
zero result" but I suspect they left it off the line for SBC.

The R65C02 does not fix this error according to the same data book.

So the way a 6502 programmer does BCD arithmetic is:

	CLC
	SED
	LDA	#$05
	ADC	#$95
	CLD
	CMP	#$00	; additional instruction needed on 6502
	BEQ	xxxx
-- 
David Wilson  School of IT & CS, Uni of Wollongong, Australia