CS 216 Assignment #3

Due Friday 17 March 2023

Name:

1. Prove by truth table one of the deMorgan laws,       (something important to keep in mind when you need 2 or more conditions)
	_____   _ _
A + B = A B which means NOT (A OR B) = (NOT A) AND (NOT B)
___ _ _
A B = A + B which means NOT (A AND B) = (NOT A) OR (NOT B)
Paste your preferred law here and fill in columns under each operation --
Answer here:


2. The truth table for "logical implication" (and exclusive or) are given in the truth table below.
How about NOR, the negation of OR? [A NOR B = NOT (A OR B) ] what are its truth values?
Also NAND. [A NAND B = NOT (A AND B) ]   Finally, fill in the last 3 columns. Have you seen that pattern before?
A
B
A implies B
A xor B
A nor B
A nand B
not A
  B 
(not A) + B
0
0
1
0



0

0
1
1
1



1

1
0
0
1



0

1
1
1
0



1


[In other words, if A is true, implication requires B to be true. If A is false, B can be anything. "That's logic!"]

3. The following assembly language instructions are "pseudo" instructions, that is, they are in fact not implemented by MIPS hardware. Instead, the assembler must convert them to 1, 2 or more actual machine instructions. It may use $1 ($at) in the process (that is why we don't use that register.) For each instruction, give a possible implementation, using only instructions that are not marked with a dagger, and therefore represent MIPS machine language instructions. (And therefore you may use $at, as the assembler would.)
Hint: You could look at these in QtSpim, but please use the symbolic register names, $t1 rather than $9, for instance.
not   $t1, $t0
neg   $t3, $t4
li    $t8, 303
div   $t5, $s1, 63


blt   $t6, 'a', notlower
sub   $t7, $t0, 1
(immediate operand is not hardware sub)

4. In assembly language, NOT is bitwise. Since slt or slti gives a result of either 0 or 1 (the other 31 bits are 0), what instruction, if any, can you use to produce a correct logical result (0 or 1) for not $t0, where $t0 has just been the result of slt? (store back in $t0)