Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
blog:commodore_pet_compiler [2021/11/25 15:41] – created johnblog:commodore_pet_compiler [2021/11/29 15:20] (current) – [Commodore PET - Software Development] john
Line 14: Line 14:
    * Assemble your **.S** assembly listing using //ca65//, which will emit a **.o** binary object file    * Assemble your **.S** assembly listing using //ca65//, which will emit a **.o** binary object file
    * Link your **.o** object files using //ld65//, possibly including the cc65 standard library, which will emit a **.prg** executable    * Link your **.o** object files using //ld65//, possibly including the cc65 standard library, which will emit a **.prg** executable
 +
 +Here's a simple //makefile// to get started with development. It assumes you have a **./src** folder with your C source code and that you resulting binary will be placed in **./bin**. Alter the paths to the location of the cc65 installation as appropriate:
 +
 +<code>
 +# Names of the compiler and friends
 +CC = cc65
 +AS = ca65
 +LD = ld65
 +
 +# libraries and paths
 +INCLUDES = --include-dir /usr/share/cc65/include
 +LIBS = --lib /usr/share/cc65/lib/pet.lib
 +
 +# Compiler flags
 +ASM_FLAGS= --target pet
 +LDFLAGS = --target pet
 +CFLAGS = --target pet -O -Oi -Or -Os
 +
 +# What our application is named
 +TARGET = game.prg
 +
 +all: $(TARGET)
 +
 +# The main application
 +OBJFILES = src/test.o
 +
 +$(TARGET):  $(OBJFILES)
 + $(LD) $(LDFLAGS) --obj $(OBJFILES) $(LIBS) -o bin/$(TARGET)
 +
 +################################
 +# Main code
 +################################
 +src/test.s: src/test.c
 + $(CC) $(CFLAGS) $(INCLUDES) src/test.c
 +
 +src/test.o: src/test.s
 + $(AS) $(ASM_FLAGS) src/test.s
 +
 +###############################
 +#
 +# Clean up
 +#
 +###############################
 +clean:
 + rm -f src/*.o
 + rm -f bin/$(TARGET)
 +</code>
 +
 +==== Documentation & Library Reference ====
 +
 +   * Commodore PET specific functions (which are very few) are defined in **pet.h**, found in the //include// directory of the cc65 installation.
 +   * CC65 implementation guidance can be found [[https://cc65.github.io/doc/|here]].
 +   * The CC65 standard library can be found [[https://cc65.github.io/doc/funcref.html|here]].
  • blog/commodore_pet_compiler.1637854901.txt.gz
  • Last modified: 2021/11/25 15:41
  • by john