Machine Problem 2

22C:18, Fall 1996

Due Monday June 30, 1997, in class

Douglas W. Jones

Modify your solution to Homework 3 problem 1 so that it reads the value of t from the keyboard. To do this, your program should begin by reading a line from the keyboard, using the monitor routine KBGETS.

Note that KBGETS requires, as a parameter in R3, a pointer to the buffer where the string is to be put, and that KBGETS destroys the contents of R3 to R7. KBGETS is not well written: It imposes no limit on the length of an input string; in this regard, it is exactly as badly designed as the standard C routine gets()! Read the UNIX manual page on gets() and fgets() to see clear documentation of both the wrong and right ways to design such a service!
To convert between the textual representation of a number returned by KBGETS and a binary integer, call the external function ATOI. You will have to write ATOI and assemble the code for it! ATOI should conform to the definition given for the standard C routine; read the UNIX manual page on atoi() for documentation of this. The parameter should be passed in R3 and the value of the function returned in R3.

Turn in:

  1. An assembly listings of your main program.
  2. An assembly listings of your ATOI routine.
  3. The linker's map of the combined results.
Comment all parts of your program appropriately -- not too much or too little!