What 65816 test analogous to nestest?

Discussion of hardware and software development for Super NES and Super Famicom. See the SNESdev wiki for more information.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
User avatar
koitsu
Posts: 4201
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: What 65816 test analogous to nestest?

Post by koitsu »

creaothceann wrote:The data sheet (which is quite recent) also contains the bus activity.
Thanks for this -- I'd skimmed this one some time ago but had completely forgotten it contained relevant info. The bus activity diagram doesn't help me (again: not a hardware guy), but the Table 3-1 Addressing Mode Summary, Table 5-4 Opcode Matrix, and Table 5-7 Instruction Operations don't match up cycle-count wise. I want to assume the misunderstanding is something I'm doing, not the documentation/technology, but I really don't know:

Table 3-1 says for Absolute Indirect (Jump), the cycle count is 5. What's weird is: it says the cycle count of the original 6502 is 5, as well as for the 65816 is 5.
Table 5-4 says for opcode 6C (JMP (a)), the cycle count is 5. No entry in the "Cycle Count Assumes" notes under the chart apply to this opcode.
Table 5-7 says for entry 3b. Absolute Indirect (a) JMP: 5 cycles and shows the exact same data as what the GTE doc does (thus I suspect the GTE doc info originated from WDC)

And to recap: from the Programming the 65816 document:

Page 360 says for opcode 6C the cycle count is 5, with sub-notes "add 1 cycle if 65C02" and "6502: if low byte of addr is $FF: yields incorrect result" (known 6502 page wrap bug).
Chapter 19 for Instruction Lists says the same thing as Page 360.
Page 436 of an opcode chart says for opcode 6C, the cycle count is 5.

We do know the WDC PDF contains several mistakes all over the place (that's how/why I Emailed them some time ago and got a response from Bill Mensch acknowledging the mistakes). However, I also own the original Lichty/Eyes book (which contains basically both of WDC's above documents), but there's no difference in what's depicted.

I wonder if the 6 cycle thing is somehow truly a 65c02 specific detail, and that proper page wrapping (as implemented on the 65816) doesn't cost an additional cycle -- i.e. the 65c02 had some "kludge" put in place to fix the JMP ($xxFF) bug that cost an extra cycle, which was later alleviated on the 65816 (where the bug is also fixed) sans the cycle penalty.

I should probably just ask WDC. Sorry for getting hung up on a single opcode, but I do find it strange.
creaothceann
Posts: 611
Joined: Mon Jan 23, 2006 7:47 am
Location: Germany
Contact:

Re: What 65816 test analogous to nestest?

Post by creaothceann »

koitsu wrote:I want to assume the misunderstanding is something I'm doing, not the documentation/technology, but I really don't know
There really seem to be a few errors in there - SNES/emu coders have to compare with enthusiast documents (e.g. 1 2 3). But JMP (a) seems to be correct.

As to the 65?02 variants I've found these docs: 1 2 3
My current setup:
Super Famicom ("2/1/3" SNS-CPU-GPM-02) → SCART → OSSC → StarTech USB3HDCAP → AmaRecTV 3.10
Sour
Posts: 891
Joined: Sun Feb 07, 2016 6:16 pm

Re: What 65816 test analogous to nestest?

Post by Sour »

creaothceann wrote:Here are some ROMs: https://board.byuu.org/viewtopic.php?f=16&t=1486
Thanks for that link, finally finished coding the bare minimum PPU/DMA features that these roms needed, so I can finally use them to fix up the (numerous) CPU bugs they detect :p

And thanks for taking the time to make this post, tepples!
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: What 65816 test analogous to nestest?

Post by Oziphantom »

koitsu wrote:One thing I can't determine or test is whether or not on a 65816 when e=1 if the instruction takes 5 or 6 CPU cycles.
Does the IIgs still not have counters?
User avatar
koitsu
Posts: 4201
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: What 65816 test analogous to nestest?

Post by koitsu »

Oziphantom wrote:Does the IIgs still not have counters?
I don't know what you're talking about, unless it's PMC? If so, no, there isn't any performance monitoring counters in the CPU. In fact, I don't know of this being very commonplace on any non-present-day CPU. There isn't anything that can relay/display/whatever that level of granularity either (a 1 CPU cycle variance). Generally speaking for counting CPU cycles, you quite literally count them -- based on CPU vendor documentation. Which is where there's a strange discrepancy. I do suspect though that it's 5 cycles, and that for whatever reason (kludge-fix) it's 6 on the 65c02 specifically.
niconii
Posts: 219
Joined: Sun Mar 27, 2016 7:56 pm

Re: What 65816 test analogous to nestest?

Post by niconii »

koitsu wrote:There isn't anything that can relay/display/whatever that level of granularity either (a 1 CPU cycle variance).
If you only run the instruction once, sure. But if you do it one hundred times, that's a difference between 500 cycles and 600 cycles, and that's a lot easier to measure.
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: What 65816 test analogous to nestest?

