# Assignment 11, due April 17

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!

1. Background: Here is the specification for a flipflop of some kind:

c = a + b

d = a b

e = c f

f = d + e

a) Draw the diagram for this circuit using standard logic notation. Neatness counts. You may want to work out a preliminary version and then redraw it. The inputs a and b should be on the left, while the outputs e and f should be on the right in your final product. (0.4 points)

b) What values should c and d have in order to allow this flipflop to hold a stored value? (0.4 points)

c) What combination(s) of a or b will force c and d to take the values you identified for part b). If one of the variables can be either zero or one, you should not even mention that variable. (0.4 points)

d) This flipflop behaves very similarly to one of the flipflops discussed in the notes. Only one of the inputs or outputs behaves differently. Conventional flipflop inputs, outputs and intermediate points have conventonal labels such as C, D, R, S, R, S, Q and Q. Relate a, b, c, d, e and f to these conventional names in a way that clearly relates this flipflop to the conventional flipflop to which it is most closely related. (0.3 points)

2. Background: Consider two possible approaches to virtualizing the Hawk instruction set on the Sparrowhawk machine:
• The sparrowhawk.h macros without the STRICTSPARROW restriction. In this case, you have to re-assemble your original program to make it run on the Sparrowhawk.
• A trap handler for the undefined instruction trap on the Sparrowhawk that emulates the missing instructions. In this case, you can assemble your program with hawk.h and then run it on the Sparrowhawk.

a) Given that your Hawk program can be run either way, which approach will give you the fastest execution times? (0.5 points).

b) What limitation does one of these approaches have that causes it to fail to work correctly with some programs? (0.5 points)

3. Background: The Hawk hardware raises a bus trap when your program attempts to reference a nonexistant memory location. Suppose you wanted to have the Hawk monitor convert undefined instruciton traps into a software exception of the sort discussed toward the start of Chapter 13. Obviously, the first step is to define MEMORY_EXCEPTION, a global variable (COMMON block).

At a very high level, the bus trap handler looks like this:

1. Save PC, R1 to R15 and PSW in the trap save area.
2. Do something.
3. Restore PC, R1 to R15 and PSW from the trap save area in order to return from trap.

In this case, the return from trap will transfer control to the exception handler. The details of how the registers are saved and restored are discussed at length in Chapter 13 of the Hawk manual as well as in Chapter 13 of the notes, but these details do not matter to this question.

A problem: Describe (in a few lines of English text or pseudocode) what the code for the Do something step should do. This must describe how the EXHAND and EXAR fields of the fields of the common block are used. (0.5 points)