Description
This is the famous harmonic summation problem. It has been used in many places to benchmark the speed of the main processor. Here you compute the sum and the amount of time needed to compute that sum.
Background for the application
The Harmonic series has nth partial sum: Hn = 1 +++ . . . . + . It is known from mathematical studies that Hn grows arbitrarily large as n goes to infinity. We are interested in the question: Given a positive integer n what is the value of Hn? Simultaneously, we want to compute the runtime needed to make that computation.
Assignment
Make an x86 program that inputs a value N, which is the number of terms in the summation, and outputs the sum, the runtime, and some intermediate values as shown in the sample execution below.
Make a driver program that calls the assembly program. As usual the driver is not part of the solution. The driver doesn’t know the actions of the called program.
Sample execution: input number = 87
Welcome to the Harmonic Sum programmed by Barbara Boswell
Please enter the number of terms to be included in the sum: 87
The clock is now 3577685633 tics and the computation will begin
Terms completed Harmoic sum
9 2.8532423456645
18 2.9923413245356
27 3,0345464765777
36 3.3435674572108
45 3.7786547580712
54 3.8987343575689
63 3.9678342167897
72 4.0034856341213
81 4.0345546789098
87 4.0575613435376
The clock is now 3763457809 tics.
The elapsed time was 8543678 tics, which equals 6359.84 seconds.
The harmonic sum will be returned to the driver.
The driver received this number 4.0575613 and will keep it.
A zero will be returned to the operating system. Have a nice day.
//Don’t panic. The numbers above are not mathematically correct. They simply show the perceived layout of the user interface.
The goal is to show the harmonic sum growing the regular intervals during the execution. Ten more or less evenly spaced outputs would be nice. If the input number is 10 thousand then the output of a single line each one thousand calculations is reasonable.
Modular structure
My opinion is that there is not enough activity in this program to warrant more than a driver module and a manager module.
I cannot see enough activity to include separate functions to be called by manager. You already have read_clock from an earlier assignment. Now it is time to re-use read_clock.
Ultimate test
Run your program and enter 1 trillion for input. That should keep your computer busy for about 25 minutes. Well, maybe things have changed. That 25 minutes of run time came from about 3 years ago. Maybe processors are better now. Or maybe your program code is better than then.
When your program works
Celebrate. There are no more assembly programs to create as a student. As an employee that will be a different story.
I will test your program using small integers for number of terms. I will not be able to test everyone’s program for the 1 trillion input. In the comments write me a note giving your run time in seconds and the harmonic number computed when you entered 1 trillion. [1 trillion is the number of terms included in the sum.]
Send me your source files at the usual place: holliday@fullerton.com
Last day for credit: December 7, 2020 at 23:59pm. [Not 00:00am on Dec 8.]
We’re done.
Have a nice vacation in January 2021. Come back fresh on January 25, 2021 to log in to brand new zoom sessions.
If you’re graduating in December 2020 then congratulations. You should be visiting job sites all through January. We have a new career specialist in ECS as of a couple months ago. I wrote about her in one of the pages at our class website. You should contact her electronically for help in finding a career job or an intern job.
The last day for faculty to submit grades is the first working day of January, namely: January 4, 2021. After that date I will begin to respond to the long queue of pending email.
Now study and graduate. I am going to miss the fun. I think I will miss all of you too.