assemblyc64commodore6510

Using xa65 assembler to create Commodore 64 .prg


I am trying to learn 6510 assembly and since I am running Debian xa65 is the assembler I want to use.

I have so far written a piece of code that looks like so:

*=$0801
.byte $0c, $08, $0a, $00, $9e, $20
.byte $34, $30, $39, $36, $00, $00
.byte $00

*=$1000
INC 53280
INC 53281
JMP $1000

Now, the first .byte section are suposed to "autostart" the program once loaded. This is something I found from a tutorial and as far as I can understand it will only run SYS 4096 making the CPU start executing the code at address $1000

The rest of the code should simply start flickering the outer and inner border of the C64 and repeat forever.

When assembling this I simply run the following:

xa test.s -o test.prg

and then I try to load test.prg into VICE to test it. with LOAD "TEST.PRG",8,1: and even if the file loads it does not autostart, nothing happens if i type RUN: and the same if I type LIST: - the only result is the famous READY. and the cursor flashing very happily like usual.

I tried to remove the autostart stuff and assembled only the code starting from *=$1000 but I got the same results. Trying to start with SYS 4096 also results in READY and nothing more.

I am sure I am not using the xa assembler right, but I can't figure out how I do create a proper PRG file for the C64 to use. What am I doing wrong?


Solution

  • I was trying to figure out how to make xa65 pad its output when I came across your question and have since learned how it works. Here's what I've found.

    As jester said, your code won't be at $1000 since setting the PC doesn't perform any padding. Padding is supported in xa65 using the .dsb directive, but a number of bytes must be specified for the directive rather than just an address like some assemblers' .org directive allows. Since the assembler allows for simple arithmetic, the number of bytes is given by <desired address> - PC.

    Adding the missing .prg address header and changing your second PC change to a padding directive results in output that behaves as expected. However, this still doesn't make it autostart. LOAD "TEST.PRG",8,1: and RUN does work, though.

    .byte $01, $08 ; Load this .prg into $0801
    
    *=$0801
    .byte $0c, $08, $0a, $00, $9e, $20
    .byte $34, $30, $39, $36, $00, $00
    .byte $00
    
    .dsb $1000 - * ; Pad with zeroes from PC to $1000
    
    INC 53280
    INC 53281
    JMP $1000
    

    FWIW, how to use the padding method wasn't immediately obvious in xa65's documentation (to me, at least).