EASy68K  
It is currently Tue Dec 11, 2018 10:49 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: 7 segment counter
PostPosted: Mon Jul 18, 2011 2:43 pm 
Offline

Joined: Sun Jun 19, 2011 1:36 am
Posts: 7
Location: Midwest
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 19, 2011 2:37 am 
Offline

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
http://www.easy68k.com/EASy68Kforum/viewtopic.php?t=985

Doing 5 digits (0-65535) or 6 digits (0-655359) isn't too difficult using 16-bit divides intrinsic to the 68000.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group