6502 Machine Language for Beginners
savetz writes "If you've always wanted to learn 6502 assembly language, now's your chance. The full text of the classic, best-selling 1983 book Machine Language for Beginners is now on the Web. It includes examples and program code for Atari 8-bit, Apple ][, PET/CBM, VIC-20, and Commodore 64 computers."
I have the copy of this that I bought back when it came out. Or, rather, my dad bought it for me. I remember showing it to him and having him ask "What? Are you going to start talking to the refrigerator with this?"
Good old dad. Never has understood what "machine language" really means, and still doesn't care.
It's a good book, if you want ot know 6502. Give it a try and then start coding for the Atari 2600 or Commodore 64.
Curmudgeon Gamer: Not happy
But wouldnt that be add with carry, and not a straight add? Just being pedantic here mind you, because you do get the carry pretty much for free when making an alu, and stick a multiplexor on the carry line and you have the add instruction almost for free as well.
Come to think of it, is there any advantage to having a straight add instruction over an add with carry? (Aside from preserving the carry bit for the next instruction, but that would be some weird programming)
Yeah, but you have to clear the carry (CLC), *then* Add with Carry (ADC) to perform what a normal ADD would have done on other processors. Struck me as funny when I first learned 6502.
Now, the IBM 1620 didn't have hardware addition. You had to load in a lookup table that contained the answers to "2+2", "2+3", etc...
I must be a weirdo, cos I actually find it interesting and quite amusing. I spent my entire childhood on a PC (my dad brought one home in 1983), all my friends back then had Vic-20's, C-64's or Spectrums.
I find it particularly amazing to see how much instructions sets have progressed. I really do like the ARM instruction set (but how will they make a superscalar ARM CPU with conditional instructions?), the PowerPC is pretty damn good too. MIPS is bearable, but the x86 set with it's ridiculous 8 registers is a horrible patched-then-repatched abortion that should be put to sleep asap!
Then again, 8 registers is bliss in comparison to the 3 I just found out the 6502 has!
On the other hand, it's hardly a good tool for learning how to design computers that work today. While you can draw a number of parallels between an 8-bit microprocessor and a 64-bit microprocessor, the design challenge of a 64-bit microprocessor is so much greater than the 8-bit, you absolutely must use higher level design techniques, while you could conceivably get away with hand designing an entire 8-bit processor (as was, in fact, done).
:)
Incidentally, if you want a real learning experience, why not a 4-bit processor?
When I saw this, my first thought was of the scene in ST:TNG with Scotty and Picard on the hologram bridge of Kirk's Enterprise. Scotty liked the first Enterprise because he could tell the speed by the feel of the deck plates and Picrad said the Enterprise was superior than the Stargazer in terms of numbers, but he still often wished he was on the Stargazer.
//e. I knew the monitor ROM backwards and forwards. I used an amazingly powerful assembler called ORCA/M (known for it's macros and libraries), and learned hardware from books about the Apple //e. It was a wonderful world to learn and play in. I sold my //e to buy an Amiga. I still have the Amiga, but I wish I still had that //e -- it had a FULLY SOCKED motherboard, with a modified ROM that gave me extra features (I did the ROM mods myself), and a few nice accessories -- like a hard drive with a whopping 5 Meg of storage and a memory card that gave me over a megabyte of online memory -- which I used as a ramdrive.
//e (I had even figured out how I could make it multi-task w/ a clock card -- but never got around to programming it) instead of worrying about networking and web pages and relational databases.
I learned almost everything I know about computers from my Apple
Just like Picard and the Stargazer, I often wish I were programming on my old
I agree that simpler is better, when learning/teaching core computer architecture concepts. However, rather than using old computer simulators, I personally prefer Atmel AVR microcontrollers. With a bare minimum of hardware, you can build a miniature computer from scratch and control every bit of the software that goes into it. It's just a good feeling to know that you aren't relying on anyone else's ROM code to do the dirty work. Plus it's an 8-bit RISC processor with 32 general-purpose registers, which is quite nice when you get too lazy for assembly and break out the gcc cross-compiler. =)
Paranoid
Bwaahahahahaa.
Well, my experience up to the 6502 was with processors that had a lot more opcodes in their instruction set. The 68000, z80/8080, 6809 all had separate ADD and ADC-type instructions. (I won't even touch on 370 BAL, which had one-to-one constructs with fortran code)
;)
But the 6502 was SO minimal. They didn't bother with *any* fluff that could be cut out.
So I found it amusing.
The real instructions only used up about a third or so of the available opcodes, and while most of the rest simply froze the processor, there were others that had interesting and predictable effects, and were in fact used by some of the C64 games. See this for the exciting low down.
....
So, I've been writing a 6502 Ada compiler just for the heck of it, and it's much more fun than targeting these new-fangled, regular instruction sets. Clearing space on the stack is great. The fastest way to do it depends on how much space you need; with one or two bytes, a couple of PHPs, three to six or so and you transfer SP to X, decrement the appropriate number of times, then send X back to SP. More than sixish, and you should TSX, TXA, SBC, TAX, TSX.
You'd be astounded at the machinations required for addressing variables on the stack, and mortified at the way a simple CMP instruction has the arrogance to affect the overflow bit. Unfortunately, this comment is to small to go into it.
Meeeeeemmmoooorrrrriiiiieeeeeeeeeees