C64 Assembly

August 26, 2009 · Print This Article

c64assembly 150x200 C64 Assembly

When I visited Germany this year I found that my mom had dug up a few of my really old computer books. The original Amiga manuals hold marginal interest to me now, but there was one book that stirs some seriously cool memories: “Commodore 64&128 – Maschinensprache für Einsteiger”. It’s a book about programming the C64 In 6502 assembly, and that’s how I spent most of 1988!

Even though I never turned into a professional programmer, my first real contact with the computer (other playing than games, of course) was programming the C64. My dad had bought the system under the usual pretense; we were going to use it for bookkeeping and other useful tasks, of course, and he even took a BASIC programming course. But in the end, it was I who got the most use out of the machine, and I used his coursework to program various simple games in BASIC myself. This all happened when I was only 9 or 10 years old, so the programs were simple. But the first ever English words that I ever learned were “if”, “then” and “print”.

A couple of years later I had met an older neighbor kid who had a few connections to the local cracker scene. That’s how I learned about this newly released book, “Maschinensprache für Einsteiger”, advertised as the ultimate way of learning to program the C64 at its core level, Assembly. My friend was all over it; so I saved my allowance, bought the book, and found myself programming C64 assembly when I was about 12 years old. The young age was very much reflected in the complexity of the programs I wrote – apart from pushing various register values around and creating loops, the most I ever got onto the screen where simple raster loops that created 16-color rainbows. And after a while, I moved on to different things… probably the Amiga.

Rereading this book after all these years has resulted in a weird twilight state. A lot of my fundamental computer understanding stems from this book (even though in 1988 I didn’t realize that I was learning basic concepts like hexadecimal numbers, CPU registers, bits and bytes). A lot of the ideas never fully registered back then, and I certainly didn’t gain a holistic understanding of the C64 system. I was just using assembly loops and instruction that made pretty lines appear on screen.

vice 544x289 C64 Assembly

Which is why revisiting C64 programming today is a bit of a revelation. Now that I can fully understand what the book is telling me, the C64 is almost delightfully simple to work with. 65384 bytes of RAM, unified memory – it doesn’t get much easier than that. Programming is procedural to a fault. Memory allocation isn’t even abstracted into variables. I can directly address the video memory of the C64. I can directly test the state of the keyboard and move around the register contents to create a simple text processor. What you see is what you get – and it’s as close to the hardware as possible (even though everything I’m doing now is actually emulated, of course). All of this is possible because the C64 is such a simple machine, at least compared to today’s consoles. And let’s be honest, hacking assembly code directly into the unit’s memory is quite a pain in the ass when using a monitor program.

But then again I don’t really have to program anything! I just get to test out a few of the concepts presented in the book, and reconnect with the old computer. Reading “Maschinensprache für Einsteiger” inspired me to download one of the popular C64 emulators and do just a bit of C64 assembly code again. My programs haven’t been much more complex than what I did back in 1988. But at age 33, it only took me a day to get to that point of knowledge, and I feel that if I kept going, I could create something that actually uses the C64′s capabilities. I won’t. It’s just cool to think about icon smile C64 Assembly

Comments

 (Subscribe)

4 Responses to “C64 Assembly”

  1. Virginia on August 27th, 2009 9:16 pm

    Oh god, let me tell you about simple programming for the Commodore 64. When I was a wee lass, my dad had like four of these babies (still does) because one was simply not enough. And even though I know know about all these fairly cool games that were developed for the C64, those were sooo not my experience.

    He would send away for these “Teach yourself to program!” kits, and sometimes we’d program crap together and sometimes he’d do it. I got exposed to this one game that I think was called “The Worst Text-Based Adventure Game In History: No, Really” in which no doors could ever become unlocked, but the worst was when he ordered a DIY game to program for me called “Count The Hearts”. GUESS WHAT THE OBJECTIVE WAS?

    We have come a long, long way. :)

  2. Warren on August 28th, 2009 5:26 am

    I do this every now and then. It’s fun to just fire up an emulator and go to town. I’ve made several attempts at writing C=64 compilers on my Mac as well. That’s a pretty fun challenge, actually.

    You’re so right about the machine itself. It’s so straightforward and procedural, it’s a pleasure to work with it.

    My issue these days is that I over complicate even the simplest tasks because my mind is all about objects and function calls and code re-use – all of which waste a lot of memory on the C=64. So by the time I have something appearing on the screen, I’ve eaten 50% of the available memory. :P

  3. Matthias on August 28th, 2009 8:29 am

    Let me guess, Virigina: you had to count the hearts? Just a wild guess…

    I love how the book brings so many things that I did back into perspective. We used to hack pages and pages of data listings into the computer, never understanding what we were actually doing. Finding out that each “data” was literally writing an 8bit hexadecimal number into memory, some of which were the assembly code for the instruction and some the parameters, is cool :) It’s so easy to forget that computers are still just a combination of “electricity flows/doesn’t flow”, but the C64 brings all that back into focus.

  4. Stefan on December 30th, 2011 2:33 pm

    I somewhat missed out on the C64 when I was younger. I had one, but I never managed to buy an assembler cartridge nor even a disk drive.

    I remember I did do a small amount of machine code programming, but it was all done by converting opcodes to decimal and entering them as data statements in a BASIC program.

    I still have the Vic-20 programmers manual where I found all the 6502 opcodes. I still see my pencilled-in decimal conversions written at the side of the opcode listing!

    By the time I managed to gain any sort of understanding, it was Christmas of 1989 and Santa brought me an Amiga 500. I still don’t know where my C64 is :-/

Got something to say?