Skip to content

Instantly share code, notes, and snippets.

@rbento
Last active March 25, 2025 08:56
Show Gist options
  • Select an option

  • Save rbento/e21dbdb75d695097f80720c1618f390a to your computer and use it in GitHub Desktop.

Select an option

Save rbento/e21dbdb75d695097f80720c1618f390a to your computer and use it in GitHub Desktop.
My Notes on Apple 2 Programming

Apple 2 Programing

Program

hello.s

        .segment "HEADER"
        .byte $01, $08, $01, $00, $00, $00, $00, $00  ; Apple DOS binary header

        .segment "CODE"
        .org $0800  ; Load address in memory

        LDX #$00
loop:   LDA message,X  ; Load character from message
        BEQ done       ; If null terminator, end program
        JSR $FDED      ; Call CHROUT to print character
        INX            ; Move to next character
        BNE loop       ; Loop until null terminator

done:   RTS

message:
        .asciiz "HELLO, APPLE II!"  ; Null-terminated string

        .segment "TRAILER"
        .byte $00, $00

Build

Using ca65 6502 compiler

Configure

apple2.cfg

MEMORY {
    HEADER: start = $0800, size = $0008, type = ro;
    RAM:    start = $0808, size = $F7F8, type = rw;
    TRAILER: start = $FFF8, size = $0008, type = ro;
}

SEGMENTS {
    HEADER:  load = HEADER, type = ro;
    CODE:    load = RAM, type = rw;
    TRAILER: load = TRAILER, type = ro;
}

Compile

ca65 hello.s -o hello.o

Link

ld65 -C apple2.cfg -o hello.bin hello.o

Create Image

Using Apple Commander

java -XstartOnFirstThread -jar AppleCommander.jar
Screenshot 2025-03-25 at 4 51 25 AM Screenshot 2025-03-25 at 4 51 37 AM Screenshot 2025-03-25 at 4 51 42 AM Screenshot 2025-03-25 at 4 51 54 AM Screenshot 2025-03-25 at 4 52 00 AM Screenshot 2025-03-25 at 4 52 06 AM Screenshot 2025-03-25 at 4 52 27 AM Screenshot 2025-03-25 at 4 52 35 AM

Emulate

With Virtual ][ Apple 2 emulator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment