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

Re: 65c02 in Apple][



Robert Steinmetz wrote:
> It there a simple way to determine if I have the additional
> instructions available for program use?

I remembered that ProDOS tests for a 6502 vs 65C02 and it had something
to do with the way a flag was set in decimal mode.  A Google search
found this:

*******************************************************

http://www.s-direktnet.de/homepages/k_nadj/cputest.html

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

*******************************************************

I have not tried this to see if it works.

--
Paul
Monroe, Michigan USA