Page 1 of 3

Weird JMP problem

Posted: Sat Mar 02, 2013 3:34 am
by Mercury1964
Hello!
I am currently building a 65c02 computer, and have an odd problem. The JMP and JSR opcodes, instead of jumping to the correct locations in memory, will often jump to a random address. I have not experienced this with any other operation. The bug occurs frequently and I have yet to find a reason or a solution for it. Anyone have an idea?
The model of CPU is the W65C02S6TPG-14. The computer is constructed on breadboards, with a CY7C199-35PC 32K SRAM IC directly connected to address lines 0 to 14. My code runs fine in multiple 6502 emulators, just a simple jump back to $0000.
Thank you in advance,
John

Re: Weird JMP problem

Posted: Sat Mar 02, 2013 3:44 am
by GARTHWILSON
Are all the other instructions working right? What kind of construction? I ask because this processor's edges may be too fast for especially the solderless breadboards.

Re: Weird JMP problem

Posted: Sat Mar 02, 2013 4:01 am
by Mercury1964
Construction is on a solderless breadboard, about 3 of them all packed together. I'm using telephone wire for jumpers. I haven't tried all of the other instructions, but NOP and BRK work fine. The computer is being single-stepped.

Re: Weird JMP problem

Posted: Sat Mar 02, 2013 4:30 am
by GARTHWILSON
I've never heard of a problem like that, but solderless breadboards are the worst of all worlds for this kind of thing. Still, if you have a clean clock signal and the phase 0 input is connected with very short wires to the clock source, ie, no flying or bundled wires, it should still work, especially if you mean you are single-cycling it. Otherwise the wires act as inductors and antennas talking to each other and edges from other wires will couple into the clock input causing unwanted extra triggering. This kind of construction also makes for a ton of groundbounce that has a similar effect. The page entitled, Construction: Avoiding AC-Performance Problems in the 6502 Primer should be a good guide, and has links to more. I wouldn't rule out that your problem is something entirely different, but encouraging beginning builders to get off to a better start can prevent a lot of frustration for them.

Re: Weird JMP problem

Posted: Sat Mar 02, 2013 6:50 am
by Arlet
How are you implementing the single step ? If there are glitches on the clock, that could cause some problems.

Re: Weird JMP problem

Posted: Sat Mar 02, 2013 7:38 am
by clockpulse
Mercury1964 wrote:
The computer is constructed on breadboards
What's the clock speed?

Re: Weird JMP problem

Posted: Sat Mar 02, 2013 1:49 pm
by Mercury1964
I did mean single-cycled, sorry about that. The clock is a monostable multivibrator made from a 555 timer with a transistor to invert the signal. Before the computer had its RAM, I directly wired the data lines to NOP, and the clock didn't have any issues advancing through memory. Also, I noticed something else with the issue: the longer I wait between cycles, the more likely the bug is to occur.

Re: Weird JMP problem

Posted: Sat Mar 02, 2013 2:10 pm
by BigEd
Will the clock edges be adequately fast? Both JMP and JSR have to route the final operand byte (the MSB) direct from the data bus at the close of the final cycle out to the address bus at the beginning of the next cycle. Is the MSB corrupt, or both bytes of the address? Has any other opcode with an operand worked?

Re: Weird JMP problem

Posted: Sat Mar 02, 2013 2:45 pm
by Mercury1964
I don't have an oscilliscope yet, so I don't know. Also, I looked and saw that this also occurs with NOP. It seems that if I wait in the first cycle of the instruction, the next address will be incorrect. I'm still probing the JMPs, though.

Re: Weird JMP problem

Posted: Sat Mar 02, 2013 3:14 pm
by BigEd
Ah, that's good, if it's not just JMP - less mysterious!

Re: Weird JMP problem

Posted: Sat Mar 02, 2013 3:35 pm
by Mercury1964
Okay, new data with JMP. I put a jump to $0000 at address $0000 and put a few dozen NOPs behind that. When I cycled through it, it got to the high-order byte of the JMP command. Then, the address lines went blank for ~3 cycles or so before resuming at the next NOP instruction, appearing to have just skipped the jump. I'm thinking that before, when I wasn't using a NOP buffer after the instruction, it would reach the next instruction (BRK or some other, random opcode - i didn't clear the entire RAM space) and would produce the odd results. I still don't really know.

Re: Weird JMP problem

Posted: Sat Mar 02, 2013 4:03 pm
by BigEd
By blank do you mean zero?

Re: Weird JMP problem

Posted: Sat Mar 02, 2013 6:25 pm
by Mercury1964
I don't know. Because the monitor is in between the RAM and the 65c02, I would assume so.

Re: Weird JMP problem

Posted: Sat Mar 02, 2013 6:29 pm
by Mercury1964
The monitor is 16 LEDs in a DIP package, to be specific.

Re: Weird JMP problem

Posted: Sat Mar 02, 2013 6:34 pm
by GARTHWILSON
Do you have current-limiting resistors on the LEDs?