Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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. how do i do this?

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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions

Question

Does the business have a well-defined target market?

Answered: 1 week ago

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago