Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question # 01: The following problems deal with translating from C to MIPS. Assume that the variables f, g, h, i, and j are assigned

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Question # 01: The following problems deal with translating from C to MIPS. Assume that the variables f, g, h, i, and j are assigned to registers $50, $s1, $s2, $s3, and$s4, respectively. Assume that the base address of the arrays A and B are in registers $s6 and $87, respectively. 1. f=-g - A[4]; 2. B[8] = A[i,j]; a) For the C statements above, what is the corresponding MIPS assembly code? b) For the C statements above, how many MIPS assembly instructions are needed to perform the C statement? c) For the C statements above, how many different registers are needed to carry out the C statement? The following problems deal with translating from MIPS to C. Assume that the variables f, g, h, i, and j are assigned to registers $s0, $s1, $s2, $s3, and $54, respectively. Assume that the base address of the arrays A and B are in registers $s6 and $s7, respectively. a. sll $s2, $s4, 1 add $50, $s2, $s3 add $50, $s0, $s1 b. sll $t0,$so, 2 add $t0,$s6, $t0 sll $t1,$s1, 2 add $t1,$s7, $t1 lw $50, 0($t0) addi $t2, $t0, 4 lw $t0, 0($t2) add $t0,$t0, $50 sw $t0, 0($t1) # $t0 = f*4 # $t0 = &A[f] # $t1 = g *4 # $t1 = &B[g] #f= A[f] a) For the MIPS assembly instructions above, what is the corresponding C statement? b) For the MIPS assembly instructions above, rewrite the assembly code to minimize the number if MIPS instructions (if possible) needed to carry out the same function. c) How many registers are needed to carryout the MIPS assembly as written above? If you could rewrite the code above, what is the minimal number of registers needed? Question # 03: In the following problems, we will be investigating memory operations in the con- text of an MIPS processor. The table below shows the values of an array stored in memory. Assume the base address of the array is stored in register $6 and offset it with respect to the base address of the array. I) Address Data 20 4 24 5 28 3 32 2 34 1 II) Address Data 24 2 38 4 32 3 36 6 40 1 a) For the memory locations in the table above, write C code to sort the data from lowest to highest, placing the lowest value in the smallest memory location shown in the figure. Assume that the data shown represents the C variable called Array, which is an array of type int, and that the first number in the array shown is the first element in the array. Assume that this particular machine is a byte- addressablejmachine and a word consists of four bytes. b) For the memory locations in the table above, write MIPS code to sort the data from lowest to highest, placing the lowest value in the smallest memory location. Use a minimum number of MIPS instructions. Assume the base address of Array is stored in register $s. c) To sort the array above, how many instructions are required for the MIPS code? If you are not allowed to use the immediate field in lw and sw instructions, how many MIPS instructions do you need? Question 4: In the following problems, the data table contains bits that represent the opcode of an instruction. You will be asked to interpret the bits as MIPS instructions into assembly code and determine what format of MIPS instruction the bits represent. 1. 0000 0011 0000 1010 1000 0000 0010 0001two 2. 0000 0001 0100 1011 0100 1000 0010 0011two For the binary entries above, what instruction do they represent

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Oracle8I Building Efficient Databases

Authors: Jonathan Lewis

1st Edition

0201715848, 978-0201715842

More Books

Students also viewed these Databases questions

Question

=+5. How might managers address any abuse of sick leave?

Answered: 1 week ago