0% found this document useful (0 votes)
28 views2 pages

Assembly

This document contains assembly code that measures elapsed time in minutes, seconds, and tenths of seconds. It displays the keyboard prompt "Press s to start the program". If the user presses S, it begins looping to get the current time and calculate the difference from the start time. It then displays the elapsed time in minutes:seconds.tenths format, clearing the screen before each new output. The loop repeats until 10 minutes have passed, at which point it halts the simulator.

Uploaded by

atif
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views2 pages

Assembly

This document contains assembly code that measures elapsed time in minutes, seconds, and tenths of seconds. It displays the keyboard prompt "Press s to start the program". If the user presses S, it begins looping to get the current time and calculate the difference from the start time. It then displays the elapsed time in minutes:seconds.tenths format, clearing the screen before each new output. The loop repeats until 10 minutes have passed, at which point it halts the simulator.

Uploaded by

atif
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

ASSIGNMENT

*-----------------------------------------------------------
* Title :
* Written by :
* Date :
* Description:
*-----------------------------------------------------------
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
ASSIGNMENT
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

OUTPUT:-

You might also like