CptS 260 third programming project

Assigned: Nov 5, 2008
Due: Dec 1, 2008, 5PM

Turning in your assignment

When finished, submit your file named io.s using the the Project turn-in link at the left side of the CptS 260 web pages. (Click the link and follow the directions.) You may turn in the assignment as many times as you like before the deadline. Only the last will be graded.

Introduction

Both SPIM and MARS support display output and keyboard input using memory-mapped I/O. This problem will probably be easier in MARS, however. In MARS, the facilities you need are provided in the "tool" called "Keyboard and Display MMIO Simulator". Find it on the MARS Tools menu. After clicking the menu item a window pops up. Click on the "Connect to MIPS" button at the lower left, and click on the "Help" button at the lower right and read the description.

As discussed in class, the keyboard and display are separate devices, as far as your MIPS programs are concerned. Each has a status register and a data register. The keyboard device base address is 0xFFFF0000 and the display device is at 0xFFFF0008. For each device the status register is at the base address and the data register is in the next word. The ready bit is the low-order bit (bit 0) of the status register and the interrupt-enable bit is bit 1. Values that are to be read or written pass through the low-order byte of the data registers. These are the only bits that are significant in any of the device registers.

The problem: I/O using busy waiting and interrupts

Write a program that uses the console and keyboard I/O system of either SPIM or MARS to:
  1. using busy-waiting I/O, implement a simple typing test in a function named typingtest. Prompt the user with the string Please type: The quick brown fox and all of that. Read characters from the keyboard and echo them to the display. If any character is typed incorrectly, immediately start a new line of output saying Sorry! Try again. and on the next line display the prompt again. When the user has correctly typed the string, display Congratulations! on a line by itself and return from the typingtest function.

    Implement functions putchar(c) and getchar() following the usual MIPS calling convention. Implement function putstr(s, n) using putchar. (s is a pointer to a string and n is the number of characters to display). Use these functions to implement function typingtest().

    Do NOT use the syscalls to perform I/O anywhere in this assignment.

  2. using interrupt-driven I/O, implement function putstring(s, n). The goal is that putstring should return immediately to its caller allowing the output interrupt handler to write the characters to the display. In function part2(), use busy-waiting I/O to read keys from the keyboard. Each time a key is read call putstring("NN characters have been read so far\n.", len) where NN and len are filled in with the appropriate values, UNLESS the character is q in which case return from part2.

    You will need to write a decimal conversion function for this part.

Your main program, then, consists of a single call to typingtest() followed by a single call to part2() followed by an exit syscall.

Grading