
Easy 6502 - anigbrowl
http://skilldrick.github.com/easy6502/
======
Macsenour
I ported Serpentine for Broderbund to the C64 and a few other games for other
publishers. After I changed to being a Producer, I thought I would ever
program in 6502 again.

Then years later, I was given the task to program toys, all in 6502. I did a
Little People Farm, Little People Phone, a musical jumprope and a reading of
Goldielocks and the three bears.

I think the 6502 will never die.

~~~
mnicole
This is such a silly question, but are you the one that made the barn door on
the farm moo when it opened?

~~~
Macsenour
lol probably! Does it not work right?

~~~
mnicole
No way - just the opposite! In fact I think it worked the last time I ever saw
it years later. That was an incredibly memorable piece of my childhood, and
apparently that of many others' as well:
<http://dribbble.com/shots/680831-Fisher-Price-WIP-2> (wherein I also mention
that feature).

~~~
Macsenour
I'm proud of the phone too. It taught kids their own home phone number in a
really cool way. I didn't design the features, I just programmed them. I
wonder how many kids called home because they learned their number from this
toy.

------
OldSchool
What a luxury an assembler was compared to writing programs directly in hex
where LDA # was $A9 nn, JMP was $4C aa aa, and RTS was $60 for example. Your
brain would just about as quickly speak hex, though calculating relative
branches (limited to a 256 byte range) was a "two pass" mental operation. I
still have the green Rodnay Zaks book.

~~~
kragen
The funny thing is that an assembler that calculates relative branches for you
is a pretty simple program. Why did people spend so much time without writing
one?

~~~
OldSchool
I can't speak for everyone but having 1K of total RAM and no cross assembler
from which to write that first native assembler were enough to stop me from
attempting it :)

~~~
kragen
Yeah, the RAM limitation in particular requires a lot of creativity; this
version would use the entire 1K for its label table:
[http://lists.canonical.org/pipermail/kragen-
discuss/2012-May...](http://lists.canonical.org/pipermail/kragen-
discuss/2012-May/001234.html)

Did you have any external media available, or just the RAM?

~~~
OldSchool
Unfortunately just RAM, lots of time and the mind of a 12 y/o!

~~~
kragen
Probably about the best you could do then would be to interactively assemble
code (probably without mnemonics!) and output the assembled version. You could
probably do a reasonable interactive assembler without mnemonics in 256 bytes;
not sure about base64 input and output (four letters/numbers per 3 bytes of
code!), or error correction.

Did the machine not even have a memory of what was on the screen? Because
that's usually at least 2K, and that would go a long way.

------
thomasfl
This bring back childhood memories. I remember creating an interrupt
subroutine in assembly on my commodore 64 that listened to the push button on
the joystick and quickly changed the background colors on the screen. If I
pressed the button it looked like the monitor flickered. Played lot's of
pranks with my friends with that hack.

~~~
ghshephard
I'm right there with you. I recall there was a Horizontal and Vertical refresh
interrupt, and you could catch that horizontal refresh (when the scan line was
returning from the right side to the left side) and switch video modes from
graphics into text cleanly, then, on the vertical refresh, when the scan line
returned to the upper left hand corner, switch back to graphics mode. Allowed
you to (easily) display images and text on the screen at the same time
(graphics on top part of screen, text below whatever horizontal line you
decided to switch back to text)

~~~
vidarh
It was a single interrupt, but you could trigger it on a specific scan line by
storing the number of the scan line in $D012. So to do stuff during the
vertical blank you'd just need to set $D012 to a large enough value.

It was/is the bread and butter of the C64 demo scene.

------
Kurtz79
"I don’t think you’ll ever have to write assembly language in your day job"

Not completely true. My company for example develops embedded systems for
trains.

These systems can have a lifespan of decades, where they see daily use, and
there's no reason for the customers to upgrade, but they might ask a change or
some new functionality over the existing system.

Not me personally but I know of a few engineers that every now and then have
to roll up their sleeves and write assembly. I would be surprised if this is
not somewhat common, for companies mantaining long term systems.

Nice article BTW.

~~~
lttlrck
Assembly is still the best way to leverage small microcontrollers and they're
big business (AVR, Microchip). And a lot of fun BTW.

