

How to detect on which CPU the assembler code is running
(This information is fromDraco, the author ofSYSINFO 2.0)
You can test on plain 6502-Code if there is a 65c816 CPU, the 16-Bitprocessor avaible in some XLs as a turbo-board, avaible. Draco told mehow to do this:
First we make sure, whether we are running on NMOS-CPU (6502) or CMOS(65c02,65c816). I will just show the "official" way which doesn`t uses"illegal opcodes":
test_nmos: lda #$99 clc sed adc #$01 cld beq cmos ...; if the program is here we have a 6502-cpu rtscmos ...; if here, we have a cmos-type (65c02,65c816) jmp test_65816
This test uses the decimal mode and the decimal addition. OnNMOS-CPUs the addition does not affect the Z-flag.
But now we have to make sure if we are running on a 16-bit-CPU. Thiscould be important if we include in our program/demo 16-bit Code oron the other side if we can use "illegal opcodes".
The 16-bit test uses the REP #$xx command which does nothing on 65c02! (but on 65c816 !!!):test_65816: rep #$02 ; resets the Z-flag on 65c816 (use MAE-Assembler !!!) bne c816 ... ; here is stored the 65c02-Code rtsc816 ... ; here could be the additional 16-bit code rts
Special thanx to Draco!!! I will use in my next demos/intros 16-Bitcode even if its just 16-bit additions which make life easier. ;)
Last changes: 19 Jun 1997
Feel free to contact me for any legal reason!
HeAvEn, Member of TaquarT