The 6502 microprocessor is 35 years old as of September 16th
leoville.com
leoville.com
The BBC micro model B was the first ever computer I programmed, at the tender age of 8 or 9. My dad was (still is, in fact) working in the computing department at a university all those years ago and managed to get us all kinds of nice little extras.
Like duel floppy drives - no tapes for me! And I didn't even realise how lucky I was until I visited a friend and we spend 20 minutes loading a game from tape. And visited another friend who saved some of his work to tape, only for the tape to get corrupted somehow, so it never loaded again.
Like sideways RAM. I always thought it was called this because it plugged sideways into the motherboard, but apparent this is not so: http://en.wikipedia.org/wiki/Sideways_address_space. This supported an extra 16kB (I think) of memory, and allowed us to run a complete word processor, and my dad used a Pascal compiler - which took up to half an hour to compile his code! I remember him setting it going over dinner... But it used to die on the first compile error found, which did tend to slow things down even more. And we had a daisy-wheel printer, which gave fantastic quality so long as you only required one font at a single size.
Then, a couple of years later, we got a 6502 co-processor connected via the 'tube' (http://en.wikipedia.org/wiki/Tube_%28BBC_Micro%29) - an expansion port on the BBC micro. This more than doubled the memory, and ran faster. But various optimizations didn't work. You could no longer write directly to screen address-space, as this was still in the hosts address-space, whereas user programs now executed in the co-processors address space. But, excitingly, there were API calls that allowed you to read/write to/from memory in the host system, so I wrote a (very simple) windowing system that stored the graphics contents beneath each window in the host memory, while executing on the co-processor.
The most ambitious programme I ever wrote was a sideways scrolling shooter game, which was written almost entirely in assembly, and could have up to 50 moving sprites on the screen at the same time without dropping frame-rate. Sadly I never fully completed it, as my dad had just got his first PC at the time and I moved over fairly quickly.
And of course, no discussion of the BBC is complete without mentioning Elite, which was a truely awesome game. They completely re-implemented line drawing routines, as the inbuilt ones weren't fast enough. And they used two screen modes _at the same time_ to allow high definition at the top of the screen, but only in black and white; and lower definition, but in colour, at the bottom of the screen. Try doing _that_ on a PC!
Sigh... Wonderful times... And all in less than 32kB of memory...
The Tube version of Elite was amazing.
I have fond memories many hours spent typing in game listing from a magazine ... and learning that you should always type 'save' before 'run' in case it crashed. And that was before we ever had a disk drive. I can still recall the tape noisy perfectly!
My son has expressed an interest in wanting to write a game rather than just play them, but it always seems to stumble on the fact that he is used for 50fps full 3D and the learning curve to produce anything like that is huge. 25 years ago you could type something in an afternoon that was comparable to something you could buy off the shelf.
Interesting side note: The Apple IIGS could run normal Apple II 8bit software and GS-only 16bit software... Nintendo had planned the same for the SNES, but bailed on the idea early on, afraid of the backwards compatibility cannibalizing SNES game sales.
Sony, who was an important part of designing the SNES, produced the SPC700 sound DSP (which had a 6502-like instruction set, its own RAM, and a normal DSP companion core to do mixing, panning, volume, and filtering).
Incidentally, Sony had a working prototype for a add-on CD drive for the SNES (it used the expansion port on the bottom most people didn't know existed, and the SNES would sit on the drive). The drive also included a secondary independent 65C816, sorta like SA-1 chip used in Super Mario RPG (which ran 3x faster, had its own RAM, could MMIO and DMA to hardware in the SNES and interrupt the main CPU to do so).
By the time Sony was ready to ship the device with Nintendo, the SegaCD add-on for the Genesis had already crashed and burned, and Nintendo decided to back out because they thought CDs had no future for gaming.
Sony decided to make their own console, replacing the Super Nintendo "component" of their CD add-on, and produced the Playstation. The Playstation sound chip was similar to the SPC700 (but vastly enhanced for CD quality audio), but the rest of the Playstation was decidedly not like a SNES.
Sony, during the development of the Playstation 2, decided to add backwards compatibility as a feature when Nintendo didn't.
It had a few worked examples. I used to cover the examples with a sheet, read the problem, then try to solve them before looking at the answer (since I didn't have a physical machine to test things.) -- I quickly came to appreciate that there was no canonical single "answer" in algorithms, and the only way to compare the "equality" of two solutions is see they leave the machine in the same state, given identical initial configurations .. very disturbing thoughts for a self-taught newbie programmer.
I did that for a few weeks and was bored. Then got Robert Lafore's book "Assembly Language Programming for the IBM PC and XT", and I killed it. Hard to explain this, but my first working assembly programs were quite advanced, because I have been "paper hacking" for quite some time by then. I wrote my first apps off of a floppy disk that I used to insert into internet cafe or library computers, when no one was looking (I didn't do any of the PC speaker tricks until much later, when I got my own computer.)
Within a few months I grew tired of the 15+ minutes it took to load BASIC into RAM from cassette and decided to learn assembly language. This was better since there was a "monitor" program in ROM and therefore always available immediately.
Today, I flip-flop back and forth between thinking, "Those were the days!" and "How could 30 years have gone by so quickly?"
I was hired for my first programming job at the age of 19 and was tasked with writing a macro assembler for the 6502 from scratch. My manager/mentor had already designed the basics, and handed me a big pile of notes and flowcharts on my first day or work.
Before diving in I wrote a FORTRAN version of the hashing algorithm that we planned to use, and found that we could improve performance considerably with a slight change (I got a raise for doing this).
I wrote the assembler in 6502 assembler, using an existing non-macro assembler that ran on our Ohio Scientific machine. I got it to the self-hosting point as quickly as possible so that I could use the advanced features that I had built into my version. We wrote a set of "default" macros to make the instruction set more regular, filling in some holes.
After some fine-tuning, I was able to compile macro-dense code at several thousand lines per minute. This was on a machine with two floppy disks and 48KB of RAM.
This was an incredible "first project," given that all of my 6502 programs before starting the job had run on my Apple ][ and would fit on a printed page.
I still have the listings for the assembler, and pull them out from time to time to reminisce.
http://retrobits.libsyn.com/index.php?post_id=505602
http://retrobits.libsyn.com/index.php?post_id=514107
http://retrobits.libsyn.com/index.php?post_id=517736
http://retrobits.libsyn.com/index.php?post_id=521785
Simply amazing.
Well, actually more like a lot of moving things around in memory...
MOVEDOWN LDY #0
LDX SIZEH
BEQ MD2
MD1 LDA (FROM),Y STA (TO),Y
INY
BNE MD1
INC FROM+1
INC TO+1
DEX
BNE MD1
MD2 LDX SIZEL BEQ MD4
MD3 LDA (FROM),Y STA (TO),Y
INY
DEX
BNE MD3
MD4 RTSLuckily the 6502's instruction set is pretty easy to memorize, used to know it back to front. Only 56 base instructions and once you understand the way the addressing modes affect the opcode for LDA it's easy to work it out for the others.
Glad I don't have to do that anymore, but it was a great grounding for all the high-level stuff that came later.
(*Well, unless you count my dad's 31-step programmable TI calculator.)
At first the machine did not even have a cassette interface, so there was no way to save programs and you had to type them in every time. The machine came with some examples, like Conway's "Life". Given that the machine really only had about 256 bytes of usable program storage (half the 1k was used for video) this wasn't quite as bad as it sounds but still pretty tedious.
Actually when I first got a cassette interface I still had to type the cassette loader in by hand to boot :( Eventually I got the rom expansion that included the cassette loader and an assembler.
Obviously writing a program directly into memory in opcodes does involve some upfront thinking, but you'd be surprised how "REPL-like" the coding experience could be :)
All the rest of them have slid in to the swamp of time. The 6502 was a funny chip with it's zero page access and lack of a 'mul', to some extent not having a mul makes you a better programmer (you'll have to roll your own, and that will lead you to discover look up tables for nibble sized chunks pretty quickly because of a perceived lack of performance), and the 'zero page' was a good preparation for knowing how to deal with memory with different degrees of accessibility (think of caching and demand paging).
I worked a lot with the 6809 as well, and that was a much richer instruction set (and more orthogonal too), but I did not learn as much from that as I did from the 6502 because of the more restricted environment on the 6502.
I believe my first 6502 based computer had all of 1K of RAM :)
Single board job with a hex calculator keypad and 6 7 segment displays and an fsk based tape interface.
A total perspective vortex of a sort ;)
Looking back, I had college courses on assemblers for 6809 (EE dept), 8088 (CSci), and IBM 370 (CSci - the banana book rocked). I wonder if that goes on anymore today.
Interview with Sophie Wilson, chief architect of ARM, October, 2001
Primarily the 6502. I learned about pipelines from it (by comparison with the 6800) and its designers were clear believers in the KISS principle. Plus the syntax of its assembler and general accessibility of it from the machine code perspective. I can still write in hex for it - things like A9 (LDA #) are tattoed on the inside of my skull. The assembly language syntax (but obviously not the mnemonics or the way you write code) and general feel of things are inspirations for ARM's assembly language and also for FirePath's. I'd hesitate to say that the actual design of the 6502 inspired anything in particular - both ARM and FirePath come from that mysterious ideas pool which we can't really define (its hard to believe that ARM was designed just from using the 6502, 16032 and reading the original Berkeley RISC I paper - ARM seems to have not much in common with any of them!).
A 6502 emulator in JavaScript, visualizing the actual core and its electric flow during operation, cycle by cycle, instruction by instruction. If this is not Hacker News worthy, I don't know what is.