Assignment 7, due Oct 14

Part of the homework for 22C:60 (CS:2630), Fall 2011
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

On every assignment, write your name legibly as it appears on your University ID card! Homework is due on paper at the start of class on the day indicated (usually Friday). Exceptions will be made only by advance arrangement (excepting "acts of God"). Late work must be turned in to the TA's mailbox (ask the CS receptionist in 14 MLH for help). Never push homework under someone's door!

  1. Background: Consider the "string compare" operation:
    	strcmp(a,b)
    

    This compares two strings a and b. If they are equal, it returns zero. If the first string is greater than the second, it returns a positive value. If the first string is less than the second, it returns a negative value. The return value of zero occurs when all characters are equal up to and including the final NUL marking the end of string. The nonzero return values indicate whether the first character where the two strings differ is greater or less, as illustrated by these examples:

    	strcmp("abc"," ") > 0    because 'a' > ' '
    	strcmp("abc","a") > 0    because 'b' > NUL
    	strcmp("abc","aa") > 0   because 'b' > 'a'
    	strcmp("abc","abc") == 0
    	strcmp("abc","abcd") < 0 because NUL < 'd'
    

    A problem: Write SMAL Hawk code for strcmp(). Use the standard Hawk calling conventions, so pointers to the strings a and b will be passed in R3 and R4, and the result should be returned in R3. (1.0 points).

    No main program should be turned in, but you are welcome to write one to test your code.

  2. Exercises from Chapter 8 of the Notes:

    a) Do exercise a). Work this out by: First, drawing the schematic diagram and labeling the output of each gate. Second, writing out a truth table with one output column for each labeled point in the circuit. Work it through to the final output and then compare this with each of the known functions of two inputs. (0.5 points).

    g) Follow the instructions. Note (emphatically) that the borrow signal from one bit to the next signals the need to borrow. So, it is an output from each less significant bit to the next more significant bit, just like carry. (0.5 points)

    k) (0.5 points).

    l) (0.5 points).