Department of Information Technology

Assignment 2 Mobile Phones, Calculators, and SPIM's Memory-Mapped I/O

Goal :

  • Learn how to write simple I/O routines in MIPS.

Obs :

  • Please follow the guidelines provided here for submission.
  • It is important that you have been through the tutorial, the lab and the first assignment.
  • Deadlines: first deadline 22 Mars 2009,completion 29 Mars 2009
  • This assignment is compulsory only for the 1DT016 instance.

This is the last MIPS assignment. It is about writing a mini calculator simulator that is common in many mobile phones.

All input and output must follow the so-called memory-mapped I/O (or polling) scheme. You will implement it in this assignment. All you need to know about is in section A.8 of Patterson and Hennessy.

Pay a special attention to the last part. Note the difference between the memory mapped approach and the interrupts approach. You will be implementing memory mapped I/O; interrupts are also possible in SPIM, but coding them is longer and harder.

Only correct input will be accepted, and in simple mobile phones this means only numbers 0,1,2,...,9, and the operations +,-,* and /. Three more characters will be used y = "Yes" button, n = "No" button, and x = "Exit program" button (see example bellow). All the other characters will be ignored.

Only integers are accepted by the program. The program needs not calculate operations which lead to a result bigger than 2147483647 (2^31 - 1). Moreover, you are not allowed to use I/O system calls (syscalls) like in the previous assignment.

  • It can be tricky to get the memory mapped input/output to work. Therefore, it is recommended to divide the programming into two steps. Write and test the polling I/O routines first (fill in the readCharacter and printCharacter). Then, fill in the printString subroutine.
  • As you know : THINK FIRST before beginning the coding ! This will save you plenty of time. In this assignment you have much freedom for the main code structure. The program can of course use the procedure int_to_string (from the previous assignment). It is suggested that you fill in the given subroutines (ex parseChar), they are supposed to be independent and they should follow the given specifications. You will be able to determine yourselves how you can make good use out of them.
  • Optional improvement: manage overflow. In case of an overflow the program can print a message; for example "Too large value entered".
  • In the following table, we give an example on how the calculator is supposed to work.

The bold text and the one between "< >" represent the input. The characters in the control column, ex <y> (show result), are "invisible" characters: they are not to be printed. Only the left column are to be printed.

output control
123 <+> (add)
123+256 <*> (multiply)
379*1111 <y> (show result)
=421069 </> (divide)
421069/3 <y> (show result)
=140356 <n> (reset)
0 <+> (add)
3 <y> (add)
3 <x>
Good Bye!

Good Luck!

Updated  2009-03-09 14:12:13 by David Eklöv.