Author Topic: 6502 CPU Stepper  (Read 1316 times)

0 Members and 1 Guest are viewing this topic.

Offline Bigmalc40Topic starter

  • Newbie
  • Posts: 4
  • Country: gb
6502 CPU Stepper
« on: September 24, 2022, 12:20:34 pm »
Hi Guy's,
              Just come across to this site while researching an old 7 segment LED, unfortunately I didn't find the information.
However maybe there is someone who may be able to suggest some advice to my new question.
I want to debug an Old 6502 computer which is no longer working and think a single step circuit for the 6502 chip would be of some use to me.
Does anyone have Experience with the 6502 CPU and could provide a Single Step Circuit.
Thanks

Bigmalc40
 

Offline Ed.Kloonk

  • Super Contributor
  • ***
  • Posts: 4000
  • Country: au
  • Cat video aficionado
Re: 6502 CPU Stepper
« Reply #1 on: September 24, 2022, 12:36:00 pm »
Hi Guy's,
              Just come across to this site while researching an old 7 segment LED, unfortunately I didn't find the information.
However maybe there is someone who may be able to suggest some advice to my new question.
I want to debug an Old 6502 computer which is no longer working and think a single step circuit for the 6502 chip would be of some use to me.
Does anyone have Experience with the 6502 CPU and could provide a Single Step Circuit.
Thanks

Bigmalc40

A youtuber, Ben Eater has a whole channel dedicated to building 6502 kits. I remember he made a clock circuit which would allow advancement of the program counter via a push button.

https://www.youtube.com/c/BenEater/featured
iratus parum formica
 

Online CountChocula

  • Supporter
  • ****
  • Posts: 199
  • Country: ca
  • I break things—sometimes on purpose.
Re: 6502 CPU Stepper
« Reply #2 on: September 24, 2022, 01:09:28 pm »
A youtuber, Ben Eater has a whole channel dedicated to building 6502 kits. I remember he made a clock circuit which would allow advancement of the program counter via a push button.

https://www.youtube.com/c/BenEater/featured

Ben's videos are great, but please do keep in mind that he's using a modern CMOS version of the 6502, which has a completely static core. Old-timey chips from the 80s cannot be stopped and single-stepped by supplying individual clock pulses—they need a minimum frequency to operate correctly.

It might help to hear a bit more about what kind of debugging you're thinking about… perhaps you could achieve your goal without single-stepping, but that's hard to say without more specifics.

You could also ask on 6502.org. Lots of friendly advice from people who have done all sorts of things with (and to) the 6502.

Cheers!
Lab is where your DMM is.
 
The following users thanked this post: Ed.Kloonk, Bigmalc40

Offline Bigmalc40Topic starter

  • Newbie
  • Posts: 4
  • Country: gb
Re: 6502 CPU Stepper
« Reply #3 on: September 25, 2022, 05:52:56 pm »
Thanks Ed, there's so much stuff there, I shall have many happy hours reading though them though I can't see any mention of a 6501 stepper.
 

Offline Bigmalc40Topic starter

  • Newbie
  • Posts: 4
  • Country: gb
Re: 6502 CPU Stepper
« Reply #4 on: September 25, 2022, 05:57:05 pm »
Hi Count, Thanks for responding to my post, I don't know what you mean by "a modern CMOS version of the 6502, which has a completely static core", What is this?

Regards

Bigmalc40
 

Online CountChocula

  • Supporter
  • ****
  • Posts: 199
  • Country: ca
  • I break things—sometimes on purpose.
Re: 6502 CPU Stepper
« Reply #5 on: September 25, 2022, 07:24:22 pm »
Hi Count, Thanks for responding to my post, I don't know what you mean by "a modern CMOS version of the 6502, which has a completely static core", What is this?

Hi! If your device is really old, it probably uses an older 6502 made in the 80s or 90s. These chips are quite different from the modern 65C02 that is still made and sold by WDC today, like the one that Ben Eater uses in his videos.

The modern 65C02 has what's called a “static” core that can be stopped and held in its current state for an indefinite period of time (as long as you supply the appropriate voltage and meet a few other conditions). This allows you to single-step the processor by supplying clock pulses that come at arbitrary intervals; you can quite literally pulse the clock by hand (though you need to be cautious of bounces), and the CPU will happily follow along, once cycle at a time. This is actually pretty cool, because you get to see a lot of what the processor does as it works its way through executing each operation.

The old 6502s, like, say, the stock ones you might find in an Apple II or a Commodore 64, cannot do this; they must be supplied a clock of a minimum frequency, or they will misbehave and exhibit unpredictable behaviour. I can't remember the exact minimum frequency, but IIRC it's at least several kHz. If you try to single-step them using Ben's approach, you will get all kinds of confusing weirdness.

There is, however, a trick that you can use even with the old CPUs. IIRC, it was something that Woz came up with and takes advantage of the CPU's ability to suspend execution using the RDY signal. I've attached the circuit below, but never tried it myself, as I typically use modern CPUs. I hope this helps!