------
dirkk0
Which reminds me of Notchs upcoming(?) game with the DCPU-16.
<http://dcpu.com/dcpu-16/> <http://0x10co.de/> Assembler know-how might be in
demand soon.

------
mdwrigh2
Previous discussion: <http://news.ycombinator.com/item?id=4213806>

~~~
anigbrowl
Good catch and well worth reading. I thought there was something familiar
about the link but oddly HN didn't refer me back to the earlier thread.

~~~
jacquesm
HN will never refer you to an earlier thread unless the URL matches exactly.
See the '/index.html' suffix on the original and the lack thereof on this one,
that's the difference that allowed you to submit the URL for a second time.

~~~
spullara
It is awesome though, I enjoyed it the first time, and apparently no one saw
it because it is now at the top of HN.

~~~
jacquesm
Yes, it is awesome. When I learned how to program 6502 asm the best you could
do was to buy Lance Leventhal's book and cobble together your own assembler,
now you can learn the same thing interactively in a browser. 30 years
difference.

~~~
sageikosa
Machine code monitor on the Apple ][+...had to calculate jump offsets in my
head.

~~~
spullara
On the C64 I had the monitor cartridge. Always great when you had to block
move memory to add an instruction in the middle. Converting things to data
statements was also fun.

~~~
sageikosa
Did some of that, had to throw in delay loops so the sprites wouldn't tear
when moving in response to the joystick.

------
nathanstitt
Oh that takes me back! I remember peeking & poking for hours to various memory
locations on my old 64 just to see what would happen.

Later I wrote a good bit of assembly for demo programs (which frankly sucked).
I particularly loved the SID chip
(<http://en.wikipedia.org/wiki/MOS_Technology_SID>).

Anybody remember Impossible Misson? I'm still fond of uttering "Destroy Him,
My Robots". I don't think anybody gets the reference anymore though.
<https://www.youtube.com/watch?v=ginShVeGpGY>

~~~
sageikosa
I remember peeking and poking a PET (or was it a CBM?) we had in the copier
room at school until it would make a horrible whining sound requiring turning
off the machine. Learned much later that some of the video registers could be
poked with values that might damage the hardware :-)

------
bbguitar
I'll second the childhood memories comment. I also remember pouring over Z80
machine code and does anyone remember typing in individual numbers on a 1K
ZX81 to run a blocky space invaders program (circa 1979)??

~~~
Erwin
I remember forking an open source game library around 1985. Well, typing the
source code in from the magazine so I could make my own game with sprites. I
don't think I made it because of those awful rubber keys and it was not my
computer anyway. The owner claimed he knew a guy who could replace the weird
rubber keys with some plastic Commodore keyboard (though that would make
typing BASIC code challenging -- the Spectrum keyboard had some strange mode
where you could type just a single key to insert DIM or LIST).

~~~
fallous
Worse, it required that mode. It was memory-saving by using single character
codes for the commands rather than 3 bytes for DIM or 4 bytes to store LIST as
ASCII.

------
lucbij
Back in the early 80's. I saw a commodore 64 ROM with a cool looking spaceship
on the packaging. It read: 'Make your games run faster'. I got my father to
buy it for me. It was a 6510 assembly language monitor. This is how I jumped
from Basic to assembly. It was a brutal learning curve. There was no Internet,
as far as I was concerned back then.

There was a magazine called 'The Transactor':

[http://www.scribd.com/collections/2988621/The-Transactor-
Com...](http://www.scribd.com/collections/2988621/The-Transactor-Commodore-
Computer-Magazine)

The experience, definitely gave me a leg up later on, as an EE student, where
I got to learn x86 ASM as well. The symbolic assemblers were much nicer. Most
people would start out with templates where all the various memory segments
were already setup. What was crazy was that after a awhile, you got to a point
where you could recognize the instructions from looking at the HEX.

~~~
voltagex_
The original source of those PDFs is
[http://archive.org/search.php?query=collection%3Atransactor-...](http://archive.org/search.php?query=collection%3Atransactor-
magazines&sort=-publicdate)

------
bch
Reading all the positive recollections of the 6502 (esp. from people who've
programmed other controllers) makes me feel nostalgic. It brings back happy
memories of programming (with a paper and pencil -- I had no concept of an
editor, or even assembly language) my C=64 -- I had a book of opcodes, and
would scan up and down the list to find what I thought I wanted, then write it
all out in a notebook. Then I would collect this code, and POKE it into place
in the C=64 memory, and voila! Magic! The C=64 was so malleable. I would "hack
the kernel"("OS Wedge" is what I knew it as) by resetting an interrupt vector
for some function (ie: keyboard interrupt) to the address of my new code, and
at the end of my code, call to the ROM for the original code. This way, I
could get the screen to change colours every time I pressed a key.

It was one of my first introductions to computing, and probably exactly what I
needed.

------
nathell
I actually find both 6502/6510 and x86 assembly languages fun.

------
arankine
I remember moving from 6502 to mips. Had to build a calculator for compsci. I
rewrote the multiply instruction, didnt even consider it would be there in
mips. 6502 was my first assembly, and i hold it dear to my heart :)

