Assignment 10, due Nov 7

Part of the homework for CS:2630 (22C:60), Fall 2014
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

On every assignment, write your name legibly as it appears on your University ID card! Homework is due on paper Homework is due on paper at the start of class on the day indicated (usually Friday). 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: The macros from sparrowhawk.h that are given in mp5.h have the following problem: In some contexts, CMPI under hawk.h will produce different value in the condition codes from CMPI under sparrowhawk.h. Ultimately, this is because the Sparrowhawk macro for CMPI r,c produces the following instruction sequence:
            LIS     R1,(-c) >> 8
            ORIS    R1,(-c) & #FF
            PLUS    R1,r
    	TESTR   R1
    

    a) Which condition codes are set differently by TESTR and CMPI? (0.2 points).

    b) Which of the following conditional branch instructions might behave differently after a CMPI for programs assembled with sparrowhawk.h instead of hawk.h?
    BGTU BGT BGE BCR BVR BZR BNR
    (0.4 points; -0.1 point per error).

    c) What sequence of instructions should CMPI have assembled to on the Sparrowhawk in order to avoid this incompatability? (0.4 points).

  2. Background: Suppose the Hawk monitor supported a windowing model on the display. Instead of calling putchar(ch) to put a character into video RAM, instead you would work with windown w -- where w could be the entire video RAM, or it could be a sub-window of the display area. This would require a much more sophisticated monitor, but that is not the question here. Rather, let's just assume that the monitor.h includes the following:
    ; class window
    ; all window objects begin with a pointer to the class descriptor
    ;DESCR  =       0
                    ; windows contain many private fields
    WINSIZE =       28
    
    ; all window implementations include a descriptor as follows,
    ; each descriptor entry points to one method, called as follows
    ; uses R3 - pointer to window w.
    ;      R4 - first parameter if any, additional parameters go in R5 etc.
    WINCLEAR=	0	; w.winclear() clears window w
    WINAT	=	0	; w.winat(x,y) sets location for the next put
    WINCHAR =	0	; w.winchar(c) puts character c in the window
    

    A problem: Given the local variables W, the address of a window object, and CH, the character to output (both currently stored in the current activation record), write SMAL Hawk code to call W.winchar(CH) (0.5 points)

  3. Background: Assume that the variables A, B, C, X and Y are all single-precision 32-bit floating point variables defined in the current activation record, and assume that the Hawk floating point coprocessor is already turned on and selected.

    A problem: Write Hawk code to compute Y=AX2+BX+C. (0.7 points)

  4. Problems: Give the 32-bit IEEE floating point representation for each of the following, expressing your answers as 32-bit hex values: (0.2 points each)

    a) 0.510

    b) 510

    c) 5010

    d) 50010