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.8125 1101.0101 _____._____ | | _____._____ 9.5625 0111.1001 _____._____ |
_ _ _ _ _ _ _ _ |_|_|_|_|_|_|_|_| |s| exp | man |
Answer the following questions for this number system, giving answers in conventional decimal form: (2.4 points)
; A is in R3, an 8 digit fixed point unsigned BCD number; ; A has 2 digits of fraction and 8 digits of integer part! ; B is pointed to by R8; B is a BCD integer. ; assume that BCDTOI and ITOBCD converts between 8 digit BCD ; numbers and binary integers in R3, and that they know nothing ; about fixed point numbers! CALL BCDTOI ; convert R3 to binary ____________________________ ____________________________ ____________________________ CALL ITOBCD ; convert R3 back to decimal ; R3 now contains 10*A ____________________________ ____________________________ ____________________________ ; R3 now contains 10*A rounded to the nearest integer ____________________________ ____________________________ ____________________________ ; B now contains 10*A, in the format required for B
; A is a common holding a global array of integers; ; AP is the label on a word pointing to A[0]. ; ; I is a common holding an integer; ; IP is the label on a word pointing to I. ; ; I is known to be within bounds for indexing into A. ; ; B is the displacement from R2 of a local array of ; integers. B points to location 0 of that array. ; ; J is the displacement from R2 of a local integer. ; ; J is known to be within bounds for indexing into B. ____________________________ ____________________________ ____________________________ ____________________________ ____________________________ ____________________________ ; R3 holds the value of A[I] ____________________________ ____________________________ ____________________________ ____________________________ ____________________________ ; B[J] holds the value of A[I]
; -------------------- ; R2 points to AR with following format ;RA= 0 ; return address TIMEX= 4 ; extra value to add AR= 8 ; size of activation record TIMES: ; horrible function to multiply two words ; algorithm: A x B = if B zero 0 ; = if B even B/2 x (2 x A) ; = if B odd (B/2 x (2 x A)) + A ; expects argument in R3, R4. ; returns result in R3. ; wipes out R5 TEST R4 BZS TIMQT ; quit if B is zero _________________ ; save return address MOVE R5,R3 ; \ MOVE R3,R4 ; > swap A and B MOVE R4,R5 ; / (R5 ends up a copy of A) SRU R4 ; get B/2, set C if B odd BCS TIMODD LIS R5,0 ; if B even, R5=0 else R5=A TIMODD: _________________ ; set aside R5 as extra value SL R3,1 ; get 2xA _________________ ; \ _________________ ; > recursive call _________________ ; / _________________ ; Recover extra value in R4 ADD R3,R3,R4 ; add it to return value _________________ ; recover return address TIMQT: JUMPS R1