—CC

Lab is where your DMM is.
 
The following users thanked this post: edavid

Offline coppice

  • Super Contributor
  • ***
  • Posts: 8642
  • Country: gb
Re: 6502 CPU Stepper
« Reply #6 on: September 25, 2022, 09:21:22 pm »
The old 6502s, like, say, the stock ones you might find in an Apple II or a Commodore 64, cannot do this; they must be supplied a clock of a minimum frequency, or they will misbehave and exhibit unpredictable behaviour. I can't remember the exact minimum frequency, but IIRC it's at least several kHz.
The original 6502 core used registers that were a lot like DRAM, and required regular refresh, just like DRAM. However, these cores had to be refreshed a lot more often than DRAM. I think the 6502 was similar to the 6800, and the 6800 needed a clock of at least 100kHz.
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 5870
  • Country: de
Re: 6502 CPU Stepper
« Reply #7 on: September 25, 2022, 09:40:00 pm »
The normal 6502 way to do single-stepping would be to have the program to be debugged loaded in RAM.
Setting a breakpoint would invoke the Monitor (no, not a CRT/LCD screen, but the resident ROM program) to insert a "BRK" instruction at the relevant location, which would then allow the user to examine the CPU registers and data involved. ("BRK" is a non-maskable software interrupt that should invoke an interrupt handler to display the data).
« Last Edit: September 25, 2022, 09:45:03 pm by Benta »
 

Offline coppice

  • Super Contributor
  • ***
  • Posts: 8642
  • Country: gb
Re: 6502 CPU Stepper
« Reply #8 on: September 25, 2022, 09:43:03 pm »
The normal 6502 way to do single-stepping would be to have the program to be debugged loaded in RAM.
Setting a breakpoint would invoke the Monitor (no, not a CRT/LCD screen, but the resident ROM program) to insert a "BRK" instruction at the relevant location, which would then allow the user to examine the CPU registers and data involved.
That is the approach a lot of early MPU evaluation boards used. Most instruction sets have some kind of software interrupt instruction which can be used in that way.
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 5870
  • Country: de
Re: 6502 CPU Stepper
« Reply #9 on: September 25, 2022, 09:49:08 pm »
Yep, and the only way you can do it with NMOS (and early CMOS) processors.
 

Offline coppice

  • Super Contributor
  • ***
  • Posts: 8642
  • Country: gb
Re: 6502 CPU Stepper
« Reply #10 on: September 25, 2022, 09:52:36 pm »
Yep, and the only way you can do it with NMOS (and early CMOS) processors.
There were some dynamic MPUs with specific single step hardware features. You had to keep the clock running with all dynamic MPUs, but that didn't mean instruction processing had to continuously proceed.
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4032
  • Country: nz
Re: 6502 CPU Stepper
« Reply #11 on: September 25, 2022, 11:17:32 pm »
The old 6502s, like, say, the stock ones you might find in an Apple II or a Commodore 64, cannot do this

C64, yes. I don't think the 6510 was ever updated.

I'm sure there were more Apple II made with CMOS processors than with NMOS 6502.

I found the following data, which the author admits is questionable:

Code: [Select]
Apple II          64,700
Apple II Plus    545,500
Apple //e      4,250,000
Apple //c        450,000
Apple //c Plus   200,000
Apple IIGS       979,000
Total          6,489,200

Apple //e made between January 1983 and February 1985 (just over two years) used the NMOS 6502, but those made between March 1985 and November 1993 (more than 8 1/2 years) used the CMOS 65C02.  As of course did the //c models, and the IIGS (65C816).

It's hard to find sales for individual models or years of the //e.  I've found one source that says there were 400k //es in 1983 and 1 million in 1984 (the peak). The same source says 300k total Apple II in 1990.

By elimination, 4,250,000 //e in total, minus 1.4 million NMOS ones in 1983/84, would mean  2.85 million CMOS ones. Added to //c and IIGS that makes 4.48 million CMOS vs 2.01 million with NMOS.

I'll bet its even more skewed if you find a working Apple II in an attic.
 

Offline lapm

  • Frequent Contributor
  • **
  • Posts: 564
  • Country: fi
Re: 6502 CPU Stepper
« Reply #12 on: October 02, 2022, 12:12:37 pm »
Hi Guy's,
              Just come across to this site while researching an old 7 segment LED, unfortunately I didn't find the information.
However maybe there is someone who may be able to suggest some advice to my new question.
I want to debug an Old 6502 computer which is no longer working and think a single step circuit for the 6502 chip would be of some use to me.
Does anyone have Experience with the 6502 CPU and could provide a Single Step Circuit.
Thanks

Bigmalc40

Have you verified there actually clock signal present and for example reset/irq/nmi lines are not stuck in wrong state?
Electronics, Linux, Programming, Science... im interested all of it...
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf