Understanding 6502 assembly on the Commodore 64 - (1) Intro

      With all computers,  there are only two catagories that a user falls into at any given time.  Writing software and using software.  Really, not much has changed with regard to that even today.

    Having only 4000+ transistors means programming the 6502 with regard to speed and available memory means Assembly is an obvious choice to develop software. The Commodore is a great computer to learn 6502 machine code.  Between all of my 6502 computers, my choice is the C64




You can't be serious, Jordan!!!!! What about your Apple II!!!!


First of all, I never got into any of these meaningless computer rivalries of the 80's.  I was fortunate to have several different computers back then, and while some were better than others i.e. Any computer vs. TRS80 in the graphics department.  My focus is about standardization.


Use an Apple II and then a Commodore 64, you'll see why the Apple II cost 3 times the price.


The Apple II, loaded with internal expansion, had both ROM and processor upgrades throughout the years.  Most know this as the ][e versus the //e.    Then theres the fact that there was more than 1 Apple II....... II, IIc, IIe, //e, IIgs.  All of which had interesting hardware quirks, possibly due to chip reduction that made graphics related work very interesting on the Apple II



The C64's greatest limitation was its biggest advantage


The C64 on the other hand remained pretty much the same throughout the entire run.  If you had an understanding of the C64's memory mapped hardware you could write assembly code for it.  You did not need to learn and write for multiple iterations of the same computer.  As a matter of fact, the only variation in the Commodore 64 PAL vs. NTSC continues to be an issue even to this day.


The C64's "OS" is both terrible and amazing at the same time 

Its easy to forget that when you turn on a C64, one second later its up and running.  With BASIC loaded  and ready to go.  You do not need to boot up with a DOS disk to get things going.  This operating system is just a BASIC interpreter with various BASIC commands to address I/O. Formatting a disk is really nothing more than a one line basic command.

Such that:

Formatting a disk
 OPEN 1,8,15,”N0:MYDISKNAME,01”:CLOSE 1

Could also be:
10 PRINT "SUPER DUPER FORMAT UTILITY" 
20 OPEN 1,8,15,”N0:MYDISKNAME,01”:CLOSE 1
30 PRINT "FORMAT DONE"
RUN 

Simple, obscure, but effective.


64K RAM SYSTEM 38911 BASIC BYTES FREE


The commodore basic and kernel goodness are all loaded when the computer is powered up.  If using basic is what you want, you have 38911 Bytes free to do so, but thats not what this is about.  There is more than just BASIC going on.  The BASIC interpreter is, in and of itself a machine language program running on the computer.  If we are not using basic, we can take advantage of the memory that it occupies, however, there are still memory areas for kernel functions, stack, etc.  That being said, getting rid of basic would leave you with more than enough space to work.  All things considered, the machine language program that is' BASIC has been wonderfully deployed.  We just want our own machine language program, not basic.



THE BOOKS 


  



If ever there was a book that explained all of this in a way mere mortals could understand, Jim Butterfield must have written it.  Ive had this book for many years, its out of print, but available as a PDF on Bombjack.

Today its become quite normal to write code on a modern computer, assemble it and then copy it to a C64 or execute it on an Emulator such as Vice.  None of which was an option at the time this book was written.  As I pick up this book time and again, and want to follow along, Im going to need some tools on the C64

THE PERIPHERAL

TFC3 (The Final Cartridge) These are available on Ebay. There are many reasons to get one.  First of all, the speed loader is FAST.  Not JiffyDOS fast, but at least 10 times faster I/O than the stock C64



If learning assembly is your goal, the suite provided in this cartridge will allow you to follow along in the book on an actual C64 using the included Monitor/Assembler/Disassembler.  I believe there is also a CRT file available to load into VICE to emulate it.

More information can be found here

If you can't get your hands on it there are a number of other monitors available for download,  mind you, they will need to use the same conventions as shown in the book.  The easiest way is to use TFC3 under vice

You can Download it here from Lemon64.   Actual link to the file is HERE



NEXT----->
Understanding 6502 assembly on the Commodore 64 - (2) Memory Mapped Hardware


Table of contents
  



       

1 comment:

  1. You definitively have your heart at the right place... Thanks so much for all your effort here Jordan!

    ReplyDelete