Evern wanted to write your own Atari 2600 games? This won’t get you quite that far, but it will teach you the very basics. It’s an assembly tutorial for the 6502 processor. The nice thing is that you need nothing more than your browser to participate thanks to the embedded JavaScript emulator which acts as assembler, machine, and debugger in one.
The 6502 was in a lot of early equipment. In addition to the previously mentioned Atari they can be found in the Commodore 64, Apple II, and the original NES. You can even find folks building their own computers around the chip these days (most notable to us is the Veronica project). The guide starts off slowly, providing a working program and challenging the reader to play with to code in order to alter the outcomes. It moves on to an overview of registers and instructions, operators and branching, and culminates in the creation of a simple game.
[Thanks Mathilda]
I remember learning ASM for 65816 (which was a 16-bit derivative of the 6502) for SNES development (the 65816 was also used for the Apple IIGS)
Not to forget expansion cards for the C64 featuring a 65816 running at 4 times the clock rate. I actually owned a Rossmöller “Turbo Process” card and I remember owning a book about 65816 assembly language.
I’m happy to see this site on hackaday. It’s technically impressive (a 6502 emulator in javascript, neat!) and it’s an awesome way to learn.
FYI, the Commodore 64 used a 6510 rather than a 6502.
Yeah, ive pointed that out several times before, but these guys don’t read the comments and seem to have no interest in publishing accurate information. This is the 3rd time in a month that they’ve claimed that the c64 had a 6502 while it really had a 6510. Not to mention the atari 2600 used a 6507 and the nes used a 2a03. Whilst all are similar or even derived from the 6502 they aren’t the same and they aren’t code or hardware compatible either. I guess the hackaday writers believe everything they read on hackaday.
The 6510 is code compatible with the 6502 even down to the undocumented opcodes. The 6510 is just a 6502 with an io port that was used to control the memory map on the C64. Yes I had one when they where new. The 2A03 from the NES also used a 6502 core but lacked the BCD mode “No big deal because it was almost never used”. As to support for undocumented op codes I have no idea. The 6507 was a 6502 with fewer IO lines. The actual core is identical. So….
6510 and 6507 are minor variants on the 6502 that are op code compatible. They are more opcode compatible than the 65c02.
The 2A03 is opcode compatible with the 6502 except for BCD.
You are more or less correct about them not being pin compatible but that doesn’t matter in the case of learning asembly language.
So you are being pedantic and annoying as well as most incorrectly as far as your objections in this use case. You have won you have failed to win your anoying geek badge because you filed to be 100% while complaining about a usful simplification in an artical. You may now leave and hang your head in shame.
Uh, incorrect sir. The 6510 had the extra io and also a tristate address bus, the 2a03 had an additional 22 registers to control the built in sound hardware and poll the controllers, the 6507 lacked access to interupts that were available on the 6502. So, what you are saying is basically like saying that all x86 type chips are really just 386s. While they may be opcode compatible and you can even run basic 6502 code on all 3; anything requiring the interupts or addressing more then 8k won’t run on a 6507, and any code using the extended features from the 6510 or the 2a03 isn’t backward compatible with the 6502. Not to mention that all these chips and their variations run at different clock speeds which if you had done much asm programming on chips of the erra you would realize is a big deal because it was common practice to use cycles to set up delays and other timing critical routines.
The extra IO and buss on the 6510 do not effect the opcodes in anyway. The use case here is to learn assembly language not to learn how to write for a specific system. At the Op code level these CPUs are identical and in this use case they are identical.And you are still being anoying over picky and your original post was incorrect when you said that they the instruction sets where different.
BTW clock speed is not even variant specific. Not all 6502s run at 1Mhz so difference in clock speed is a given to anyone that has ever had to count cycles.
I wouldn’t argue with COMPUTE! magazine. They considered all these 8-bit derivatives similar enough. http://www.atariarchives.org/mlb/cover.php
@ 1watcdr: i didn’t say they had different instruction sets i said they weren’t code compatible which they aren’t. Have you ever even done any asm coding? It’s extremely hardware specific; what good is it having the same opcodes when in order to do anything outside of basic bit manipulation you have to communicate with the rest of the system which will be totally different from system to system. You are the one being annoying and pedantic and also misleading just because the opcodes are similar doesn’t mean any code written for one system will run on another; i grew up writing asm code for the c64 and apple 2 and they’re quite different. If things were as simple as you imply how come you couldn’t run apple 2 programs on a c64? Or why did no one ever market an adapter to play nes games on another system? Not only does the original description imply that you could learn on this 6502 emulator how to program a 2600 it flat out says that the nes and 64 use the same chip as the apple. Your comment about the 6502 running at different speeds is also misleading as those other chips would’ve had different part numbers and wouldn’t have been interchanged at all. Having done quiet a bit of asm coding on quite a few arch’s i would argue that the opcodes are the least important part as all cpu’s would have functionally simmilar opcodes that will do pretty much the same things. While in order to do anything useful like use the keyboard or joystick or monitor or diskdrive required an intimate knowledge of the entire system and is totally different from system to system.
steveg, you’re comparing I/O and I/O compatibility, not the processor itself. It is entirely normal for two computers having 6502’s in them to have different I/O, with different I/O registers, different clock speeds, and different memory maps, whether the memory and I/O are on-chip, on-board, or on a separate plug-in board of the computer. These things will keep them from being compatible even if they have the same processor, just as two Apple II’s may be unable to use each other’s code if they have different sets of plug-in boards installed. The 6510 does has a 6502 in it.
On a different point, modern 6502’s have come a long way, although not as far as the x86 family has come. They are selling in huge volumes (hundreds of millions of units per year) but are rather invisible, being at the heart of custom ICs in things like engine controllers under your hood. The fastest ones are running over 200MHz. It’s the only processor approved for human-body-implantable life-support electronics.
It was the Commodore VIC-20 that used the 6502. What a beautiful little machine.
The VIC-20 was like a chubby girlfriend. You knew there were nicer and more exciting models out there, but that didn’t stop you loving what you had!
(Yes, I know this sounds bad, but it is the truth!)
Didn’t the VIC-20 and the C-64 the same from the outside? I remember we had a great time.
Don’t we need a virtual KIM-1, for the complete retro experience?
Combine that emulator with a pixel-art representation of the KIM-1… It would be retro-tastic!
Some Googling provides this:
http://www.mess.org/
and this:
http://www.progettoemma.net/mess/system.php?machine=kim1
…but that’s as far as I’m going down *that* rat hole :-)
CSB: my wife took a KIM-1 programming course in college. I figured out how to run a cross-assembler on the CDC timesharing machine, but she was having none of it — and continued to hand-assemble her code!
Ask and ye shall receive. The soft65 emulator is pretty close to being a Kim-1 emulator. It will even play my 1K Microchess game written for the Kim-1.
I am pretty sure I have seen another one that even looks like the Kim-1, but I couldn’t lay my hands on it right now. Maybe someone else can find the link, if it still exists.
Writing Atari 2600 games is great fun; here’s one I did a few years back:
http://www.atariage.com/forums/topic/161285-bat-passer-a-2600-homebrew/
If you want to do some hardcore coding, check out Wudsn: a plugin for Eclipse that ties together any assembler you want to various emulators for different 6502 platforms. Some supported ones include: Atari, NES, C64, Apple. It is pretty much as awesome as cross-development gets for retro code:
http://www.wudsn.com/
I taught it to myself by writing an assembler for it, I needed to remember the opcodes for use in the apple (iic) monitor and it helped a lot
Look up a UK101. That used a 6502 but was a complete kit of parts. Every single capacitor, chip, transistor, resistor, coil etc had to be soldered to the board. I nearly wore out a 1mm iron bit doing so! Coding was then all assembly language but boy did you learn! Sigh….
Why code an Atari 2600 game when you can code a bending robot?
http://m.spectrum.ieee.org/semiconductors/processors/the-truth-about-benders-brain
I did quite a bit of assembler for the BBC Micro……..a brilliant way to learn.
There is still support for the 6502 at 6502.org and they have forums, articles, posts and technical help to support you.
Thanks for this! There aren’t nearly as many resources for learning assembly as there are for HLLs. It’s great to see something like this on HaD!
I find I agree with steveg here. The first thing I thought reading the article was the C64 didn’t have a 6502 (although the 1541 disk drive did). I think HAD could at least say 6502 “based” processors or something similar. All these things might use the same core but the actual part is different and it shouldn’t be that hard to specify them correctly. If someone has a C64 with a duff processor and you give them a 6502 to replace it with that isn’t going to fix their problem.
And I did code a bending robot (beer brewing Bender) with a 6502 once, taken from a 1541 drive! I built my own computer around one to be his brain and to play his voice. I could have built it using the 6510 I guess, it would have worked the same, but then people would have complained that’s not the right chip!
Specifying the correct part is important.
Simon
Simon, it also won’t fix their problem if you give them a PLCC or a PQFP instead of a 40-pin DIP. “6502” specifies the processor, not the package, operating voltage (new ones are spec’ed down to 1.2V), temperature range, or whether there’s also other circuitry in the package.
Yes, very true.