******** * Program BOUND_1 * * Scans switches * * if in range 00-3F then 01 displayed on discrete LEDs * 40-7F 02 * 80-BF 04 * C0-FF 08 * * Illustrates use of the compare instruction. * * P. H. Anderson, MSU, 26 Sept 91; 15 Jan, '93 ********* PSCT EQU $C000 DSCT EQU $D000 IDSCT EQU $D300 STACKTP EQU $0045 REG_BASE EQU $1000 PORTB EQU $04 PORTC EQU $03 DDRC EQU $07 ORG PSCT * note that BCS and BLO are the same commands LDS #STACKTP * set stack pointer LDY #REG_BASE CLR DDRC,Y * port c configured as 8-bit input SCAN LDAA PORTC,Y * read switches CMPA #$40 BCS OUT_1 * if less than $40 CMPA #$80 BCS OUT_2 * if less than $80 CMPA #$C0 BCS OUT_4 * if less than $C0 BRA OUT_8 * otherwise OUT_1 LDAA #$01 STAA PORTB,Y BRA SCAN OUT_2 LDAA #$02 STAA PORTB,Y BRA SCAN OUT_4 LDAA #$04 STAA PORTB,Y BRA SCAN OUT_8 LDAA #$08 STAA PORTB,Y BRA SCAN * The following routine does the same thing ORG PSCT+$50 * note that BLS is the same as the combination of BCS and BEQ LDS #STACKTP * set stack pointer LDY #REG_BASE CLR DDRC,Y * port c configured as 8-bit input _SCAN LDAA PORTC,Y * read switches CMPA #$3F BCS _OUT_1 * if less than or equal to $3F BEQ _OUT_1 CMPA #$7F BCS _OUT_2 * if less than than or equal to $7F BEQ _OUT_2 CMPA #$BF BCS _OUT_4 * if less than or equal to $BF BEQ _OUT_4 BRA _OUT_8 * otherwise _OUT_1 LDAA #$01 STAA PORTB,Y BRA _SCAN _OUT_2 LDAA #$02 STAA PORTB,Y BRA _SCAN _OUT_4 LDAA #$04 STAA PORTB,Y BRA _SCAN _OUT_8 LDAA #$08 STAA PORTB,Y BRA _SCAN