Program to Read DIP Switches


Program to read DIP switches and make decisions based on switch settings

; Program which makes decisions based on switch settings

PROG:       equ     $0800
STACK:      equ     $0A00

PORTB:      equ     $0001
DDRB:       equ     $0003


CODE:       section .text
            org     PROG

            lds     #STACK      ; initialize stack pointer
            clr     DDRB        ; PORTB input -- 0x00 -> DDRB

            ldaa    PORTB       ; Get switch state
            anda    #$03        ; Mask out unused switches 
                                ;   only using PB0 and PB1
            cmpa    #$00        ; Both switches closed?
            beq     pattern0    ; Yes, display Pattern 0
            cmpa    #$01        ; 
            beq     pattern1