Hacker News new | ask | show | jobs
by cdcarter 1761 days ago
Always love to see a 6502 post here on HN. It's a really unique processor compared to other 8-bit processors at the time. With only one general purpose register, and memory mapped IO, the 6502 offers a ton of "addressing modes" to solve problems that the 8080 would solve with register transfers.

Ben Eater (http://beneater.net/) makes a neat video series and accompanying product kit where you build a 6502 on a breadboard, if you're looking for something a little more approachable than this (very cool) project!

3 comments

A while back I tried writing an Atari 2600 game and got about half way (got sprites, collisions, level, just no goal)

The console uses a slightly cheaper version, the 6507 I think. Same chip, just smaller address line and no interrupts (!)

Instead you ran a "wait for the cathode ray to reach the right side of the screen" in order to time everything correctly.

Very fascinating stuff, I recommend anyone interested in the above dive in and give it a shot.

All you need is an editor[1] (I found one online!) and the stella manual[2].

There's something nice about having the entire machine spec in one book instead of leaning on stack overflow...

[1] https://8bitworkshop.com/v3.8.0/?platform=vcs&file=examples%...

[2] https://cdn.hackaday.io/files/1646277043401568/stella.pdf

2600 has been my obsession for a few years now. I too havent set a goal but I love to follow what other people are doing for it. The community is fantastic. There's a twitch and yt channel called ZeroPage Homebrew that usually streams twice a week. They exclusivley play homebrews and the devs are usually in the chat. They were 2600 only for a long time but recently started including 7800 and 8-bit.
There’s also no way to set the horizontal position of sprites other than waiting for the scan line to reach the position you want and yelling “NOW!!!”
It's a really fun architecture, agreed. I spent the last few months writing an assembler, formatter and language server for 6502 code. If you're interested, it's available at https://mos.datatra.sh
As much as I love the 6502, I have to say the 8080 has some very neat features that I wish I had with 6502, such as conditional returns (in other words, do a RTS only if a certain flag is set or not).
What significant advantage does that have over a conditional branch followed by an RTS?
Code density, and you could potentially save a few cycles with a single instruction. Whether that matters at all depends on how much slack you have in your utilization of available memory and CPU cycles. (Strictly talking about "old" CPUs here.)

It's worth noting that the 8086 got rid of conditional returns, you only have unconditional ones there.

A taken branch on the 6502 takes 3 cycles. A not taken branch followed by a Return From Subroutine instruction takes 2 + 6 cycles.

Looking up the conditional return instructions on the 8080 seems to show it takes 5 cycles when false and 11 when true.

So the two 6502 instructions add up to being two or three cycles faster than one 8080 conditional return.

Cycle counts are super misleading. These processors were limited by the speed of RAM, and cycles per RAM access differed. Suppose you have RAM running at 1 MHz... maybe your 6502 is also clocked at 1 MHz, and your 8080 is clocked at 4 MHz. I know you're not trying to compare 6502 performance to 8080 performance in general, just that there's a fairly wide variation in how much you can accomplish in a cycle, and "how many RAM accesses can the processor make" is probably what you want to look for, since it's a bit more directly comparable across processors of that era.
I was not trying to compare the 6502 with the 8080 here, and I said "potentially" exactly because it depends on the architecture wether it works out (and, as said, 8088/8086 removed the conditional returns). On the 8080 specifically, conditional returns seem to be a little cheaper overall.
It’s only fair to compare cycle numbers if you also compare cycle times.