Post by Oziphantom »

On the Commodore range- PET->A4000 we have VIA and/or CIA chips which have cycle level timers.

So on a C64, I can start the timer, perform an instruction, then read the timer. If we know the length of the other instructions, then one can do simple maths to work out how long the unknown bit took.

I can see if I can find somebody with a SuperCPU to test it if you like.
User avatar
koitsu
Posts: 4201
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: What 65816 test analogous to nestest?

Post by koitsu »

Yeah, the Apple II series has nothing like that that I can think of off the top of my head, but of course the last time I was deeply involved with the system was in the very early 90s. You Europeans and your fancy Commodore equipment... ;-)

There may be some other incredibly clever way to do this, but it gets into being clever with the hardware, which is again an area where I tend to bow out. References I can think of which might be helpful:

* http://www.1000bit.it/support/manuali/a ... erence.pdf -- for ROM01. This is probably where you'll find the answer / get an idea
* https://archive.org/details/Apple_IIGS_ ... Publishing -- firmware reference. This may also be where you'll find the answer / get an idea. Edit: actually, this is probably the best place to start looking for ideas, then maybe the above PDF for the rest. This is what documents the MMIO registers for a lot of the capability, but actual memory map and things like graphics memory layout are in the Hardware Reference (you really needed both sets of books)
* https://apple2.gs/downloads/Apple_IIgs_ ... ematic.pdf -- schematics. Not sure if this is of ROM00 (yikes! No!) or ROM01 (good/OK), but certainly not ROM03 (yes it is different)

I have some of these volumes in print, but finding proper digital copies is sometimes painful. I have a digital copy of an older (by 3 years) draft version of the IIGS Hardware Reference if needed: better scan (B&W), OCR'd (so you can search for words), and not photos of just "an open book stuck on a scanner bed where half the time the text can't be read" (whoever did that scan really didn't bother checking the quality of their work. Sad).

I'm sorry that I'm not throwing tons of effort into diving in and coming up with the method/answer myself, despite my IIGS background, but you could say my heart just isn't in it for something like determining a 1 cycle variance on a specific opcode addressing mode that is probably not commonly used given its design. I can't even remember how much CPU time (cycle-wise) VBlank is on the IIGS, for example. It's been that long.

Usually for "amount of time" visual representations, cycle-wise, we used the technique briefly mentioned here (used bits 3-0 of $C034), but it isn't precise. For example, I can't tell you how many CPU cycles it would take to get something "visual" that was consistent, enough where you could tell the difference between, say, 5000 and 6000 cycles. Maybe instead just using the entire screen filled with a single colour (ex. colour #0) then adjusting palette selection when doing a whole series of jmp ($xxxx)s, and resetting the actual palette colour back to a different colour, on a per-scanline basis, would work (sorry, IIGS terms here). I mention tweaking the palettes instead of actually updating the on-screen video RAM because the former involves way less bytes.
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: What 65816 test analogous to nestest?

Post by Oziphantom »

I'm an Ozzie, aka Aussie aka Australian, Commodores are half the price of the Apple computers and Commodore was an American Company.
You just fell for Apple's misleading marketing, they weren't even big in America ;)
niconii
Posts: 219
Joined: Sun Mar 27, 2016 7:56 pm

Re: What 65816 test analogous to nestest?

Post by niconii »

koitsu wrote:For example, I can't tell you how many CPU cycles it would take to get something "visual" that was consistent, enough where you could tell the difference between, say, 5000 and 6000 cycles.
If it's still not precise enough, just keep adding 0s until you can measure it with a stopwatch. Or a sundial...
nocash
Posts: 1405
Joined: Fri Feb 24, 2012 12:09 pm
Contact:

Re: What 65816 test analogous to nestest?

Post by nocash »

I had never thought about using sundials for hardware tests... but for long-term test results, that's probably really more accurate than using quartz oscillators, or even ceramic resonators. Then on the other hand, https://www.3dbrew.org/wiki/TIMER_Registers claims that 3DS timers"run at a frequency of 67,027,964.0 ± 2-32 Hz" so the estimated error would be about ±1 cycle per century, or less than ±1 second per billion years... if that's true then a 3DS might outperform sundials : /

For measuring opcode timings with low frequency timers, I have used someting like this: Execute opcode, Increment counter, Repeat until vblank. That's more than accurate enough, but can get slow when testing hundreds of different opcodes.

PS. 65C02 being an 8bit CPU, it makes sense that it would be 1 cycle slower on 16bit increments than a 16bit CPU (or than a 8bit CPU tht lacks proper page wrapping).
Last edited by nocash on Sat Feb 16, 2019 11:44 am, edited 1 time in total.
User avatar
koitsu
Posts: 4201
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: What 65816 test analogous to nestest?

Post by koitsu »

