EASy68K  
It is currently Tue May 26, 2020 12:27 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Stopwatch timer
PostPosted: Sun Jan 05, 2014 7:58 pm 
Offline

Joined: Sun Jan 05, 2014 7:48 pm
Posts: 1
Hello i am trying to program in assembly language a stopwatch timer that displays mm:ss:s on sim68k and is initialised to zero, and then when key is pressed stopwatch begins. Also the timer should measure any interval up to 10 mins.

Any help with code, below is what i have so far. Any help would be much appreciated thank you :)

ORG $1000
START: ; first instruction of program
MOVE #8,D0 ; get time in hundredths of sec in D1
TRAP #15

DIVU #100,D1 ; time in seconds in D1 (RH)
; remaining hundredths in D1 (LH)
; NB this will not work after about
; 6 PM, at which time the number of
;seconds exceeds what can be held in
;16 bits

DIVU #60,D1



AND.L #$0000FFFF,D1 ; set left hand half of D1 to zero



MOVE #3,D0 ; print time in seconds on screen
TRAP #15

MOVE.B #$0D,D1 ; print carriage return
MOVE #6,D0
TRAP #15

BRA START ; repeat


; halt simulator

* Variables and Strings



END START ; last line of source


Top
 Profile  
 
 Post subject: Re: Stopwatch timer
PostPosted: Tue Jan 21, 2014 10:46 am 
Offline

Joined: Tue Nov 15, 2005 7:58 am
Posts: 129
Location: Oregon, USA
Your comments are pretty good. but you need to flesh out your code more before asking for help. Where's the part where you read the start/stop key(s)? Where do you initialize the elapsed time to zero? Where do you calculate elapsed time, vs. current time?

Some preliminary comments:
Quote:
;DIVU #100,D1 ; time in seconds in D1 (RH)
; remaining hundredths in D1 (LH)
; NB this will not work after about
; 6 PM, at which time the number of
;seconds exceeds what can be held in
;16 bits

If the number of seconds is more than 12 hours, then before dividing, subtract 12 hours and keep track that you have done so.

Code:
MOVE.B #$0D,D1 ; print carriage return
MOVE #6,D0
TRAP #15

This won't do what you say it does. Task 15 prints a number, not a character.


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: Bing [Bot] and 8 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