Assignment 1, due Jan. 19

Part of the homework for CS:3620, Spring 2018
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

On all assignments, your name must be legible as it appears on your University ID card! Assignments are due at the start of class on the day indicated (usually Friday). Exceptions will be by advance arrangement unless there is what lawyers call "an act of God" (something outside your control). Homework must be turned in on paper, either in class or in the teaching assistant's mailbox. Never push late work under someone's door!

  1. Prerequisite material:

    a) What computer instruction set(s) have you studied? Commercially available CPUs and fictional processors are equally relevant. (0.3 points)

    b) Pick an instruction set you identified in part a and translate the following function to assembly language: (0.7 points)

    int fib( int i ) { if (i < 2) return i; return f( i - 1 ) + f( i - 2 ); }

  2. Background: A paper by Parnas and Siewiorek is referenced in the notes for Jan. 17 that contains a preliminary example. What is the example? (1 point)

  3. Background: If you do not have a CLAS Linux account, create one. The instructions are here:
      — http://clas.uiowa.edu/linux/
    Go to the sub-page listing CLAS Linux Services and follow the instructions there for "Create a CLAS Account". Note that this is easier from on campus, for example, in one of the Information Technology Centers, because off campus users may have to tunnel through the University's firewall using a VPN. (The link for how to set that up is there too.)

    Use your account to sign in to linux.cs.uiowa.edu (an alias for a cluster of Linux servers) using FastX. The following link takes you to FastX:
      — http://fastx.divms.uiowa.edu
    FastX opens a remote Linux desktop. The MATE desktop has an icon at the top to let you open a command line shell interface in the a terminal window.

    When it is time to end your session, the exit shell command will close your terminal window. To close your FastX session and log out of Linux, click on the LogOut button in the System pull-down menu on your Linux desktop.

    For additional guidance, see:
      — http://clas.uiowa.edu/linux/help/remote_access

    A question: Use a shell window on a CLAS Linux machine. Type the following command:
      [HawkID@serv16 ~]$ ~dwjones/opsys
    (Boldface in the above is the command you type, non-bold is the prompt from the system; type the requested text verbatim, do not change a thing, do not replace dwjones with your HawkID.) Report the output you got. If you did not make it all the way to the point where you could do the above, report how far you got. (1 point)

     

    Machine Problem I

    Due Monday, Jan. 29

    Here is a little C program to copy arbitrary files from standard input to standard output:

    /* MP1 by --------- for CS:3620 */
    #include <stdio.h>
    int main() {
            int ch;
            while ((ch = getchar()) != EOF) {
                    putchar(ch);
            }
    }
    

    a) Modify this program so that the header comment has your name instead of the dashes shown in the code above.

    b) Modify it so that it deletes carriage return ('\r' in C) characters from the input. If you carelessly upload a text file from a Windows system, this makes your program useful -- it will strip out all of the extraneous carriage returns from the DOS-format line endings.

    c) Modify it so that all control characters other than carriage return and line feed ('\r' and '\n') are replaced by two-character sequences consisting of an up-arrow (^) followed by the printing character you get by adding the code for '@' to the code for the control character. For our purposes, control characters are encoded by integer values less than space.

    All of your code must conform, as much as is possible, to the manual of style:

    -- http://homepage.cs.uiowa.edu/~dwjones/syssoft/style.html

    The purpose of this assignment is to get you to use the departmental Linux servers, some text editor, and the C compiler, with a program somewhat more interesting than the classic hello world. Your solution must be in a file named mp1.c (all lower case). Submit your solution using the coursework submission tools documented at:

    -- https://clas.uiowa.edu/linux/help/start/submit

    In short, you will type the shell command submit, with no arguments, and when it prompts for a file name, you will type mp1.c. and then an extra carriage return to indicate that there is only one file in your submission. When it prompts for a course, type CS3620 and when it prompts for an assignment directory, enter mp1.