All pastes #832547 Raw Edit

Miscellany

public text v1 · immutable
#832547 ·published 2007-12-26 09:10 UTC
rendered paste body


; sample assembly routine in 6502 assembly (works on VIC-20, Commodore 64, Commodore 128, probably most PETS)

MESSAGE		.asc "Hello, world!": .byte 0	                        ; message to print
BSOUT		= $ffd2							; Commodore 8-bit kernal: output character to stdout
VECTOR		= $fb

			lda <MESSAGE					; initialise pointer to VECTOR in free zero page RAM
			sta VECTOR
			lda >MESSAGE
			sta VECTOR+1

			ldy #0						; initialise loop registers
			tya

-			lda (VECTOR),y					; load a character from MESSAGE into accumulator
			beq +						; if zero, message is done
			clc						; clear carry (used as error flag)
			jsr BSOUT					; perform the output
			bcs +						; abort if error
			iny						; increment character count
			bne -						; loop back unless rolled over

+			rts						; return to caller