1. Facts, Figures and Bit [12 points]a. Describe the set of numbers that are represented by a 64-bit two's complement integer.b. Add the following 16-bit integers by hand, show binary result and translate it to hexadecimal. +0011101001101100 c. Multiply the following 16-bit unsigned integers by hand, show binary result and translate to hexadecimal +0000000000001010 d. Encode the value 17.2510 according to the single precision
IEEE Floating-Point standard and show its representation in hexadecimal.
|
||||||||||||||||||
2. Logical Operations [5]Write a sequence of no more than six MIPS instruction that extracts bits 17:11 of register $s0 and inserts them into bits 8:2 of register $s1, leaving all the remaining bits of $s1 unchanged. You may use t-registers as temporaries. |
||||||||||||||||||
3. Assembler/Instruction Format [5]Using the opcode and register map tables on page A-54 , assemble the following MIPS instructions into binary. Show the position of each field by drawing a box around the corresponding bit positions.
|
||||||||||||||||||
4. Correct Assembly Language [8]Consider the folloiwng MIPS assemble language routine. (The numbers oin the left are just line numbers to help in your answer.) foo takes two integer arguments. The caller of foo and its callee bar follow the MIPS procedure call conventions. Assume VAR1 has been declared in the .data section with the .word directive.1 foo: addi $sp, $sp, -20
a. List below four bugs that are present in the code
|
||||||||||||||||||
5. Pointers, Arrays, and strings [5 points]Given the following (correct) C declarations.char foo = 'A', garply[] = "MIPS",
bar = 'C';
In the following, some of the statements are incorrect or illegal; cross out any such bad statements. Show in the spaces provided what the remaining print statements will print when the program is executed. printf("%c", *beta);
|
||||||||||||||||||
6. Compile the following C code into MIPS [10 points]struct Node {int data; struct Node *next; }; int SumList (struct Node *nptr) {
The idea here is that Nodes form a singly linked list, much like what you dealt with in cs61a. The Node structure is represented as two consecutive words, one for each field. The data field contains an integer data value and the next field contains a pointer to another. The -> notation is used to reference fields of the structure pointed to by a pointer variable. nptr->data is the same as (*nptr).data - it accesses the data field of the structure pointed to by nptr. Your code must contain meaningful comments and adhere to the MIPS calling convention and register usage convention. You are allowed to use pseudoinstructions to make it more readable. It should be clean and well structured. It needs to be right, not optimal, but your answer cannot be longer than 20 instructions. |
||||||||||||||||||