;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Test VIA's PORTB using LEDs in Cylon pattern. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; processor 6502 ; Processor directive for Assembler. PORTB = $6000 ; Our data port (Port B). PORTA = $6001 ; Our control port (Port A). DDRB = $6002 ; Data Direction Register for Port B. 1: output, 0: input. DDRA = $6003 ; Data Direction Register for Port A. Reset = $8000 ; Reset vector address of $8000 (start of ROM). ;seg .U code org $8000 ; Define the code origin of $8000 (ROM) starting point. Start: lda #$FF ; A9 FF ; All pins will be outputs. sta $6002 ; 8D 02 60 ; DDRB: Data Direction Register port B. lda #$00 ; A9 00 ; Blank the LEDs. sta $6000 ; 8D 00 60 ; Write to port B (PORTB). lda #$01 ; A9 01 ; Light only the first LED, the low order bit 1. sta $6000 ; 8D 00 60 ; Write to data port B (PORTB). R2L: rol ; 2A ; Rotate bit one position to the left. sta $6000 ; 8D 00 60 ; Write to data port B (PORTB). cmp #$80 ; C9 80 beq L2Ra ; F0 03 ; Relative branch if equal to zero. jmp R2L ; 4C 0F 80 ; Repeat indefinitely by jumping back to $800F. L2Ra: sta $6000 ; 8D 00 60 L2Rb: lsr ; 4A ; Logical shift right sta $6000 ; 8D 00 60 ; Display the result. cmp #$00 ; C9 00 ; Is this the 0/1 BIT? beq R2L ; F0 EA ; Yes? Shift-right routine is finished. jmp L2Rb ; 4C 1D 80 ; No? Continue shifting bit to the right. org $FFFC word $8000 ; Reset vector is set to location $8000. word $0000 ; Fill 32K to end.