Basic loader for Commodore 64 assembly programs

When you compile an assembly language program for the C64, to run it you need to type the SYS command followed by the starting location of your program in memory.

To make it easier for the user to run your program without having to know the starting memory location, you can add a small basic program to the start of your program, so all the user has to type is the RUN command.

The assembly source can contain a little extra code that encodes the following BASIC line.

10 SYS 4096


Each of the bytes in the loader program can be easily tailored to meet your requirements. So after inserting the disk which contains your program, the program can be loaded and run with the following commands:

LOAD “*”,8,1

The loader portion is just made up of a small number of bytes placed at the beginning of the assembly source code

.byte $0C,$08,$0A,$00,$9E,$20,$34,$30,$39,$36,$00,$00,$00

In the simple example the real assembly code begins at address $1000. The test program simply changes the screen border colour to show that is actually running.

Complile, assemble and then load the output PRG on to a disk. Then you just LOAD and RUN it.

; test program changes border colours when run

; LOAD “*”,8,1

; basic loader program
;10 SYS 4096; $0801 = 2049

; $0C $08 = $080C 2-byte pointer to the next line of BASIC code
; $0A = 10; 2-byte line number low byte ($000A = 10)
; $00 = 0 ; 2-byte line number high bye
; $9E = SYS BASIC token
; $20 = [space]
; $34 = “4” , $30 = “0”, $39 = “9”, $36 = “6” (ASCII encoded numbers for decimal starting address)
; $0 = end of line
; $00 $00 = 2-byte pointer to the next line of BASIC code ($0000 = end of program)

.byte $0C,$08,$0A,$00,$9E,$20,$34,$30,$39,$36,$00,$00,$00

; real start of program $1000 = 4096
*=$1000; change border colour
loop inc $d020
jmp loop



  1. Thanks for explaining in detail what all the !byte lines mean. Other sources skip this part. It helped me forward.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s