Assignment 7, due Mar 15
Part of
the homework for 22C:60 (CS:2630), Spring 2013
|
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!
A problem: Write a subroutine that takes a pointer to a null-terminated string as a parameter and edits that string, converting all upper case letters in that string to lower case. (The string must be stored in RAM, not ROM, for this to be possible. This is not a machine problem. If your code is correct and legible, it will receive full credit even if it is handwritten.) (1.0 points)
if (!((ch < 'A')||(ch > 'Z'))) ch = ch + ('a' - 'A');
A problem: Apply DeMorgan's laws to the Boolean expression on the if statement. The result should be easier to read. (0.2 points)
To simplify this problem, let's imagine for the moment that the Hawk has a 12 bit word with bits B11 (the most significant bit) through B0 (the least significant bit). Furthermore, assume that there are just 3 bits per byte, so byte zero consists of B0, B1 and B2, and byte three consists of B9, B10 and B11.
a) Give a Boolean expression for the C condition code as a function of bits B0 to B11. (0.3 points)
b) Draw out a schematic logic diagram equivalent to the above. Legibility is important here. If you can't draw a straight line, use a ruler. (0.3 points)
if (b) a=!c; else a=c;
a) Draw a neat and legible schematic logic diagram showing how to compute the exclusive-or of two variables using a 2-input multiplexor and a not-gate. The logic is exactly the same as the code above. (0.3 points)
b) The Hawk has no instruction to compute the exclusive-or of two variables, analogous to the ^ operator in languages like C and Java. Instead, a two-instruction sequence is required to compute this. Give the sequence required to compute R3=R3^R4. (0.3 points)
a) (0.3 points) Give the truth table for an equivalence circuit with inputs a and b and output c. (0.3 points)
b) Use the general methodology for converting any truth table to a logic circuit given in the middle of Chapter 8 of the notes to derive the logic circuit for equivalence from your truth table. (0.3 points)