I am trying to write code for a counter using the LED. I was able to get it to work for two digits. I am now just having problems expanding it to more digits. I would like to do 5 digits. Any pointers? Here is my code for two digits. At the bottom I started to try and add more stuff:
Code:
ORG $1000
START CLR.B $E00000 ;TURN UNUSED DIGIT OFF
CLR.B $E00002 ;TURN UNUSED DIGIT OFF
CLR.B $E00004 ;TURN UNUSED DIGIT OFF
CLR.B $E00006 ;TURN UNUSED DIGIT OFF
CLR.B D0 ;INITIALIZE D0
LP4 MOVE.L D0,D5 ;DEPOSITE A COPY OF THE NUMBER TP BE DISPLAYED IN D5
MOVE.L D0,D7 ;DEPOSITE A SECOND COPY OF THE NUMBER TP BE DISPLAYED IN D7
MOVE.L D0,D4
MOVE.L D0,D3
DIVS #10,D0 ;RECONSTRUCT TENS DIGIT
BSR OPTENS ;DISPLAY TENS DIGIT
MULS #10,D0 ;DROP THE ONES DIGIT FORM THE ORIGIANL NUMBER
SUB.W D0,D5 ;GET THE ONES DIGIT INTO D5
MOVE.W D5,D0
BSR OPONES ;DISPLAY THE ONES DIGIT
BSR DELAY
ADD.W #1,D7
MOVE.W D7,D0
BRA LP4
MOVE.B #9,D0
TRAP #15 ; halt simulator
ORG $7000
DIGIT DC.B $3F,$06,$5B,$4F,$66,$6D,$7D,$07,$7F,$6F
DELAY MOVE.L #$14,D2
LP MOVE.L #$7FFFFFFF,D1
LP2 DBRA D1,LP2
DBRA D2,LP
; BSR DELAY
LP3 RTS
OPTHOUS LEA DIGIT,A1
MOVE.B (A1,D0.W),$E00008
RTS
OPHUND LEA DIGIT,A1
MOVE.B (A1,D0.W),$E0000A
RTS
OPTENS LEA DIGIT,A1
MOVE.B (A1,D0.W),$E0000C
RTS
OPONES LEA DIGIT,A1
MOVE.B (A1,D0.W),$E0000E
; BSR DELAY
RTS
END START ; last line of source