A$$EMBLE IT!
 
INTRODUCTION / WHAT IS AN ASSEMBLER / COMMODORE 64 ASSEMBLERS / CROSS ASSEMBLY/ RECOMMENDED PC TOOLS
/ C64 Studio - And Setting Things Up

Chapter 1: INTRODUCTION, AND ABOUT ASSEMBLERS

Introduction

With the C64 coming back in different forms. For example The C64 Reloaded, theC64 Mini and the Ultimate 64 or maybe you own just just the Commodore 64 or C128 with a 1541Ultimate 2 or just want to code C64 programs for additional emulators. You have come to the right place. I have also decided to expand things a bit further in 2018, just for fun and hopefully it should be even more interesting.

The main purpose for this web site is to produce legal future reference for those of you who would like to be involved with the assembly programming side of the C64. There have been many books that details about subroutines, mathematics, etc. However I won't go through all of those as that would just take ages, and I don't have the time for that!. After all this tutorial is supposed to be fun, not boring. 

This web site differs through various assembly coding techniques, commands, etc. by reading through this documentation, you should soon end up creating cool, exciting and possibly crazy programs in no time. Later on in this documentation, you will learn how to create your own games, that involve moving sprites, animating background objects, playing SID music, adding scores, etc. Hopefully you should be able to make your first ever demo, intro or have a go at making a C64 game in no time. The assembler I will be using for each example will be ACME / C64STUDIO cross-platform assembler. 

BACK TO TOP

What is an Assembler?

An assembler is an application, or tool that allows you to program a computer by calling out several commands. We are programmed to do things by instructions/programming from our brains. You could always say that our own lives are controlled by a program through our brain. Computer programs work a similar kind of way, but are given different instructions by a programmer (yourself) to do amazing things. Assemblers are completely different compared to BASIC programs. The listings are completely LDA, STA and all that jazz. For example. In BASIC we could command a computer to type in commands such as print the message "I WOULD LIKE A PINT OF CARLING AND A PACKET OF CRISPS PLEASE!". That can simply be performed by using the command:

10 PRINT "I WOULD LIKE A PINT OF LAGER"
20 PRINT "AND A PACKET OF CRISPS PLEASE!"

In ACME/C64Studio cross assembly, the instructions are completely different, and a whole lot faster.

*=$0810
LDX #$00
PRINTMSG
LDA MESSAGE1,X
STA $0400,X
LDA MESSAGE2,X
STA $0400+40,x
INX
CPX #MSGEND-MSGSTART
BNE PRINTMSG
RTS

MSGSTART

!TEXT "I WOULD LIKE A PINT OF LAGER    "
!TEXT "AND A PACKET OF CRISPS PLEASE   "

MSGEND

What type of Assemblers are there?

Various C64/Cross assemblers may differ, as different commands are used, but they all do build up the same routines when assembled to your Commodore 64 or emulator. You write a program listing in an assembler, and then you need to assemble it before you create a runnable file and test your file. The most common native C64 assembler which was used was Omicron's Turbo Assembler. You can find this assembler quite easily on the Internet from the Turbo Assembler home page. However, the most practical way to code and debug your own program would be to use a cross-assembler and WinVice. This is due to the additional features, and user friendly options they take.

BACK TO TOP


Assemblers for the Commodore 64

BACK TO TOP
What is a Cross Assembler?

A cross assembler is a PC version of a normal 6502 assembler. It is a small executable compiler / application program, which will assemble and compile text files (which use the assembly instruction code) into a chosen assembled program. Basically a cross assembler can convert all text assembly commands to a 6502 program for any machine that supports this level of programming. Unlike normal Commodore 64 assemblers, a cross assembler has better limitations than a normal Commodore 64 assembler, like Turbo Assembler. Cross assemblers can also import source binary files, i.e. additional C64 graphics, music, data, etc. Usually by using a command like .INCBIN or .BINARY or !BIN. You can also link more than one source file to your assembled production. Every cross assembler normally comes with its own documentation on line. As mentioned before the all new ASSEMBLE IT is going to be using ACME/C64STUDIO for its tutorials. 

Cross assemblers/compilers for the PC to the Commodore 64 (Links to original sources)
BACK TO TOP
Some recommended PC-cross platform software to use for developing all kinds of things

This part gives you recommended cross platform software for use on your PC for developing all kinds of things, from graphics to music, and also for linking and compression, etc.

BACK TO TOP


C64 Studio and Setting Things Up

C64 Studio is probably the most common C64 IDE with built in toolkit, which is used today. I have chosen this particular assembler for the ASSEMBLE IT tutorials, due to the amount of ease it has on creating and developing software. It sort of uses the ACME cross assembler module (Which I originally used to create Woolly Jumper and Sheepoid DX). There may be some differences with some of the pseudo code, but it is pretty much straightforward if you are used to ACME :)

C64 Studio also has a few additional editors, which you can use to create and develop your own sprites and graphics. Although I tend prefer to use Charpad for designing background graphics, logos, etc. As it eases designing graphics slightly.

You can grab the editor from THE C64 STUDIO page.

To set up C64Studio, you'll want to choose a version of VICE which you find to be much useful. I find X64SC from WinVice V2.4 to be very handy. I own a C64C and would like to use that version of VICE for testing for raster dots. On an older C64 these tend to no be noticed, but on newer C64 hardware like the Commodore 64C back in the late 1980's it was different.

How is C64Studio set up to call VICE?

Easy:

Select from the drop down menu:

- FILE
- SETUP WIZARD
- then select the path where X64SC.EXE is placed

For assembling, simply click on the BUILD icon or press F5 to build your program. Should there be any errors in the code, the compiler results will show the errors and which lines these errors are located at.

Packing/Crunching

There is a trick known to reducing file sizes by packing/crunching files. After assembling your own programs you can choose whether or not you would like to pack/crunch your own productions. If you want to pack/crunch, the old slow C64 way, using one or two of a variety of packers/crunchers, etc. You can do exactly that. However, an alternative choice would be to use EXOMIZER.

IMPLEMENTING EXOMIZER INTO YOUR OWN SOURCE:

First of all, if you don't want to crunch your program with a standard C64 cruncher. You can easily enough use Exomizer. A fast-compression PC based tool with a variety of functions. You can disable or program your very own depack effects, to suit your needs. Although - playing with depack effects are least important, but may look cool or weird :)

First of all you will need to GET Exomizer from the EXOMIZER HOME PAGE

If say you were to write your own program in C64Studio and you wanted to compress your own program. You can call EXOMIZER to your source code to compress your assembled program. To implement EXOMIZER compression into your own programs:

- In the project explorer tab, select the source file to be assembled
- RIGHT CLICK on the source file and select PROPERTIES
- Click on the tab BUILD EVENTS
- Ensure build event is set up as POST BUILD
- Enter the correct path and command to where Exomizer is located ... for example

C:\Exomizer\Win32\Exomizer.exe sfx $(JUMP_ADDRESS) SOURCE.PRG -o SOURCE.PRG

then click on CLOSE.

Say for example:

You write a game called SpaceBlaster, the source code file is SpaceBlaster.asm and you use $4000 as the start address of your program (*=$4000). You can call Exomizer in post build to do exactly this command below:

C:\Exomizer\Win32\Exomizer.exe sfx $4000 SpaceBlaster.GRAB -o SpaceBlaster.prg

Basically That's it for this chapter :)

BACK TO TOP



NEXT PAGE/ Page of Contents