Assume that k correspond to register $s0 and the base of the array v is in $s1. What is the MIPS assembly code corresponding to this C segment?
If ( V[K]< V[K+1]) {
temp = v[k];
v[k] = v[k+1];
v[k+1] = temp;
}
else {
v[k] = k; v[k+1]=k+1
}
please find the answer below::
mul $t0,$s0,4 #get address of k
add $t1,$t0,$s1 #get address of v[k]
add $t2,$t1,4 #get address of v[k+1]
lw $t3,($t1) #get value of v[k]
lw $t4,($t2) #get value of v[k+1]
blt $t3,$t4,ifPart
elsePart:
lw $s0,($t1) #v[k] = k
add $s0,$s0,1 #get k+1
lw $s0,($t2) #v[k+1] = k+1
j exit
ifPart:
lw $t0,($t1) #get temp = v[k]
lw $t1,($t2) #get v[k+1]
sw $t1,($t0) #v[k] = v[k+1]
lw $t0,($t1) #v[k+1] = temp
exit:
![Edit Execute cToMips1212.asmcToMips121.asm mul şt0 ,$80,4 #get address of k add $t1,$t0,$s1 #get address of v[k] add 3 $t2, $](http://img.homeworklib.com/questions/0478cd70-9e0c-11ea-a6a5-539013a0e4f2.png?x-oss-process=image/resize,w_560)
Assume that k correspond to register $s0 and the base of the array v is in...
B2. Translate the following MIPS assembly instruction into machine language: lw $t8, 100($s0) B3 Write MIPS assembly code segment for the following C code snippet: for (i - O i < 10i i++) i array[i+l] - array [i8; Register assignment: i-> Şa0 Base of array -> $s0
B2. Translate the following MIPS assembly instruction into machine language: lw $t8, 100($s0) B3 Write MIPS assembly code segment for the following C code snippet: for (i - O i Şa0 Base of...
B2. Convert the C code to MIPS assembly with only 2 efficient instructions: Register assignment: timer-v0 int timer = 0x0AC8 0001; B3. Write MIPS assembly code segment for the following C code snippet for (i - 0, i < 100; i++) -array Register assignment: i-) $ao Base of array -> $s0 array [ i+1] [i] / 2;
B2. Convert the C code to MIPS assembly with only 2 efficient instructions: Register assignment: timer-v0 int timer = 0x0AC8 0001; B3. Write...
Write the corresponding MIPS assembly equivalent of the given Ccode. Assume that register $s0 contains the base address for array arr. Use a register for each of the variables. (e.g. use $sl for total, etc.) and indicate them as a comment line in your code. int main() { inti, s = 10; int total, ps, ng int arr[10] = {3, -21, 18,0, 16, 85,-44, 23, 100, -20}; total = 0; ps = 0; ng = 0; for (i = 0;...
For the following C statement, what is the corresponding MIPS assembly code? Assume the arrays hold 16-bit integer values, $ s0 is the base for array X, $ s1 is the base for array Y, and $ t0 and $ t1 are index variables i and j respectively. Comment code X [j] = Y [i + j];
Convert the following c code into instructions MIPS Assembly language. Assume a associated with $s0, i with $s1, and j with $s2. if( i < 10) { if( j < 10) { a = 0; } else { a = 1;} } else { a = 2; }
8.6 Assume that register $s0 = 0x70000000 and $s1 0x10000000. For the following code, will there be overflow? Add $s0,$s0,$s1 Add $s0,$s0,$s1 8.7 Assume that register $s0 = 0x40000000 and $s1= 0x20000000. For the code above, will there be overflow?
Convert the following C fragment to equivalent MIPS assembly language. Assume that the variables a, b, c, d, i and x are assigened to registers $t1, $t2, $t3, $t4, $s0 and $s1 respectively. Assume that the base address of the array A and B is in register $a0 and $a1 respectively. if (a > 0) b = a + 10; else b = a - 10;
1. Convert the following C statement to MIPS code. Assume x, y and z are assigned to registers $s0, $s1 and $s2 respectively and the starting address of array A is $s6. x = y + z + A[3] 2. 2.Convert the following C statement to MIPS code. Assume the base address of array A is $s3 and h is assigned to register $s2 . A[7] = h + A[7]
Assembly Langauge.
Q6. (4 marks) : For the following C statement, what is the corresponding MIPS assembly code? Assume that the variables a, b, and c are assigned to register $s0, $s1, and $s2, respectively.
Compile the assembly code for the following C codes. Assume that i, j, and k have been stored in $s0, $s1, and $s2 respectively. The base address of the array B is stored in $s4. Please only use only TRUE MIPS instructions. for (i = k; i > 0; i = i - 2) j = i + 2k; for (i = 0; i < k; i++) for (j = 1; j < i; j++) B[2j] = B[i - k]-4