Check CMOS. By Lee Davison.

Introduction.

Check if the code is running on a CMOS or NMOS 6502. You may need to know this if your code has timing critical loops or relies on the features of one processor and needs different code on the other.

The code.

Nothing particularly fancy, the code simply makes use of the fact that the NMOS 6502 does not set the zero flag bit when doing decimal adds or subtracts and the CMOS 6502 does. The result of this is that Zb is set only if the code is run on a CMOS 6502.


	SED			; set decimal mode
	CLC			; clear carry for add
	LDA	#$99		; actually 99 decimal in this case	
	ADC	#$01		; +1 gives 00 and sets Zb on 65C02
	CLD			; exit decimal mode

Enjoy.


Last page update: 20th March, 2004. e-mail me