ca65 V2.15 - Git f7cdfbf
Main file   : firmware.s65
Current file: firmware.s65

000000r 1               					.setcpu "65C02"
000000r 1               
000000r 1               					ACIA_DATA = $8200
000000r 1               					ACIA_STATUS = $8201
000000r 1               					ACIA_COMMAND = $8202
000000r 1               					ACIA_CONTROL = $8203
000000r 1               
000000r 1               .segment "VECTORS"
000000r 1               
000000r 1  rr rr                  .word   nmi
000002r 1  rr rr                  .word   reset
000004r 1  rr rr                  .word   irq
000006r 1               
000006r 1                         .code
000000r 1               
000000r 1  4C rr rr     reset:				jmp main
000003r 1               
000003r 1  40           nmi:					rti
000004r 1               
000004r 1  40           irq:					rti
000005r 1               
000005r 1               main:
000005r 1  A9 0B        init_acia:			lda #%00001011				;No parity, no echo, no interrupt
000007r 1  8D 02 82     					sta ACIA_COMMAND
00000Ar 1  A9 1F        					lda #%00011111				;1 stop bit, 8 data bits, 19200 baud
00000Cr 1  8D 03 82     					sta ACIA_CONTROL
00000Fr 1               
00000Fr 1  A2 00        write:				ldx #0	;for x = 0 to length of message, send character to acia
000011r 1               next_char:
000011r 1  AD 01 82     wait_txd_empty:		lda ACIA_STATUS
000014r 1               					;and #$10
000014r 1               					;beq wait_txd_empty
000014r 1  BD rr rr     					lda text,x
000017r 1  F0 F6        					beq write
000019r 1  8D 00 82     					sta ACIA_DATA
00001Cr 1  E8           					inx
00001Dr 1  20 rr rr                                             jsr DELAY_6551
000020r 1  4C rr rr     					jmp next_char
000023r 1               
000023r 1               read:
000023r 1  AD 01 82     wait_rxd_full:		lda ACIA_STATUS
000026r 1  29 08        					and #$08
000028r 1  F0 F9        					beq wait_rxd_full
00002Ar 1  AD 00 82     					lda ACIA_DATA
00002Dr 1  4C rr rr     					jmp write
000030r 1               
000030r 1  48 65 6C 6C  text:				.byte "Hello World!", $0d, $0a, $00
000034r 1  6F 20 57 6F  
000038r 1  72 6C 64 21  
00003Fr 1               
00003Fr 1  5A           DELAY_6551:   PHY      ;Save Y Reg
000040r 1  DA                    PHX      ;Save X Reg
000041r 1  A0 01        DELAY_LOOP:   LDY   #1    ;Get delay value (clock rate in MHz 2 clock cycles)
000043r 1               ;
000043r 1  A2 68        MINIDLY:   LDX   #$68      ;Seed X reg
000045r 1  CA           DELAY_1:      DEX         ;Decrement low index
000046r 1  D0 FD                 BNE   DELAY_1   ;Loop back until done
000048r 1               ;
000048r 1  88                    DEY         ;Decrease by one
000049r 1  D0 F8                 BNE   MINIDLY   ;Loop until done
00004Br 1  FA                    PLX         ;Restore X Reg
00004Cr 1  7A                    PLY         ;Restore Y Reg
00004Dr 1  60           DELAY_DONE:   RTS
00004Dr 1               
