Path: utzoo!attcan!uunet!lll-winken!ames!mailrus!csd4.milw.wisc.edu!uwmcsd1!marque!studsys!jetzer From: jetzer@studsys.mu.edu (jetzer) Newsgroups: comp.sys.apple Subject: Re: 65C02 Message-ID: <450@studsys.mu.edu> Date: 1 Mar 89 05:38:58 GMT References: <8902221021.AA05592@crash.cts.com> <765@microsoft.UUCP> Organization: Marquette University - Milwaukee, Wisconsin Lines: 42 In article <765@microsoft.UUCP>, brianw@microsoft.UUCP (Brian Willoughby) writes: > In article <8902221021.AA05592@crash.cts.com>, delton@pro-carolina.cts.com (System Administrator) writes: > > What's the shortest way (code size wise) to test for a 65C02 in software > > (disregarding reading ROM ID bytes since the ROM's and CPU's don't > > necessarily go together). Mainly I need to differentiate between the 6502 and > > 65C02. [lots of gory details deleted] Here is a routine that someone posted just recently (within a month and a half or so). All I know for sure is that a 65C02 does return a $43, and a ZIP chip will also return the $43. I assume it will correctly identify the other types of processors (I pulled the 6502 out of my unenhanced //e and put the 'C02 in it after I put my ZIP Chip in my enhanced //e). Best as I can figure, it load the acc with #0, then tries to do a BRA (a 'C02 opcode, the "80 02") over an RTS. If you're on a 'C02 or better, it takes the branch, else it returns. Then it loads acc with #38, and tries to perform operation EB on it. This must be an '816 code, which the C02 ignores (or treats as a NOP), loads acc with #43, and returns. (Sorry I can't attribute the code to the original poster. I was getting ready to download it [with lotsa other stuff], and I always strip the headers before transfer to cut down on the xfer time.) ------------------------------------------------------------------------- This might do the job -- this will return what kind of processor you have, no matter what your ROMS are like. 300:A9 00 80 02 EA 60 A9 38 EB A9 43 EB 60 The accumulator holds your processor type: $00 for 6502 $38 for 65816 or compatible $43 for 65C02 If you like you can add "8D FF 02" to the end of that, and store the result in 767 where you can say A=peek(767) -- Mike Jetzer "Hack first, ask questions later."