~~~
fekberg
Aw MIPS, the first ASM that I ever encountered at my technical institiute. A
trip down memory lane on a Thursday, well thank you very much! :)

------
phatbyte
I never coded in assembly apart from the basic hello worlds and such, but this
is awesome.

I actually wouldn't mind learning assembly as a pet language :D

~~~
falcolas
I recently stepped through "Programming from the Ground Up", and found it very
educational. It's aimed at the x86 processor on Linux, so it's still quite
relevant.

Worth going through, if you have the time.

<http://programminggroundup.blogspot.com/>

~~~
phatbyte
Nice link, thanks :)

------
Scramblejams
What was everyone's favorite 6502 book from back then? Please list yours. I
see Rodnay Zaks and Leventhal mentioned by other commenters.

What was yours?

~~~
kabdib
I uniformly found anything but the manufacturer's references to be verbose and
slow. I learned Z-80 assembly from Zilog's instruction set reference, and 6502
assembly from the Synertek reference. Ditto the 68000.

I never really learned x86 assembly because I started with some awful Scelbi
book.

BTW, I used assembly in a real-world project about two years ago, and one of
my cow-orkers was using it yesterday. It's anything but dead.

------
cpeterso
Is anyone still producing 6502 processors today? Is there any price advantage
to using such an venerable and well-known design today?

~~~
MagerValp
Yes, Western Design Center is selling the 65C02 in the classic 40-pin DIP
package for about $5 a pop.

The last time I checked, which admittedly was almost 10 years ago,
microcontrollers with embedded 6502 cores were quite popular with chinese toy
manufacturers.

~~~
cpeterso
You reminded me of the Playpower Foundation that is designing a $10 6502-based
"TV-computer" for distributing educational games to developing countries. This
is cool, but I can't help but think that Moore's Law will deliver a cheap
Android device.

Is there an Android device cheaper than the Raspberry Pi?

<http://playpower.org/>

------
charlieflowers
I used to have an "IDE" called "Develop 64" that had a 6502 assembler and
disassembler (6510 actually). Anybody else remember that? It was pretty good
for its time.

I have fond memories of capturing an interrupt and displaying the time in the
upper left corner of the screen without blocking the command line. Good times!

~~~
vidarh
There's no difference in the instruction set between 6502 and 6510 (at least
not in the documented opcodes) - the 6510 is a 6502 with up to 8 GPIO pins and
a tristate address bus. On the C64 the IO pins were used for bank switching
the ROM and underlying RAM, and for controlling the tape port.

(fun and useless trivia about the tape port: you could use your C64 as a very
primitive 1-bit sampler by recording the tape input, and play it back by
toggling the input to max and down again on every "1"; with some basic run-
length encoding you could get a reasonable length sample in memory and still
be able to record at a tolerable sample rate to get recognizable output)

------
beambot
OT: That's a beautiful github project page. I wasn't even aware that GitHub
Pages existed...

------
orangethirty
Well, there goes my weekend.

------
yati
The page looks very bad (read: is almost unreadable) on non Macs :(

~~~
ersii
I'm not sure I understand what looks poorly. It looks fine with Firefox on
Ubuntu. I like the way it looks.

