# Assignment 12, due May 5

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: Consider the skeleton for a trap handler given in section 13.3 of the Hawk manual. In that skeleton, the label myCODE is used for the subroutine that actually handles the trap, while the body of the skeleton itself is devoted to saving the complete CPU state before calling myCODE and restoring the entire CPU state after return from myCODE.

A problem: Assume you are working on an undefined instruction trap handler. Your job is to make the instruction trap handler redefine all undefined instructions as being equivalent to a halfword no-op instruction. That is, whenever the CPU encounteres an undefined instruction, the trap handler should increment the PC by 2 and return from trap making no other changes to the registers. Your answer should be the complete code of myCODE for this trap handler.

Hint: It is not big code, perhaps 6 instructions, including subroutine entry and return. (1.5 points).

2. Background: Consider a problem where your program is manipulating an intensively used data structure with a size of n bytes, where your computation takes t time, and computation theory says that t=O(n).

Your machine has a cache with a capacity of 10,000 bytes where the cache allows memory operations in 1 ns. Main memory is much much larger, and has an access time of 20 ns. Assume that the program is small, so you can ignore the size of the program itself, paying attention only to the data.

A problem: Sketch a graph of t as a function of n. Theory predicts a straight line (and we didn't give you enough information for you to give the slope of the line. In practice, the line is not straight, and there is a kink in the line. On your graph, indicate the correct value of n where the line kinks, make the line kink in the correct direction, and give the ratio of the slopes above and below the kink. (0.5 points).

3. Background: In the Hawk, the virtual address and physical address have the same format, so the MMU takes a 30 bit virtual address in and outputs a 30 bit physical address.

A question: Aren't memory addresses 32 bits on the Hawk? Why did it say 30 bits here? (0.5 points).

4. Background: In the Hawk, the virtual address and physical address have the same format, so the MMU takes a 30 bit virtual address in and outputs a 30 bit physical address. The Hawk MMU interface is describe in Secitons 1.3.4.6 and 1.3.5 of the Hawk manual.

The marketplace these days demands that large machines support RAM sizes bigger than 4 gigabytes. A larger physical address could be supported by dedicating unused bits in the MMUDATA register to the physical page number.

A question: How many bits are there in the largest physical (word) address that could be supported on a modified version of the Hawk without major changes to the way the MMU interface operates? (0.5 points).