## CS 2011, A Term 1999 Professor Sergio A. Alvarez Practice Problems for Test 3

1. A C++ program contains the following declaration of an external assembly procedure:
```   extern "C" void doublebyref(int x, int& y);
```
The parameters x, y are assumed to be short integers that occupy two bytes of memory each. Notice that x is passed by value, whereas y is passed by reference. Standard C naming and calling conventions are assumed to be in effect.

• (a) Give the full proc / endp directives for the assembly procedure. Do not include any explicit parameter declarations.
```

```

• (b) Write assembly instructions that set up a stack frame within the assembly procedure and then copy the value of the parameter x to register ax. Previous contents of ax should be saved for future use.
```

```

• (c) Write assembly instructions that double the value of x and store the result in the location indicated by y. You may assume that the stack frame has previously been set up and that x has been copied to registers ax as described in part (b) of this problem.
```

```

• (d) Write assembly instructions for the assembly procedure that finalize the stack frame of part (b), perform any necessary final tasks, and return control to the calling program.
```

```

2. Which of the following Boolean operators are complete in the sense that each of them alone (in sufficient quantities) suffices to compute any Boolean expression? For each operator that you claim is complete, give a general argument in support of your claim. For each operator that you claim is not complete, give a specific truth table that cannot be reproduced by any combination of operators of the given type.

• (a) AND
```

```

• (b) OR
```

```

• (c) NOT
```

```

• (d) NOR
```

```

3. Consider the Boolean function g(A,B,C,D) that returns 1 if the 4-bit unsigned binary integer ABCD equals 0, 1, 2, 3, 8, or 10 (decimal), and returns 0 otherwise.

• (a) Give the disjunctive normal form (standard sum of products expression) for g, based on its truth table. Include the truth table in your answer.
```

```

• (b) Draw a Karnaugh map for g and use it to find a simplified equivalent Boolean expression for g as a sum of exactly two products, each containing exactly two factors.
```

```

• (a) Using only standard two-input NOR gates, construct a logic circuit that computes the Boolean function
```   f(A,B,C) = A'B + C
```
Your answer may be given either as a circuit diagram, or else as a symbolic expression using the notation X NOR Y. In any case, explain your answer.
```

```

• (b) Use a Karnaugh map to find the simplest possible Boolean sum of products expression for the function h(A,B,C,D) whose value is 1 if the unsigned binary integer ABCD is greater than or equal to 11d, and is 0 otherwise.
```

```

4. Consider the basic latch circuit discussed in the lectures, containing two NOR gates, the first having output Q and inputs Q~, R, the second having output Q~ and inputs Q, S.

• (a) Draw the latch circuit. Label each input and output for each of the two NOR gates.

```

```

• (b) Fill in the output values:
```Q = _, Q~ = _
```
if the input values are R=0, S=1.

• (c) Fill in the output values:
```Q = _, Q~ = _
```
if the input values are R=1, S=0.

• (d) Fill in the output values:
```Q = _, Q~ = _
```
if the input values are R=1, S=1.
```

```

5. Draw the circuit diagram for a 4-bit binary counter. Your circuit should have 4 outputs D0, D1, D2, D3, a clock input C, and a reset input R. The outputs should be set to 0 on the first rising clock edge occurring while the reset input is 1. The outputs should change on each rising clock input occurring while the reset output is 0, in such a way that the new outputs represent the result of incrementing the old outputs by 1 in the usual binary positional notation, with D0 as the least significant bit and D3 as the most significant bit. You may use standard flip-flops as building blocks.
```

```