65c02, 6502, 65816 ??? CPU sells but who`s buying...

risszeichnung

How to detect on which CPU the assembler code is running

(This information is from Draco, the author of SYSINFO 2.0)

You can test on plain 6502-Code if there is a 65c816 CPU, the 16-Bit processor avaible in some XLs as a turbo-board, avaible. Draco told me how 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
           rts
cmos       ...
; if here, we have a cmos-type (65c02,65c816)
           jmp test_65816

This test uses the decimal mode and the decimal addition. On NMOS-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. This could be important if we include in our program/demo 16-bit Code or on 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
            rts
c816        ...       ; here could be the additional 16-bit code
            rts

Special thanx to Draco!!! I will use in my next demos/intros 16-Bit code even if its just 16-bit additions which make life easier. ;)

back to main-index



Last changes: 19 Jun 1997

Amiga_logo

Feel free to contact me for any legal reason!


email_icon HeAvEn, Member of TaquarT