EASy68K  
It is currently Thu Apr 02, 2020 1:12 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Thu Jan 03, 2013 11:45 pm 
Offline

Joined: Thu Jan 03, 2013 11:36 pm
Posts: 2
Hi, I am doing a stopwatch timer.

I have managed to make it start counting from 0:0.0 (mm:ss.tenth) when s is pressed.

But I need to make it stop when s is pressed again, but the counting should not be stopped before s is pressed.

I have a feeling that Task 7 (TRAP #15) will be helpful, but I couldn't figure it out how to make use of it.

Could somebody please give me some advice or any clue?

Code:
   ORG   $1000
START:   LEA   MESSAGE,A1   ; load the message into A1
   MOVE.B   #14,D0
   TRAP   #15   ; display the message
   
   MOVE   #5,D0
   TRAP   #15   ; read a char from keyboard into D1.B
   
   SUB.B   #$73,D1
   BNE   end   ; if the char is not S, it ends the program.

   MOVE   #8,D0   ; get time (in hundredths of sec) in D1
   TRAP   #15
   MOVE.L   D1,D2   ; copy the time to D2, D2 then is the start time

repeat   MOVE   #8,D0   ; the start of the loop
   TRAP   #15   ; get the time again, now the difference between D1 and D2 is the time that has passed.

   SUB.L   D2,D1   ; substract the start time, get the time that has passed.
   
   DIVU   #100,D1   ; LH is the reminder, RH is sec.
   
   MOVE   D1,D7   ; D7 is used here as a transfer to separate reminder and sec.
   AND.L   #$0000FFFF,D7   ; set the LH to zeros, only sec is left
   
   MOVE.L   D7,D3   ; move sec to D3
   
   SWAP   D1
   AND.L   #$0000FFFF,D1   ; swap D1 and clean the LH, only reminder left
   MOVE.L   D1,D4   ; put the reminder to D4
   
   DIVU   #60,D3   ; divide sec by 60, get minutes
   
   MOVE.L   D3,D7   ; D7 is used again as a transfer to separate min and sec(the reminder in this case)
   AND.L   #$0000FFFF,D7   ; set LH to zeros, only min is left
   MOVE   D7,D5   ; move min to D5
   
   SWAP   D3   
   AND.L   #$0000FFFF,D3   ; swap D3, and set LH to zeros, only sec is left
   
   MOVE.L   D3,D6   ; move sec to D6
   
   DIVU   #10,D4   ; the reminder is divided by 10, get tenths
   AND.L   #$0000FFFF,D4   ; no need for the reminder in this case
   
* To sum up until this line, min is in D5, sec is in D6, tenth is in D4
* then start print

   MOVE.L   D5,D1   ; print min
   MOVE   #3,D0
   TRAP   #15
   
   MOVE.B   #$3A,D1   ; print colon
   MOVE   #6,D0
   TRAP   #15

   MOVE.L   D6,D1   ; print sec
   MOVE   #3,D0
   TRAP   #15
   
   MOVE.B   #$2E,D1   ; print full stop
   MOVE   #6,D0
   TRAP   #15

   MOVE.L   D4,D1   ; print tenths
   MOVE   #3,D0
   TRAP   #15
   
   MOVE.W   #$FF00,D1   ; clear screen
   MOVE   #11,D0
   TRAP   #15
   
   SUB.B   #$A,D5   
   BEQ   end   ; if the min, D5, is 10, then program ends
   

   BRA   repeat   ; go back to the loop
   

end   MOVE.B   #9,D0
   TRAP   #15      ; halt simulator

* Variables and Strings

CR   EQU   $0D
LF   EQU   $0A
MESSAGE   DC.B   'Press s to start the program',CR,LF,0


   END   START      ; last line of source


Top
 Profile  
 
PostPosted: Fri Jan 04, 2013 12:12 am 
Offline

Joined: Mon Dec 27, 2004 11:40 pm
Posts: 318
Quote:
I have a feeling that Task 7 (TRAP #15) will be helpful, but I couldn't figure it out how to make use of it.
Call the trap then test the state of the byte in d1. If it is not zero then a key has been pressed.

Lee.


Top
 Profile  
 
PostPosted: Fri Jan 04, 2013 12:27 am 
Offline

Joined: Thu Jan 03, 2013 11:36 pm
Posts: 2
lee wrote:
Quote:
I have a feeling that Task 7 (TRAP #15) will be helpful, but I couldn't figure it out how to make use of it.
Call the trap then test the state of the byte in d1. If it is not zero then a key has been pressed.

Lee.


thanks a lot.


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

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 4 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:  
cron
Powered by phpBB® Forum Software © phpBB Group