EASy68K
http://www.easy68k.com/EASy68Kforum/

Stopwatch timer
http://www.easy68k.com/EASy68Kforum/viewtopic.php?f=6&t=1278
Page 1 of 1

Author:  CAZA36 [ Sun Jan 05, 2014 7:58 pm ]
Post subject:  Stopwatch timer

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

Author:  gtippery [ Tue Jan 21, 2014 10:46 am ]
Post subject:  Re: Stopwatch timer

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.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/