Assignment 10, due July 25

Part of the homework for 22C:60, Summer 2005
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

Always, on every assignment, please write your name legibly as it appears on your University ID and on the class list! All assignments will be due at the start of class on the day indicated, and unless there is what insurance companies call "an act of God" - something outside your control; the only exceptions to this rule will be by advance arrangement.

  1. Background: Consider the game that has been the subject of the machine problem. One of the parts of this problem was to detect that the player had moved his asterisk out of bounds. An alternative way to do this is to introduce a "bounds check" subroutine, for example, called BNDCHK, that is called after incrementing the X and Y coordinates as part of a move. If this routine sees that the new values are in bounds, it does nothing. If this routine sees that the player has attempted to leave the board, it raises the BOUNDS exception.

    a) Ignoring problems of separate assembly, but using the tools discussed in chapter 12, write the code of the BOUNDS routine. (1 point)

    b) Now, assume that you want to write BOUNDS as part of a separately assembled source file. Present a design for the interface to this separate module. Among the things your design must answer are: How does the BOUNDS routine learn the dimensions of the screen? How does the handler get attached to the BNDCHK exception? And, of course, before you actually answer this question, you must determine what it means to present a design for an interface, as opposed to presenting the interface itself. (1/2 point)

  2. Background: The Hawk machine contains a number of unimplemented instructions. An attempt to execute one of these instructions will cause an illegal instruction trap. Search the Hawk machine's list of opcodes (one of which lists them in numerical order) and find these instructions.

    a) How many of these illegal instructions include space in them for two 4-bit arguments? (1/2 point)

    b) (1/2 point) Given an example, in hexadecimal, of a halfword assembly directive that will assemble to produce one of these illegal instructions, with the two 4-bit argument fields both set to zero.

    c) Give a macro called ILLEGAL that has two integer arguments, so that if you assemble it, it will create the illegal instruction you identified in part b and encode your two integers in the two available 4-bit argument fields of this instruction. (1/2 point)