ADDR B1 B2 B3 B4 X:\public_html\EEL4746\programs\updown.asm PAGE 1
count EQU $1004 ; Put count in port B
dir EQU $1003 ; Put dir in port C
D000 4F start: CLRA ; Set the current state to S0.
D001 B7 10 04 output: STAA count ; Output current state # as count.
D004 BD D0 1B JSR delay ; Delay so we can see what's
. happening
D007 7D 10 03 loop: TST dir ; Test the "dir" input
D00A 27 07 BEQ down ; Go down if dir=0
D00C 81 05 up: CMPA #5 ; Already 5?
D00E 27 F7 BEQ loop ; If so, no change.
D010 4C INCA ; Increment state number.
D011 20 EE BRA output ; Update output and repeat.
D013 7D 10 04 down: TST count ; Check current count
D016 27 EF BEQ loop ; If count=0, keep it.
D018 4A DECA ; Decrement state number.
D019 20 E6 BRA output ; Update output and repeat.
D01B CE 03 E8 delay: LDX #1000
D01E 09 dloop: DEX
D01F 26 FD BNE dloop
D021 39 RTS
Symbol Table
UP D00C
DIR 1003
DELAY D01B
DLOOP D01E
COUNT 1004
START D000
DOWN D013
LOOP D007
OUTPUT D001