Program 6, Part A

(printable version)

Purpose

This program is intended to provide understanding in the areas of I/O implementation, memory mapped I/O and spin wait loops (polling).

Program Statement

Write a MAL program that reads in user-entered strings. The program keeps counts of the number of times each letter appears in the input. The program stops reading the user input when it encounters the period (`.') character as the first character on a new line. The program then prints out the count for each letter.

Put this MAL program together with a kernel in which you implement the MAL I/O functions of getc, putc, and puts. This functionality will be implemented using memory mapped I/O and spin wait loops.

Provided for you is a working kernel. The kernel you will use for this program is in the file
~cs354-1/public/bin/spinwait.kernel
Copy the file (to your own directory), and modify your copy. Note that this kernel works, but it is missing the code to do the syscall functions getc, putc, and puts. You will need to add code to this kernel to make these syscall functions work.

The simulator (sim) has a default kernel of its own that it uses. In order to substitute and test your own kernel, you must use a different version of the simulator, called isim. The user interface is exactly the same as sim, but a kernel must be supplied with the user-level program. Note for users of the PC version: you will not be able to use the PC port of the simulator for this assignment. It may look the same, but it does not work the same.

A sample execution of the program looks like
Letter counting program.
Enter a period as the first character on a line to end the program.
Count the letters in my strings.
There are two lines in my input.
.
Counts of the letters:
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
1 0 1 0 7 0 1 2 5 0 0 2 2 6 2 1 0 4 4 8 2 0 1 0 2 0

Requirements

  1. Make your program work the same as the sample run.
  2. Use MAL/TAL instructions only. For the I/O instructions getc, putc, and puts, substitute the MAL/TAL instructions that the assembler would use. When this is finished, your code will not have the instructions getc, putc, or puts, but will instead use syscall.
  3. Your program must be well commented.
  4. Your implementation of the MAL I/O functions of getc, putc, and puts are to be implemented within the kernel using memory mapped I/O and spin wait loops.

Recommended Approach

  1. Keep backup copies of each piece of this program.
  2. Make sure that you have a working version of the user-level program that reads the strings and prints the letter counts before going on to the next step. Test this user-level program with sim.
  3. Modify the user-level program so that it uses syscall directly instead of the MAL instructions getc, putc, and puts. Again, test this program using sim. Make and keep a separate copy of this program. (It will be needed to do program 6.)
  4. Copy the spin wait version of the kernel. Add to the kernel to implement getc, putc, and puts. Put this completed kernel together with the user-level program that uses syscall into one file. The kernel must be first within the file. Test this code using isim.

    Hints

    1. You have already written a procedure to print out an integer. Reuse that procedure in this program!
    2. Don't forget to have the code within the kernel echo keyboard input.
    3. The user-level program should be easy for you to write. The difficult part of this program is getting the kernel to work.

      Handing In the Program

      You must "hand in" your program (the SAL source code) to the computer directly by typing

      cp p6A.s ~cs354-1/handin/username/P6A/.

      just once, where "p6A.s" is the name of the file containing your SAL source code and "username" is your CS login. No printouts will be turned in. I will run your program several times using different test data.