

The 6502 microprocessor is 35 years old as of September 16th - pietrofmaggi
http://leoville.com/6502-turns-35

======
chrisb
Ah, memories, memories.

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...

~~~
gaius
I have a copy of _Beyond BASIC_ , the BBC Micro 6502 manual, here on my desk!

The Tube version of Elite was amazing.

~~~
jacquesm
The book that really rocked my world was 'advanced programming techniques for
the BBC micro' by McGregor and Watt, I still have it somewhere. 3D graphics,
animations sorting & searching, all the good stuff, and explained in a way
that made sense to me.

~~~
gaius
That rings a bell - I may even have a copy of it at home!

------
DiabloD3
Don't forget what the 6502 was in. The NES used it, the Apple II used it, and
the C64, and a few early arcade games, and the early Ataris. The SNES used the
16 bit variant of it called the 65C816, as did the Apple IIGS.

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.

------
mahmud
My first language that wasn't. I taught myself 6502 asm before I have even
seen it run. The local British Council library (UK sponsored library going
back to colonial times) had 3-5 books on computer programming, all of which I
memorized. Among those books was one on the BBC Micro assembly programming.

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.)

~~~
limmeau
So you taught yourself 6502 assembly language while there were already
internet cafes? When was that?

~~~
mahmud
1996

------
pietrofmaggi
After all these years the 6502 (in his reincarnations) it's still alive,
selling million of pieces (but at 200MHz).
<http://www.westerndesigncenter.com/wdc/index.cfm>

~~~
rbanffy
Wow! Just imagine a 200 MHz Apple II!

------
rman666
In 1979, at age 16, I saved money from my paper route and purchased my first
computer, an Ohio Scientific (OSI) C2-4P, from Allied Electronics in West
Allis, Wisconsin. It had a 6502 microprocessor and 4K(!) of RAM. I used a
cassette tape recorder for mass storage (transfer rate was 300 baud), and an
RF converter and a television set as my video monitor. This provided a
stunning monochrome 80×40 character display!

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?"

~~~
joe_bleau
Wait, you had 80 columns through an RF modulator on a TV? Wow. I thought it
would be pretty fuzzy at 40 columns.

~~~
rman666
My memory is probably failing me. Gads.

------
jeffbarr
As it does for many others, news of this chip brings back fond memories.

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.

------
pietrofmaggi
BTW: Commondore keeps a page on the history of MOS and the 6502 with a lot of
insights:
[http://www.commodore.ca/history/company/mos/mos_technology.h...](http://www.commodore.ca/history/company/mos/mos_technology.htm)

------
rbanffy
A couple weeks back I was catching up with the Retrobits podcast and listened
to this interview with Chuck Peddle:

<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.

~~~
nonane
Awesome - thank you for sharing. Excellent interview. Chuck Peddle was the guy
who made / marketed the 6502. Lots of history here including mentions of the
C64, Apple I, Steve Jobs, Bill Gates, Basic, TI.

------
jedwhite
Ah memories :)

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 RTS

------
allertonm
I first* learned programming on a 6502-based machine with 1K of RAM and no
assembler or basic (Microtan 65, in case anyone remembers that.)

Luckily 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.)

~~~
gecko
Just to be explicit: you mean you programmed it purely with opcodes,
presumably compiling by hand a program you'd figured out earlier?

~~~
allertonm
Yes, I programmed it purely with opcodes. The machine was just running a very
basic "monitor" that let you write instructions and data into memory in hex
and then let you run them.

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 :)

------
ojbyrne
I was surprisingly impressed by meeting Brad Templeton in Silicon Valley in
~2006, not because he was a board member at the EFF, nor that he founded
Clarinet, but because he wrote PAL, an assembler for the C64 that I used back
in the day.

------
michael_dorfman
After all these years, I think the 6502 instruction set is still the one I
know best.

~~~
jacquesm
I only remember 0x00 and 0xEA these days :)

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.

~~~
mtkd
Did any peer chip have a mul in the late 70s/early 80s?

~~~
jacquesm
6809 did 8x8 mul.

~~~
pietrofmaggi
6809 was one of the first to have a mul instruction, and was used in the
initial development of the macintosh:
<http://www.folklore.org/StoryView.py?story=Good_Earth.txt>

------
knuckle_cake
Maybe this is a good time to toss up the half-finished 6502 simulator I have
kicking around.

------
danbmil99
My first assembly language. Ahh, the beauty of limitation

------
hackermom
Related: <http://www.visual6502.org/JSSim/index.html>

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.

~~~
samlittlewood
Wow - that was made by extracting the gates & nets from de-packaged die
photographs! It is actually a transistor & wiring simulator (in javascript)
that has a 6502 description loaded (and a simulated memory device tied to the
pads)

