Assignment 6

CS/ECE 354-2, Fall 1998

due Monday Dec. 7, before 5pm

Read this entire assignment before you begin!


Program

Purpose

This program is intended to provide experience with exception handling.

Program Statement

Write a Pentium program that gives a little typing test to the user. Keep the string

The quick brown fox jumps over the lazy dog.
in an array of characters. Prompt the user to enter this string. Count the number of errors the user makes. Calulate the number of seconds that the user takes to enter the string. Print this statistic out. Also calculate the number of words the user typed per minute. Use 9 as the number of words in the string. Do integer calculations for the number of words per minute (not floating point), using
words per minute = (9 words * 60 seconds) / time for user input

		 = 540 / time for user input

2 Example Runs

Type the string:
The quick brown fox jumped over the lazy dog.
The quick brown fox jumped over the lazy dog.  
Number of errors:
0
Seconds to enter the string:
28
Words per minute:
19
Type the string:
The quick brown fox jumped over the lazy dog.
the wuick brown fox jumped over the lazy hog.  
Number of errors:
3
Seconds to enter the string:
15
Words per minute:
36

Information about the Clock

To complete this assignment work, you use a different set of macros than the previous assignments. You will get a copy of the file exceptions.inc, and include this file instead of Pmacros.inc.

These macros include a new one, called start_clock. This macro starts the mechanism which will generate clock interrupts at the rate of 1 per second (not realistic, but nice to work with for the assignment). This macro requires the address of the clock interrupt handler as its operand.

You will need to write the clock interrupt handler. It will be written just like a Pentium procedure. To return from this procedure, use the instruction


ret   20

The call to this interrupt handler places 5 parameters on the stack, which we do not use or care about. The handler is expected to remove the parameters before it returns. Note that what we are doing is different than an actual Pentium exception handler. An actual Pentium exception handler would not receive parameters, and it would return with the instruction iret. Also note that the clock interrupt handler goes in the same source code file as the typing test.

Your program also needs a way to find out what the current time is. This current time is what the clock interrupt handler keeps track of. The clock interrupt handler places the value in a variable. Note that at this assembly language level, the variable is a global variable. Therefore, your typing test program finds out what the current time is by copying this global variable.

You will also need to link in a new library (which wasn't used before). This requires a change to the makefile (.mak). A new makefile is available for you, and it is called p6.mak.

These new files (exceptions.inc and p6.mak) are in the directory (folder):
/p/course/cs354-smoler/public

Recommended Approach

  1. Write the Pentium program that gives the typing test, but does not do any timing. Get this program working before going on to the next step. Note that you will want to include Pmacros.inc as you did for previous programs.
  2. Copy the file exceptions.inc to your directory (folder). Also get the new makefile (p6.mak), and modify it if necessary. Change the source code to include exceptions.inc instead of Pmacros.inc. Test the program with this new include file. It should work the same as before, except that the output window will just stay around after the program is done. Click on the 'X' to get rid of the window after each time you run the program.
  3. Add your clock interrupt handler procedure. Check that the program still works.
  4. Add code to the main program to start the clock interrupts. Place the code at the very beginning of your program. Again, check that the program still works.
  5. Add code to use the current value of time in calculating number of seconds it took to enter the string and the number of words per minute.

    Handing In the Program

    Follow the guidelines in how to turn in assignments. For this program, you will need to turn in your source code (the .asm extension) and your makefile (the .mak extension). No printout will be turned in.


    NO Homework!