1. (.5 point) For the following C statement what is the corresponding MIPS assem
ID: 3890893 • Letter: 1
Question
1. (.5 point) For the following C statement what is the corresponding MIPS assembly code? Use a minimal number of MIPS assembly instructions. Assume that f, g and h are in $s0, $s1 and Ss2, respectively. f- (g + h) + 5; 2. (1.5 points) Consider the following MIPS assembly instructions. Assume that the variables f, g, h and i are assigned to registers $s0, $s6, $s1, $s5 and the base address of a word array A is at $s3. For each of the instructions write down the type of the instruction format and the corresponding C statement? (a) (b) (c) add $s0, $s6, $s0 sub $s1, $s6, $s5 sw $s1,1200($s3) 3. (1 points) For the following C statement what is the corresponding MIPS assembly code? Assume that the variables i and j are assigned to registers $s4 and Ss5 and that the base addresses of word arrays A and B are $s0 and $s1 B[8] = (i-j) + A[20]; 4. (1 points) Assume that registers $s0 and $s1 hold the values 0x90000000 and 0xE0000000. (a) What is the value of $t0 in hexadecimal for the following assembly code? add $t0, $s0, $s1 (b) Is the result in $t0 the desired result or has there been an over ow? 5. (1 points) Translate the following MIPS assembly instruction into machine code. Write down both the binary as well as the hexadecimal representation of the translated machine language. Refer to the MIPS reference card and lecture slides for mapping of registers to numbers. sub $t0, $s4, $s5Explanation / Answer
1)
add $s1,$s2 ;both are added and result stored in $s1(g+h)
add $s0,$s1,5 ;both $s1 and 5 are added and result stored in $s0 (g+h)+5
2)
a)R-type format
register addressing
f=g+f;
b)R-type format
register addressing
h=g-i
c)I-type format
base addressing
h = A[1200]
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.