Skip to content

Instantly share code, notes, and snippets.

@LightningStalker
Last active February 23, 2026 17:59
Show Gist options
  • Select an option

  • Save LightningStalker/19ed5a3b7462695bbd7a8b9789424a3a to your computer and use it in GitHub Desktop.

Select an option

Save LightningStalker/19ed5a3b7462695bbd7a8b9789424a3a to your computer and use it in GitHub Desktop.
vasm hello world for Apple 2
; vasm hello world for Apple ][
; address for call of the ROM BIOS function routines
COUT equ $fded ; character output
CROUT equ $fd8e ; start new line
WRST equ $3d0 ; warm reset, return to system
; symbols to get rid of the "magic numbers"
ABM equ $80 ; abyte modifier (chars + $80)
CR equ 13 ; carriage return char
ZT equ -$80 ; zero terminator $80 + -$80 = 0
org $800
start:
cld ; binary math
ldx #0 ; zero index reg
jsr CROUT ; sys doesn't give us a new line
lda msg, x ; A = first byte of msg
loop: ; (Absolute X Addressing Mode)
jsr COUT ; put it the screen
inx ; X++
lda msg, x ; A = the next
bne loop ; loop unless we found the 0
jmp WRST ; quit back to the OS
; abyte directive can convert to Apple ][ screen character set by + 0x80
; modifier.
msg abyte ABM, "hello, world", CR, ZT
#/bin/bash
# assemble, image, emulate
ASMFILE=helloa2.s
LISTING=list
BINFILE=hellov#060800
DSKIMG="d.dsk"
EMUSTATE=$(realpath SaveState.aws.yaml)
ASM=vasm6502_oldstyle
DSKIMGPROG=cp2
EMU=sa2
ECHO="echo -e"
READ=read
ASMOPTS="-Fbin -L ${LISTING} -o"
DSKIMGOPTS="a --overwrite"
EMUOPTS="-s"
READOPTS="-n 1 -s -t 5 -p"
PROMPT="Emulate? enter = no, other = yes: "
#ANSI color
ABRED="\\e[1;38;5;9m" # bold bright red
AVIO="\\e[1;38;5;207m" # bold violet
ACLR="\\e[0m" # reset all attributes
${ECHO} "${ABRED}Assemble...${ACLR}"
${ASM} ${ASMOPTS} "${BINFILE}" "${ASMFILE}" &&
${ECHO} "listing saved to: '${LISTING}'\n"
${ECHO} "${ABRED}Copy binary to disk image...${ACLR}"
${DSKIMGPROG} ${DSKIMGOPTS} "${DSKIMG}" "${BINFILE}"
${ECHO} ${AVIO}
${READ} ${READOPTS} "${PROMPT}" KEY
${ECHO} ${ACLR}
if test -n "${KEY}"
then
${EMU} ${EMUOPTS} "${EMUSTATE}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment