169 points · by unwind · 13y ago · 33 comments
My first real programming job entailed writing a blazingly macro assembler from scratch for the 6502, using a much slower (and non-macro) assembler from the vendor (Ohio Scientific, for those of a certain age).
I simulated the proposed hashing algorithm in FORTRAN at the community college I was attending, and found that it led to a lot of collisions for the base 6502 opcode set. When I pointed this out to my manager (who's still my friend 32+ years on), he made sure that I got my first raise.
I still have those listings and the original design documents around somewhere.
And this is 30 year old tech. The 6502, the processor in you cell phone is about 1000x faster than it (and much more capable)
To me the hardest part (apparently) is converting the electronic circuit to the actual chip drawings. Not sure how this is done (how do you route it). And this was done by hand in the 6502, the drawings were done the size of a desk and reduced photographically. (IIRC)
Here's an article about it too: http://research.swtch.com/6502
Not only did they route / layout by hand-drawing, and then cut the Rubylith photomask by hand (it's not a drawing they use to reduce it photographically - they cut out holes..), but Bill Mensch got it right the first time. 3,510 transistors according to the article.
Bill Mensch left MOS to found Western Design Centre quite early, and so is covered less in that book than Chuck Peddle which was instrumental in Commodore for a long time after they acquired MOS. The amazing thing is WDC still sell variations of the 6502 design, including various replacements such as a 16 bit version.
Peddle (the other main designer) and Mensch deserve a lot more attention than they've gotten.
(EDIT: From WDC's website: "Annual volumes in the hundreds (100’s) of millions of units keep adding in a significant way to the estimated shipped volumes of five (5) to ten (10) billion units. " Yikes...)
I've seen that story before that the 6502 worked perfectly the first time, but I think there's some mythologizing going on. The ROR instruction was totally broken on the first release of the 6502 and wasn't fixed until months later. [1]
The quote above says that the 6502 has 3510 transistors, and this number appears many other places. It turns out that the 6502 has 3510 enhancement transistors and 1018 depletion transistors, for a total of 4528 transistors, according to the visual6502 analysis.
And if you're interested in the inner workings of the 6502, you should definitely check out the huge transistor-level schematic at: http://www.downloads.reactivemicro.com/Public/Electronics/CP...
[1] http://en.wikipedia.org/wiki/6502#Bugs_and_quirks and details at http://www.pagetable.com/?p=406
http://www.kickstarter.com/projects/textfiles/the-jason-scot...
In any case, the main thing is that a lot of MOS' early success came from saving a tremendous amount of money being able to get to market quickly and cheaply compared to the competition thanks to actually having guys like Mensch and Peddle coupled with superior process (though that did not last all that long).
Now, normally you have to worry about increasing clockspeeds having diminishing returns, since memory latency remains constant despite a faster CPU clock. But anything that could run on the amount of RAM the 6502 could handle would fit in a modern processor's L1 cache, and the scheduler is perfectly able to hide L1 latency so I think ignoring this factor is fair in this case.
This all gets a bit complicated in modern days because of memory access costs and caches which try to alleviate the costs, but the idea is that modern CPUs are likely to be around 10 times as fast per-clock as 6502 and because of multiple cores and threads that value goes to something like 40-60. Add the huge increase in clock speed and you're a bit south from x100_000 in optimal case.
I would hope every programmer would write some core on a C64 to really learn how much RAM the 64 KB really is. You can actually waste some of it and in some cases it really is "enough so that I don't have to optimize". :) Real hard-core people would go with VIC-20 which as only 5120 bytes of RAM, or Atari 2600 with 128 bytes of RAM. One could imagine there's nothing you can do with them but oh boy how wrong one would be! Heck, a single tweet is 140 characters. And you can fit that in 128 bytes. You really can... :)
One order of magnitude: 10x
Two orders of magnitude: 100x
Three orders of magnitude: 1000x
[0] Of course, that's ignoring multiple cores, better microcode, caches, etc.
How MOS 6502 Illegal Opcodes really work http://www.pagetable.com/?p=39
I just finished a 6502 emulator, I recommend doing it for everyone. Lots of fun and very interesting.