Name ______________________________________ Section ___________This exam is open-book and open-notes, but closed neighbor! You have one (academic style) hour, which is defined as 50 minutes. Answer the questions in the space provided. If you need scratch paper, feel free to use the backs of the exam pages, but please transcribe your answers into the blanks provided.
Base 2 Base 10 | Base 2 Base 10 | 1110.1011 14.6875 | | _____._____ 3.5625 1001.0110 _____._____ | | _____._____ 9.9375 0110.0001 _____._____ |
_ _ _ _ _ _ _ _ |_|_|_|_|_|_|_|_| |s|exp| man |Give the binary values and fixed point decimal equivalents for each of the following numbers (0.4 each, 1.6 total):
The largest positive number. _ _ _ _ _ _ _ _ ____________ The most negative number. _ _ _ _ _ _ _ _ ____________ The smallest nonzero positive number. _ _ _ _ _ _ _ _ ____________ The largest nonzero negative number. _ _ _ _ _ _ _ _ ____________
; A is in R3 ; B is in memory, pointed to by R8 ; C is in field of a record in memory, ; R9 points to the record, ; F is defined as the offset of that field. ; TIMES (pointed to by PTIMES) is in monitor.a LOADS R4,R8 ; get B LOAD R1,PTIMES ; (wipes out R4-7) JSRS R1,R1 ; R3 = A*B, unnormalized ____________________________ ____________________________ ____________________________ ____________________________ ____________________________ ____________________________ ____________________________ ____________________________ ____________________________ ____________________________ ____________________________ ____________________________ ____________________________ ____________________________ ____________________________ ; R3 contains D; D = A*B + 2*B + C
; -------------------- ; R2 points to AR with following format ; 0 ;return address TIMBSV= 4 ;_________________________________________ TIMAR= 8 ;_________________________________________ TIMES: ; horrible function to multiply two numbers ; expects numbers in ________________________ ; returns result in _________________________ ; wipes out _________________________________ TESTR R3 BZS TIMQT STORES R1,R2 STORE R4,R2,TIMBSV ADDI R4,R3,-1 LOAD R3,R2,TIMBSV ADDI R2,TIMAR JSR R1,TIMES ADDI R2,-TIMAR LOAD R4,R2,TIMBSV ADD R3,R3,R4 LOADS R1,R2 TIMQT: JUMPS R1
T1 = A + B + 0x96969696 T2 = T1 & 0x30303030 T3 = T1 - (T2 >> 3) SUM = (T3 & 0x0F0F0F0F) | 0x30303030(The above code is given in C, where the & operator means bit-by-bit Boolean and, the >>3 operator means right shift 3 bits, and a leading 0x on a constants means that the radix is hexadecimal.) Write a properly commented SMAL Hawk procedure called ASCIIADD that uses this algorithm and conforms to the header comments given. You do not need to understand how or why the algorithm works to solve this problem! (4 points)
;---------------------------- ASCIIADD: ; add 2 4-digit ASCII numbers. ; given A and B in R3 and R4 ; returns A+B in R3 ; may destroy R4-7 _____________________________________________________ _____________________________________________________ _____________________________________________________ _____________________________________________________ _____________________________________________________ _____________________________________________________ _____________________________________________________ _____________________________________________________ _____________________________________________________ _____________________________________________________ _____________________________________________________ _____________________________________________________ _____________________________________________________ _____________________________________________________ _____________________________________________________