-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BBR0 not recognised correctly on 65C02 CPU #10
Comments
BBR/BBS is actually supported, but only if you specify an appropriate CPU type. Try specifying --cpu=R65C02 It should also work with --cpu=W65C02, but looking at the code there is currently a bug in that case. What's your understanding of which manufacturer's 65C02 include the Rockwell/WDC extensions (BBR/BBS/RMB/SMB)? This is my understanding:
Can you think of any other cases? I think the only one that's currently incorrect is W65C02 BTW, this is my go-to reference for all things 65C02: I also don't think I correctly handle the WDC-only WAI and STP instructions, because they are variable (potentially infinite) length, and because I have never seen any code that uses them. |
Ah yes, R65C02 works perfectly, thanks! I'm afraid I don't know much about which CPUs provide which instructions as I've mostly stuck to the NMOS instruction set. For STP I imagine all that's needed is to watch out for a reset sequence and then continue from there. It's not an instruction I've used though. WAI seems trickier, but so is anything related to RDY really unless it's being sampled by the logic analyser. If RDY is sampled then I would have thought WAI would work fine, as it pulls RDY low to pause the CPU - it should be observable by the logic analyser. RDY could probably be connected to PA4 to prevent sampling when it's low, in fx2pipe modes at least, without requiring 16-bit sampling - this kind of control works very well for me with the CPU's reset pin. Otherwise, it looks like after WAI is executed the logic analyser sees the next opcode repeated until WAI ends, then execution resumes as normal. The decoder didn't recover very quickly from the desyncs this caused. It is probably unlikely that there would be many (if any) identical bytes in memory following the WAI instruction, so it may be a fairly safe bet to assume that if the data stream is not changing then the WAI instruction is still waiting. Otherwise I think you'd need to consider backtracking if there's a prediction fail soon after the WAI instruction, and trying again with it consuming fewer cycles. That sounds pretty complex, unless it's something you already have support for! But if RDY is wired through to the logic analyser then it would be best not to do anything heuristic I think. |
Being curious, I did some experiments with WAI and STP - I built a simple system to test this in with just the CPU and some ROM, so there'd be no complications. STP is indeed pretty simple, it just stops, and the opcode at the following memory address repeats on the data bus forever until the next reset. As far as I can tell, RDY mostly behaves like a three-cycle instruction, except it pulls RDY low if there are no pending interrupts. In particular, if IRQ is already low, then RDY is not pulled low at all, and WAI finishes in three cycles. In addition, if I let the logic analyser see the state of RDY by wiring it along with nRESET through a NAND gate, then it prevents sampling when RDY is low, and in all cases I checked, WAI then appears - to the decoder - to have taken three cycles. I tested interrupting WAI with a masked interrupt, as well as with an NMI. Looking in the code, it looks like WAI was set to be a single cycle instruction ( Line 2012 in fa605b1
So I think this is promising as a way to support WAI, at least if the user hooks RDY up to PA4 or PA5 appropriately. I tested this mostly with "--ifclck=xi" and a 10MHz clock, but it also seemed to work with "-a" and a 1.8MHz clock. |
Thanks for that investigation George. I'll update the decoder with those changes, but it may take a few days as my main/ancient dev machine has died and I'm awaiting a cheap ebay HP Z440 to replace it. |
Hi Dave, hope you're well!
I've been debugging a Dormann test fail, and found that the decoder doesn't seem to understand opcode 0F (BBR 0). Here's the relevant part of the Dormann listing, and the decoder's output given the byte sequence you can see here - it looks to me like it just didn't understand the 0F opcode:
The command line I used was:
I've also attached the data file for reference:
data14.bin.gz
The text was updated successfully, but these errors were encountered: