This program is intended to provide understanding in the areas of I/O implementation, memory mapped I/O and spin wait loops (polling).
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
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
.
getc
,
putc
, and puts
are to be implemented within the kernel
using memory mapped I/O and spin wait loops.
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.)
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.
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.