Order Now  +1 678 648 4277 

Stopwatch timer up to tenths of second using 68k assembly assignment help

The assignment deals with simulating a stopwatch timer using 68k assembly. The program written by our 68k assembly assignment helpers allows the user to start and stop the stopwatch by pressing the keys. The stopwatch current time is displayed on the screen using the mm:ss:s format. The current time is read from the system using a trap.

Simulating a Stopwatch Timer

*----------------------------------------------------------- * Title: Stopwatch timer * Written by : * Date: Dic 9, 2017 * Description: A program that displays minutes, seconds and * tenths with the following format: * mm:ss.s * Starts at zero. When a key is pressed, the * display increments, another press stops it. *----------------------------------------------------------- ORG $1000 START: first instruction of the program CLR.L D3; D3 will indicate stopwatch running, initialize to zero CLR.L D5; D5 will be 1 to restart the stopwatch LOOP: MOVEA.L #DISPLAY,A1 ; print current display MOVE.L #14,D0 TRAP #15 MOVE.L #7, D0; see if the user pressed a key TRAP #15 CMP #0,D1 BEQ NEXT; if no key was pressed, continue MOVE.L #5, D0; read the key into D1 TRAP #15 EORI #1, D3; flip the stopwatch state NEXT: CMP #0, D3; see if the stopwatch is running BEQ CLEAR; if not, loop displaying the current count, clear first CMP #0, D5; see if we need to restart the stopwatch BNE UPDATE; if not, update the display MOVE #8, D0; get time in hundredths of sec in D1 TRAP #15 MOVE.L D1, D4; set as the start of stopwatch MOVE.L #1,D5 ; set D5 to 1 to indicate no restart UPDATE: MOVE #8, D0; get time in hundredths of sec in D1 TRAP #15 SUB.L D4,D1 LEA DISPLAY, A0; get the address of display message into A0 DIVU #100, D1; time in hundredths of seconds in D1 MOVE.L D1, D2; save in D2 SWAP D1; move the upper 16 bits down to get remainder AND.L #$0000FFFF,D1 ; set left hand part of D1 to zero DIVU #10,D1 ; get tenths digit ADD #48,D1 MOVE.B D1,6(A0); save in display message AND.L #$0000FFFF,D2 ; set left hand part of D2 to zero DIVU #60, D2; time in seconds in D2 MOVE.L D2, D1; save in D1 SWAP D2 AND.L #$0000FFFF,D2 ; set left hand part of D2 to zero DIVU #10,D2 ; get first seconds digit ADD #48,D2 MOVE.B D2,3(A0); save in display message SWAP D2; move the upper 16 bits down to get remainder ADD #48,D2 MOVE.B D2,4(A0); save in display message AND.L #$0000FFFF,D1 ; set left hand part of D1 to zero DIVU #10,D1 ; get first minutes digit SWAP D1; move the upper 16 bits down to get remainder ADD #48,D1 MOVE.B D1,1(A0); save in display message SWAP D1 AND.L #$0000FFFF,D1 ; set left hand part of D1 to zero CMP #0,D1 ; see if we reached 10 minutes BEQ SKIP CLEAR: CLR.L D3; set as stopped CLR.L D5; restart the stopwatch SKIP: MOVE.B #$0D,D1 ; print carriage return MOVE #6,D0 TRAP #15 BRA LOOP; repeat DISPLAY: DC.B '00:00.0' ; line to display DC.B 0 DS.W 0 END START; last line of source