$30
CPSC 240 Assignment 6
Sleep Time
Preface
The main objective of this assignment is to reinforce your knowledge about the cpu clock by
hands-on experience.
There are no new assembly instructions in this assignment. The assignment serves to
reinforce your knowledge from Assignment 4 of this semester.
Broad view of the requirements
In other programming languages you will find a delay statement. It may look like
“delay(3000);” or “sleep(5500)”. The value passed to the function is the length of the delay
expressed in milliseconds (ms).
The main requirement for this program is to make a block of assembly instruction that will
block the application from doing anything useful until the correct amount of time has elapsed.
Dialog for the Baseline Program
Welcome to Daylight Sleeping Time brought to you by Larry Haskell.
We will send a birthday greeting to Chris.
How many birthday cards do you wish to send? 4
Thank you. The time on the clock is now 4234789232981 tics.
Happy Birthday, Chris
Happy Birthday, Chris
Happy Birthday, Chris
Happy Birthday, Chris
The time on the clock is now 4232995281454 tics
The elapsed time was xxxxxxxxxxx tics.
The elapsed time will be returned to the caller.
The main received this number xxxxxxxxxxx and will keep it.
A zero will be sent to the Operating System. Bye.
//End of dialog.
Make your computer subtract early time from late time and output that difference where the
string of x's appears.
Replace Larry’s name with your own name.
The baseline program contains no delays. It runs at computer speed.
Dialog for the Challenge Program
Welcome to Daylight Sleeping Time brought to you by Larry Haskell.
We will send a birthday greeting to Chris.
How many birthday cards do you wish to send? 4
What is the delay time (ms) between sending greetings? 2250
What is the max frequency of the cpu in this computer as a whole integer? 2 950 000 000
Thank you. The time on the clock is now 4234789232981 tics.
Happy Birthday, Chris
Happy Birthday, Chris
Happy Birthday, Chris
Happy Birthday, Chris
The time on the clock is now 4232995281454 tics
The elapsed time was xxxxxxxxxxx tics.
The elapsed time will be returned to the caller.
The main received this number xxxxxxxxxxx and will keep it.
A zero will be sent to the Operating System. Bye.
//End of dialog.
The unseen part occurs after each Birthday message. That is where the “sleep block”
executes. In fact the sleep block is the only new artifact in this program. The rest of the
instructions used here were first introduced in Assignment 4.
There are no xmm registers used in this program.
Replace Larry’s name with your own name.
If your getfrequency function is working correctly you should use in this program and omit
asking the user to input his or her frequency.
System Diagram for baseline
We want a minimal configuration for this program.
System Diagram for challenge
greeting.asm
Main
C or C++
birthday.asm
r.sh
bash
sleep.asm
greeting.asm
Main
C or C++
birthday.asm
r.sh
bash
Conclusion
You already know the facts about evaluating programs and midterms and finals. There
comes a time when I can no longer return assignments and test before the end of the
semester. You heard the announcement of this subject in lecture a couple weeks ago.
No score of point will be given for this assignment.
I encourage you to do all the assignments including this one. Doing a program reinforces
learning at a level far above simple reading on a subject. I still invite you to send me your
completed program #6. I will read it and test it and send you feedback about your product.
Due date: May 15, 2023
Calendar Spring 2023
I will be in the classroom for all remaining regular lectures. If I should be in the classroom
during tests remains an open question.
May 1: Conclusion for GDB and “Inline Assembly”
May 3: Subnormal numbers; Review topics from the early half of the semester.
May 8: Review recent subject of this semester
May 10: Concepts test
May 15: Programming test
Good-bye Johnson
May 2023 marks the end of a special era. After May Johnson will be moving on to higher
activities. This marks the end of 3 semesters he has been a key person in 240 education.
Those of you who have been in his sessions know that an SI meeting with Johnson in charge
is a phenomenon not replicated anywhere on this campus. You will not get the same
experience again.
Here is a true anecdote. In the first semester that Johnson was Si instructor there was a girl
students struggling along like everyone else. During the open hour following each lecture I
asked if she would teach little endian during the first 20 minutes of the next class meeting.
Here immediate response was “What! I am no Johnson! How do you expect me do that?”
Then I got it. Something magical happens in SI meetings that loads people’s brain cells with
knowledge. From me “Thank you Johnson for being here during these recent semesters.”
Good-bye class
Thank you for spending the last 16 weeks with me in my world of assembly. I did not learn
the names of everyone, but I did learn the names of many of you.
Some students prefer in-person classes and others prefer remote lectures. I tried to
accommodate both sides of the question by making lectures both in person and in zoom. I
hope you found that helpful.
Eighty-five percent of you will not use assembly in the future – I know that. But, don’t discard
your assembly knowledge completely because it might save your job if and when your
company downsizes.
I will miss all of you. Study hard next semester and get the job that come after graduating.
Next year when you need a hold removed from your portal come to my express advising
without an appointment. That is the easiest way to remove a hold.
Good luck, get the job you will enjoy,
Stay well, and good-bye.
F. Holliday