****** * Program BOUND_2 * * Displays distance between first two occurances of * data pattern specified using toggle switches. * * Scans mem range F000 - F0FF * * If no match found outputs 00 * if no second match outputs FF * * Illustrates use of cmp op to test equality. * * Peter Anderson, 1 Oct 91; 15 Jan, '93 ****** PSCT EQU $C000 IDSCT EQU $D000 DSCT EQU $D300 STACKTP EQU $0045 REG_BASE EQU $1000 PORTB EQU $04 PORTC EQU $03 DDRC EQU $07 ORG PSCT LDS #STACKTP LDY #REG_BASE CLR DDRC,Y * port c configured as 8-bit input LDX FIRST_LOC * set to first location LDAA PORTC,Y * get switches STAA PATT * and save in patt CLR DISTANCE * zero the distance CLR PORTB,Y * zero the LEDs TEST_EQ LDAA 00,X * get mem data CMPA PATT BEQ FIRST_M * if match INX * next mem location CPX LAST_LOC * done? BCS TEST_EQ BEQ TEST_EQ * else there was no match NO_MATCH CLR PORTB,Y * output 00, no match found SWI * halt FIRST_M * * first match INC DISTANCE * distance INX * next mem loc CPX LAST_LOC * done? BEQ L1 BCC NO_2_MATCH L1 LDAA 00,X * get data CMPA PATT * same as pattern BNE FIRST_M SECOND_M LDAA DISTANCE * if second match STAA PORTB,Y * output distance SWI NO_2_MATCH LDAA #$FF * output FF STAA PORTB,Y SWI ORG IDSCT FIRST_LOC EQU $F000 LAST_LOC EQU $F0FF ORG DSCT PATT RMB 1 DISTANCE RMB 1