1) Perform the following operation using MIPS assembly:
a) Perform C= A+B-D where A=0x4 & B=0x4 & D = 0x10 (choose the registers
b)
if (I == J)
I ++;
else
J--;
c)
if (a > 0)
b = a + 10;
else
b = a - 10;
A,
copy to code:
.text
#set 4 to t0
addi $t0, $zero , 0x4
#set 4 to t1
addi $t1, $zero , 0x4
#set 10 to t2 10 equivalent to 16 in decimal
addi $t2, $zero , 0x10
#add t0 and t1
add $t3, $t0,$t1
#sub t3 by t2
sub $t3,$t3,$t2
#print message
li $v0,1
move $a0,$t3
syscall
code snippet:
output:
b
copy to code;
.data
newline: .asciiz "\n"
ais : .asciiz "a = "
bis : .asciiz "b = "
.text
addi $t1,$zero,9 #t1 store value of a set to -3
addi $t2,$zero,9 #t1 store value of a set to -3
seq $t3,$t1,$t2 #set is equal to t3
beqz $t3,Else #check if equal zero go to zero
addi $t1,$t1,1 #if part
j endIf #jump to end if
Else :
subi $t2,$t2,1 #else part
endIf:
#print message
li $v0,4
la $a0,ais #it will print a =
syscall
li $v0,1
move $a0,$t1 #print a value
syscall
li $v0,4
la $a0,newline #it will print b =
syscall
li $v0,4
la $a0,bis #it will print new line
syscall
li $v0,1
move $a0,$t2 #it will print b value
syscall
code snippet;
output:
c
copy to code:
.text
addi $t1,$zero,-3 #t1 store value of a set to -3
sgt $t3,$t1,0 #set greater than zero to t3
beqz $t3,Else #check if equal zero go to zero
addi $t2,$t1,10 #if part
j endIf #jump to end if
Else :
subi $t2,$t1,10 #else part
endIf:
#print message
li $v0,1
move $a0,$t2
syscall
code snippet.
output:
1) Perform the following operation using MIPS assembly: a) Perform C= A+B-D where A=0x4 & B=0x4...
Translate the following C code to MIPS assembly. Assume that the values of a, b, i, and j are in registers $s0, $s1, $t0, and $t1, respectively. Also assume that $s2 holds the base address of the array D. for (i = 0: i < a: i++) for (j = 0: j < b: j++) D[2 * j] = i + j;
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;
IN MIPS AND MUST RUN IN QTSPIM
Translate the following C code to MIPS assembly code. Use a minimum number of instructions. Assume that the values of a, b, i and j are stored in registers Ss0, Ss1, St0 and Stl, respectively. Also assume that register Ss2 holds the base address of the array D. for (i=0; i<a; itt) for (i-0j<b:jt+)
Using beq only, not bge! Translate the following C code to MIPS assembly code. Use a minimum number of instructions. Assume that the values of a, b, i, and j are in registers $s0, $s1, $t0, and $t1, respectively. Also, assume that register $s2 holds the base address of the integer array D. Comments are required. for(i=1; i<a; i++) for(j=1; j<b; j++) D[2*j] = i + j;
7. Translate the following C code to MIPS assembly code. Use a minimum number of instructions. Assume that the values of a,b, i and j are in registers Ss0, Ss1, St0, and St1, respectively. Also, assume that register SS2 holds the base address of the array D. for(i-0; i<a; i++) for(j=0 ; j<b; j++)
For the following C statement, what is the corresponding MIPS assembly code? Assume that the variables i, and j are assigned to registers $s0, $s1, respectively. Assume that the base address of the arrays A and B are in registers $s2 and $s3, respectively. B[i] = A[i] - 10
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; }
Convert the following C/C++ fragment into equivalent MIPS assembly language. Assume that the variables a, b, c, d, i and x are assigned to registers $t1, $t2, $t3, $t4, $s0 and $s1 respectively. if ((a<b && (c == 0) d = 1;
Please answer the following questions involving MIPS assembly code: A) For the C statement below, what is the corresponding MIPS assembly code? Assume f, g are stored in S1 and S2. f = g + (-f -5) B) For the C statement below, what is the corresponding MIPS assembly code? Assume i and j are assigned in registers S1 and S2 respectively and base of address of arrays A and B are in registers S6 and S7. B[8] = A[i...
For the following C statement, what is the corresponding MIPS assembly code? Assume that the variables i andj are assigned to registers $50 and $s1, respectively and the base address of the arrays A and B are in registers $s6 and $57, respectively. B[i] = A[B[j]+12];