1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-01 13:41:34 +00:00

helloworld-c64

This commit is contained in:
netpipe 2024-01-30 02:53:15 -07:00
parent 51b946bf25
commit 8899f35c79
3 changed files with 73 additions and 0 deletions

3
samples/c64/hello/build.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
ca65 --cpu 6502 hello.asm -o hello.obj -l hello.lst
cl65 -t c64 -C hello.cfg -u __EXEHDR__ -Ln hello.lbl hello.obj -o hello.prg

View File

@ -0,0 +1,45 @@
; Define macro setting up ca65 string literals for C64 screen codes (see https://www.lemon64.com/forum/viewtopic.php?t=72236)
.macro SCREENCODE
.repeat $20, i
.charmap $40 + i, $40 + i + $00
.endrepeat
.repeat $20, i
.charmap $60 + i, $60 + i - $60
.endrepeat
.repeat $20, i
.charmap $80 + i, $80 + i + $40
.endrepeat
.repeat $20, i
.charmap $A0 + i, $A0 + i - $40
.endrepeat
.repeat $3F, i
.charmap $C0 + i, $C0 + i - $80
.endrepeat
.charmap $FF, $5E
.endmacro
SCREENCODE ; Apply C64 screen code character translation
;--------------------------------------------------------------------------------------------------
jsr $e544
ldx #text_ - text
loop:
lda text-1, x
sta $0400-1, x
dex
bne loop
rts
;--------------------------------------------------------------------------------------------------
text:
.byte "hello world!1"
text_:

View File

@ -0,0 +1,25 @@
FEATURES {
STARTADDRESS: default = $0801;
}
SYMBOLS {
__LOADADDR__: type = import;
}
MEMORY {
ZP: file = "", start = $0002, size = $00FE, define = yes;
LOADADDR: file = %O, start = %S - 2, size = $0002;
MAIN: file = %O, start = %S, size = $D000 - %S;
VEC: start = $FFFA, size = $0006, fill = no, type = ro;
}
SEGMENTS {
ZEROPAGE: load = ZP, type = zp, optional = yes;
LOADADDR: load = LOADADDR, type = ro;
EXEHDR: load = MAIN, type = ro, optional = yes;
CODE: load = MAIN, type = rw;
RODATA: load = MAIN, type = ro, optional = yes;
DATA: load = MAIN, type = rw, optional = yes;
SPRITES: load = MAIN, type = rw, optional = yes, align = 64;
BSS: load = MAIN, type = bss, optional = yes, define = yes;
}