Commodore 64 Assembly Workshop

A series of workshops were held in LAG to practice assembly programming on the good old Commodore 64. Below you find brief instructions for installing an emulator and crossdevelopment environment, as well as some reference material.

Preparation

Setting up the tools you need, assuming debian.

Vice

Emulator

ACME

Assembler

Basic program

https://groente.puscii.nl/begin.asm

!to "begin.prg", cbm ; #name of output, type of assembly
!cpu 6510 ; type of cpu
* = $0326 ; set assembler context, where to operate.
!word   codeStartAddress
!word   $f6ed


; prepare magic.
    jmp $800

* = $800
codeStartAddress

    sei

    lda #$1b
    ldx #$09
    sta $d011   ; clear the high bit of $d012 and set text mode
    stx $d016   ; single color

    lda #$7f
    ldx #$01
    sta $dc0d   ; turn off cia 1 interrupts
    sta $dd0d   ; turn off cia 2 interrupts
    stx $d01a   ; turn on raster interrupts

    lda #<int
    ldx #>int
    ldy #$c0
    sta $fffe ; set our interrupt handler to int
    stx $ffff
    sty $d012   ; and the rasterline to #240

    lda #$35
    sta $01

    lda $dc0d   ; acknowledge cia 1 interrupts
    lda $dd0d   ; acknowledge cia 2 interrupts
    asl $d019   ; enable interrupts
    cli

; actual code block.
begin ; label
    inc $400 ; increment whatever is at address 400 (hexadecimal) (first character on screen)
    inc $401 ; same for the second character on the screen.
    jmp begin ; jump to begin.

; more magic.
int
    pha
    txa
    pha
    tya
    pha

    asl $d019

    pla
    tay
    pla
    tax
    pla
    rti

Links

Tutorials

Examples

Books