* * Lab2 * * Purpose: Turn the lights 1/4 second red, 1/4 second green, * 1/4 second off, and repeat * * Author: Heather D. Pfeiffer * * Setup some useful labels EEPROM equ $f800 RESET equ $fffe redlght equ $ff greenlght equ $f0 nolght equ 0 motors equ $1004 * Program code for playing with lights org EEPROM start * First turn on the red lights for 1/4 of a second ldx #49999 * initialize the countdown counter ldaa #redlght * load up red lights redlp staa motors * turn lights on dex bne redlp * 10 cycles in loop * 49999 = 499,990 cycles * 4 cycles from above loop should not count; first store, so 499,986 nop brn redlp * Second turn on the green lights for 1/4 of a second ldx #49999 * initialize the countdown counter ldaa #greenlght * load up green lights * 10 cycles from above padding + 4 next store instruction * gives 499,986 + 14 = 500,000 cycles for red lights grlp staa motors * turn lights on dex bne grlp * 10 cycles in loop * 49999 = 499,990 cycles * 4 cycles from above loop should not count; first store, so 499,986 nop brn grlp * Last turn on no lights for 1/4 of a second ldx #49999 * initialize the countdown counter ldaa #nolght * load up no lights * 10 cycles from above padding + 4 next store instruction * gives 499,986 + 14 = 500,000 cycles for green lights nolp staa motors * turn lights on dex bne nolp * 10 cycles in loop * 49999 = 499,990 cycles * 4 cycles from above loop should not count; first store, so 499,986 nop bra start * 5 cycles here + 5 cycles at start + 4 for store = 14 cycles * gives 499,986 + 14 = 500,000 cycles for no lights * Setup the RESET vector org RESET fdb start