CS/COE 447: Spring 2010 Lab 5 YOUR NAME: YOUR PARTNER'S NAME: Each of you should hand in a hardcopy of your own solution. This lab will give you MIPS programming practice. 1. # Write MIPS code that clears bits 11 and 13 # (makes them 0) in $t0. The code should preserve # the contents of all other bits. # # Use lui and ori to place the mask into, say, register $t1. # Then use an "and" instruction. # # Example: suppose $t0 = 0xFF81EBFF # After, it should be FF81C3FF # Make sure you understand why! 2. # Write MIPS code that prints the value for # bits 15, 16, and 17 in $t0. The code should # print a single integer number that corresponds # to the 3 digit binary number in bits 15, 16, 17. # For example, if $t0 is 0x20000, the value printed is 4 # if $t0 is 0xFFFFFFFF, the value printed is 7 # The value of $t0 should not be changed. 3. # Write MIPS code that sets bits 7 and 9 (makes # them 1) in $t0. The code should preserve the # contents of all other bits. # For example, if $t0 is 0xFF00007F, the new value should be # 0xFF0002FF 4. # Write MIPS code that prints "It is negative" # when the value in register $t1 is less than 0, # prints "It is positive", when the value in register $t1 is # positive, and prints "It is 0", when the value is 0. This # question is to give you practice writing an if-then-else # statement, and also with carrying out the tests. 5. # Translate the following C code into MIPS. # Use the following to set up the variables: .data a: .word 3 b: .word 2 d: .word 4,2,6,4,5,6,7,2,3,4,5,6 while (a < 14){ D[a] = b + a; a += 1; }