Oziphantom wrote:I'm an Ozzie, aka Aussie aka Australian, Commodores are half the price of the Apple computers and Commodore was an American Company.
You just fell for Apple's misleading marketing, they weren't even big in America ;)
Actually, they were big in America -- particularly in schools, which is exactly where most people around my age got introduced to them (I'm 42). Nearly every school I attended growing up had Apples. Other folks that had them were enthusiasts, since at the time the original Apple II debuted, the concept of a "computer at home" was considered ridiculous except to engineers and nerds. And much like the Famicom/NES, they were designed minimally and on a budget (Jobs wanted to maximise profits); Wozniak was a genius in a way, but all of that didn't necessarily make for a more "capable" machine (compared to C64, Amiga, and PC); a great example of serious design annoyance on the Apple II were "screen holes", something I really hate remembering.

I certainly won't deny that the Apple's stuff was overpriced: I still have the original store purchase receipt for my IIGS in December 1987 (it was RTM September 1986): US$2809.40, including monitor + floppy drives + RAM upgrade + printer + software (I didn't get a SCSI controller and HDD until ~1991). Not much has changed with Apple and their inflated prices. :-)

I should add that I've never been an "advocate" for any particular kind of computer from any company, nor did I have a fixation on Steve Jobs (Wozniak was always the guy who I felt more in line with); despite being brought up on Apple hardware, I was never an "Apple II zealot", though that attitude was rampant in the Apple II community (and did in the Macintosh community too -- still is, just that the worship today comes in a different form). My home had an XT growing up, but it wasn't until late 1993 when I managed to buy my own personal computer (486 DX2/66) that I really felt like I had something that was capable of all the things I wanted and had been missing out on. It took me a little over a year to "ween" myself off of the IIGS (I gave away my entire setup to my demogroup-mate, and looking back on it now, I honestly wish I hadn't). I'll always have a soft spot for the thing, but I wish I'd gotten a PC (or even an Amiga) a lot earlier. But, I certainly wouldn't have done my SNES docs or my NES docs had I not been brought up on Apple II hardware and gotten to know 65xx.

Regardless, if you haven't read Jobs' biography and Wozniak's autobiography, I would highly recommended both.

Anyway -- I could say the same thing of Commodores and Amigas: I only knew one kid at school who had a C64 (most people had nothing, else an Atari or TI computer), and not until 1993 did I encounter anyone with an Amiga (A500), after which I managed to meet 3 more who did (A1200, A2000, and A4000). I still find them more or less "obscure" in the United States. Point: when it comes to discussing 80s/90s computers, region/demographic matters tremendously.
nocash wrote:PS. 65C02 being an 8bit CPU, it makes sense that it would be 1 cycle slower on 16bit increments than a 16bit CPU (or than a 8bit CPU tht lacks proper page wrapping).
Having hardware folks around is always helpful. :-) Then this would explain the added cycle on the 65c02 for sure, and why the added cycle doesn't apply to the 65816. I'm not even sure I need to go code anything up given this statement!
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: What 65816 test analogous to nestest?

Post by Oziphantom »

Big is a relative term. So yes America was Apple's no1 and largest market, and if you compare Apple in the USA to Australia(and everywhere else), Apple was big in the USA. However they were small in the computer market. Apple were always 3rd in the race and not just 3rd but dead 3rd. Tandy TRS-80 line was the 2nd personal computer and the no1 in America for a long time, until the Tandy 1000 range took over their "80" range. The first personal computer the P.E.T was the worlds number one, however it was a solid 2nd in the USA. The PET and TRS-80 sold in the 6 digits, Apple ][s where 5 digits by the time the VIC-20 came out. The VIC-20 sold like hotcakes in the US(hitting 7 digits in under a year), then the C64 dominated, the 128 carved out a nice corner of the market. Apple pushed into the education market hard and a lot of schools had them ( here as well ) however it didn't really help them that much in the end. While they designed the Apple ][ to be low cost, it still cost double the P.E.T and the P.E.T was the first computer out. To be fair the first model P.E.T had a chiclet keyboard which sucked infinity but they fixed it quickly. And the PET doesn't have bitmap graphics, or colour. The Apple II disc drive was the fist on the market and was a brilliant piece of engineering, however the way it was built into the machine became a curse more than a benefit I feel.

Don't believe a single word that comes out of Steve Jobs's mouth, the guy has a reality distortion field that could deflect a nuke http://www.righto.com/2012/02/apple-did ... power.html and http://www.righto.com/2017/10/the-xerox ... puter.html

I do recommend this book https://www.amazon.com/Sophistication-S ... 0986832278 it does its best to dance around and conveniently not mentions some other things that had happened at the time, but it does have to stare down the barrel of reality sometimes, even if it does claim Woz invented the "monitor"

If you want to know what the Apple revisionist have removed and what Apple has slapped their name on, read this one https://www.amazon.com/Commodore-Compan ... 0973864966 although be prepared for some face palming because Man at the end Commodore's management really really did some dumb stuff.. its no accident the company is no longer around...
Post Reply