Assignment 9, due July 20

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 following very small SMAL Hawk program loops for a while and then halts:
                    USE     "hawk.macs"
                    USE     "monitor.h"
                    S       .
                    LIL     R3,#7FFFFF      ; R3 = a big number
            LOOP:                           ; do {
                    ADDSI   R3,-1           ;   R3 = R3 - 1
                    BR      CONTINUE
            ; -----------------------
            CONTINUE:
                    BNR     LOOP            ; while (R3 >= 0)
                    LOAD    R1,PEXIT
                    JSRS    R1,R1           ; exit
                    END
    

    Problem: Split this program into two separately assembled source files that can be linked; divide it at the point marked by the dashed line. The logic must not change, but you may need to change some branch instructions to jump instructions in order to get between the separate bits of your code. Turn in assembly listings of the two source files. (1 point)

  2. Background: Your operating system includes a window manager. Ignore all window operations except w.at(x,y) and w.put(ch) (where w is a window object, x and y are integers, and ch is a character). Window objects are polymorphic (there are several kinds of windows).

    a) Design the header file window.h that gives the interface to all window objects. (1/2 point)

    b) Given that R3 contains a pointer to a window object, and given that R4 contains a character, write code to call the put method of that window, passing that character, assuming the definitions and comments given in your header file. (1/2 point)

  3. Here is a logic circuit for a weird way to make one of the flipflops given in Chapter 11 of the notes:
    a circuit with feedback

    a) What kind of flipflop is this? (1/2 points)

    b) Mark the inputs and outputs that correspond most closely to R, S, R, S, D, C, Q or Q connections to this flipflop. Of course, it can't be both an RS and a D flipflop, so you should not use any irrelevant labels from this list. (1/2 point).

NOTICE: The submission instructions instructions given in the assignment for MP4 are wrong! in a file called mp4.a, to the submission directory called mp4.

 

Machine Problem 5, Due July 27

a) Divide your solution to Machine Problem 4 so that the pseudo-random number generator is a separately assembled component from the main program with the game logic in it. Your solution should reside in a directory with the name mp5. Inside this directory, there should be 3 source files, main.a, random.a, and random.h.

b) Add logic to the program so that it terminates and displays this message (approximately centered on the screen) if your asterisk bumps up against the edge of the screen.

        +---------+
        | YOU WIN |
        +---------+

In implementing this, consider that the same code could print either the winning or the losing message, and that this code could therefore be in a subroutine, and that this subroutine could be separately compiled from the main program (adding yet another assembly source file to your directory, plus its interface).

Note: This game is not really very challenging unless the population of hash marks on the screen is higher or unless there is an "intelligent" nemisis. Those improvements are left to your imagination.

Submitting your result: Use the submit command on the department linux cluster. Submit your source directory (mp5) for the course c060 and the submission directory mp5. (Yes, it is legal to submit an entire directory! Your directory may contain .o files as well, but these will be ignored in grading.

Grading: The usual warnings apply. Failure to include appropriate TITLE directories in each file that ought to have a title will be penalized. For files that should not have titles, there should be appropriate header comments. As much as half of the total credit will be granted for "beautiful code".