# Spring 2001 CSCI 255 Homework 4 Solution

## Problem 1

Assume x is a C integer variable. Show how you would set bits 5, 7, and 9 of x to 1 and clear bits 11 and 13 to 0 in one C-statment.

"`x` = (`x` | 0x280) & ~0x2800 ;".

## Problem 2

Take the R-S latch in Figure 3.17 (p. 61) and replace the two NAND gates with two NOR gates. Show that the modified latch is stable if S, R, and a are all 0 while b is 1.

In this situation a, being 0, is connected to the output of NOR(Sb) or NOR(0, 1); and b, being 1, is connected to NOR(Ra) or NOR(0, 0). Because the present values a and b are consistent with the NOR gate outputs, the circuit is stable.

Now raise R to 1. What happens to your modified latch?

The bottom NOR is now computing NOR(1, 0). This makes its output, b, change to 0. This zero propagates to the top NOR which is now computing NOR(0, 0). So its output, a now changes to 1. The one propagates down to the bottom NOR, which is now computing NOR(1, 1). However, its output, b remains 0. So we enter a new stable state where a is 1 and b is 0.

Finally lower R back to 0. Again, what happens to your modified latch?

Though the bottom NOR is now computing NOR(0, 1), its output remains at 0. Consequently, a and b do not change values.

## Problem 3

Decode the following LC/2 binary instructions, specified as hexadecimal numbers. That is, determine the type (opcode) of each instruction and specify its fields:

 0000 BR x0 0246 BRp x046 1545 ADD R2 R5 R5 1FFF ADD R7 R7 -1 4444 JSR R0 x144 6666 LDR R3 R1 38 8000 RTI 99BF NOT R4 R6 BBBB STI R5 x1BB F035 TRAP x35