Commander X16 Hello World in 65C02
By Edward Willis (http://encw.xyz and gopher://encw.xyz)
Published Dec/21/2023

So, I know I am not the only one interested in the Commander X16. I wager that
I'm not the only one programming 65C02 assembly language for the first time
either.

So, because I had to figure out myself how to get started, I've decided to post
my hello world to help other people get started.

hello.S:
---------------------------------------
.org $080D
.segment "STARTUP"
.segment "INIT"
.segment "ONCE"
.segment "CODE"

jmp start

msg: .byte "hello world", $0D, $00

CHROUT = $FFD2
UPPERC = $8E

start:
	lda #UPPERC
	jsr CHROUT
	ldx #0
cont:
	lda msg,x
	beq end
	jsr CHROUT
	inx
	jmp cont
end:
	rts
---------------------------------------

Written for the CC65 compiler. It was easy for me to get cc65 because it is in
both the Debian and Fedora repos.

Copy and compile with:
$ cl65 hello.S -t cx16 -o HELLO.PRG.

CX16 emulator is available here:
https://cx16forum.com/forum/viewforum.php?f=30&sid=6295e7544143d45e9829b68c6e34444b

Just copy the emulator files into a directory on your computer, put HELLO.PRG in
that same directory, launch the emulator by running x16emu,

Type:
LOAD "HELLO.PRG"
Don't worry about capslock it'll do that for you.
Then run with:
RUN

There are PDFs that come with the emulator that are chock full of in depth
information on programming for the CX16.

Here are some other resources that I have been using as well:
https://en.wikibooks.org/w/index.php?title=65c02_Assembly
http://6502.org/
http://www.6502.org/tutorials/6502opcodes.html
https://cc65.github.io/
https://github.com/mwiedmann/cx16CodingInC
https://cx16.dk/cx16-petscii/