Assignment 7, due Oct. 16
Part of
the homework for 22C:60, Fall 2009
|
Always, on every assignment, please write your name legibly as it appears on your University ID and on the class list! All assignments will be due at the start of class on the day indicated (usually a Friday). The only exceptions to this rule will be by advance arrangement unless there is what insurance companies call "an act of God" - something outside your control. Homework must be turned in on paper and in class! Late work may be turned in to the teaching assistant's mailbox, but see the late work policy. Never push late work under someone's door!
A problem: Write a Hawk subroutine that takes R3 as a pointer to a memory location and reverses the order of the bytes in that location. Your code should follow all of the usual Hawk calling conventions and it should be well documented. (1 point)
A problem: Write a Hawk program fragment equivalent to the following C-ish code to traverse the list and print the first character of each string in the list, except where the pointer to the string is null and except when the string is of length zero. (1 point)
while (R3 != NULL) { char * T = (*R3).TEXT; if (T != NULL) { char CH = *T; if (CH != NUL) dspch(CH); } R3 = (*R3).NEXT; }
Note: In C, the declaration char * p declares p to be a pointer to a character. The expression *p, in this context, is the character pointed to by p. The notation o.f refers to field f of object o.
x = not( a and b)
y = not( a and x)
z = not( x and b)
c = not( y and z)
a) Make a truth table showing x, y z, and c as a function of a and b. (0.5 points)
b) What logic function is this? (0.5 points)