Path: utzoo!attcan!uunet!lll-winken!csd4.milw.wisc.edu!bbn!rochester!udel!princeton!phoenix!blackman From: blackman@phoenix.Princeton.EDU (Scott Michael Blackman) Newsgroups: comp.sys.apple Subject: Re: 65C02 Message-ID: <6758@phoenix.Princeton.EDU> Date: 1 Mar 89 21:43:27 GMT References: <8902221021.AA05592@crash.cts.com> <765@microsoft.UUCP> <450@studsys.mu.edu> Reply-To: blackman@phoenix.Princeton.EDU (Scott Michael Blackman) Organization: Princeton University, NJ Lines: 54 In article <450@studsys.mu.edu> jetzer@studsys.mu.edu (jetzer) 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. > >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 > I was the one who posted this a long time ago. (Gosh, I had forgotten completely about it. It loads the accumulator with the correct ASCII value such that you can just print "65" chr$(x) "02". This is how it works: It loads the accumulator with a starting value of $00, skips the 80 02 EA only if it's a 6502 (80 01 causes the 6502 to hang -- the 01 does it, hence the reason for the EA). So if it's a 6502, it then does an RTS. Now, it loads then accumulator with a $38 (ascii for "8" for the 65802 16-bit processor) and does an EB. That's an XBA, which switches the lo and hi bytes in the 16-bit accumulator (obviously if you're on a 65c816) Then it loads the accumulator with ascii "C" and changes the hi and lo again. If the XBA's work, you wind up with "8" and if they don't, you have a "C" (because EB does nothing on the 65C02). So this program (which I do confess came directly from a Call - A.P.P.L.E. example) will differentiate between the 6502, the 65C02, and the 16-bit 65C816/65802 group. You say the Zip Chip looks like a 65C02. If they did it well, it could be indistinguishable from the "real" 65C02 except for the timing. And here's the original program again, reposted (all 12 bytes of it!): >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) (actually you add 8D FF 02 before the last 60, and then tack on the 60 after that) Anyway, (oops Mike I just erased your address) -- Scott "WhiteWoman" Blackman __ ARPA: blackman@phoenix.princeton.edu, blackman@pucc.princeton.edu [__] UUCP: ...allegra!princeton!{phoenix|pucc}!blackman BITNET: blackman@phoenix.UUCP, blackman@pucc