********** * Program NUM_ODD (6811) * * Searches memory locations $E000 - $E0FF and outputs the number * of bytes which have an odd value. * * Illustrates use of indexed addressing and use of CPX. * * P. H. Anderson, MSU, 20 Sept 90; 15 Jan 93 ********** PSCT EQU $C000 DSCT EQU $D000 IDSCT EQU $D300 REG_BASE EQU $1000 STACKTP EQU $0045 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 * * although switches not used in this program CLR NUM_ODD * initialize LDX #$E000 * index reg points to first location L1 LDAA 00,X * get the value LSRA * shift right, lsb in CY BCC AROUND * value is even INC NUM_ODD * otherwise it was odd AROUND INX * pointer incremented CPX #$E100 * gone to far? BNE L1 * if not continue LDAA NUM_ODD * if done, display number of odd STAA PORTB,Y SWI * return control to monitor ORG DSCT NUM_ODD RMB 1