Translate the following code into MIPS code.
Test (int i, int j)
{
int k;
k = Double(i+1) + Double (j-10)
return k;
}
Sub (int m)
{
int g;
g = m + m;
return g;
}
Assume the compiler associates the variable k to the register $s0. Assume the compiler associates the variable g to the register $t0.
MIPS Code:
.file 1 "" .section .mdebug.abi32 .previous .nan legacy .module fp=32 .module nooddspreg .abicalls .text .align 2 .globl Test .set nomips16 .set nomicromips .ent Test .type Test, @function Test: .frame $fp,24,$31 # vars= 8, regs= 1/0, args= 0, gp= 8 .mask 0x40000000,-4 .fmask 0x00000000,0 .set noreorder .set nomacro addiu $sp,$sp,-24 sw $fp,20($sp) move $fp,$sp sw $4,24($fp) sw $5,28($fp) movz $31,$31,$0 lw $2,24($fp) nop addiu $2,$2,1 mtc1 $2,$f0 nop cvt.d.w $f2,$f0 lw $2,28($fp) nop addiu $2,$2,-10 mtc1 $2,$f0 nop cvt.d.w $f0,$f0 add.d $f0,$f2,$f0 .set macro trunc.w.d $f0,$f0,$2 .set nomacro mfc1 $2,$f0 nop sw $2,8($fp) lw $2,8($fp) move $sp,$fp lw $fp,20($sp) addiu $sp,$sp,24 j $31 nop .set macro .set reorder .end Test .size Test, .-Test .align 2 .globl Sub .set nomips16 .set nomicromips .ent Sub .type Sub, @function Sub: .frame $fp,24,$31 # vars= 8, regs= 1/0, args= 0, gp= 8 .mask 0x40000000,-4 .fmask 0x00000000,0 .set noreorder .set nomacro addiu $sp,$sp,-24 sw $fp,20($sp) move $fp,$sp sw $4,24($fp) lw $3,24($fp) movz $31,$31,$0 lw $2,24($fp) nop addu $2,$3,$2 sw $2,8($fp) lw $2,8($fp) move $sp,$fp lw $fp,20($sp) addiu $sp,$sp,24 j $31 nop .set macro .set reorder .end Sub .size Sub, .-Sub .ident "GCC: (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609"
if you like the answer please provide a thumbs up.
Translate the following code into MIPS code. Test (int i, int j) {  
Translate the following code into MIPS code. j=0; k=0; for (i = 1 ; i < 50 ; i = i + 2) { K=k+1; j = (i + j); B[k] = j; } Assume the compiler associates the variables i, j, and k to the registers $t0, $t1, and $t2 respectively. Also, assume B is an array of integers and its address is stored at register $s1. PLEASE DO NOT COPY DOWN ANOTHER SOLUTION
Translate the following C code to MIPS assembly code. Assume that the value of i is in register $t0, and $s0 holds the base address of the integer MemArray if (i > 10) MemArray[i] = 0; else MemArray[i] = -MemArray[i];
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;
C to MIPS Conversion C variable h i j k x int a[] or &a[0] MIPS register replacement $s0 $s1 $s2 $s3 $s4 $a0 Translate to MIPS. DO NOT USE pseudo MIPS instructions (e.g., BGE). Answer MUST use true 32-bit MIPS instructions: if(j < k ) a[j] = 1; else j = a[j];
For C to MIPS Conversion C variable h i j k x int a[] or &a[0] MIPS register replacement $s0 $s1 $s2 $s3 $s4 $a0 Translate to MIPS. No credit for pseudo-MIPS instructions (e.g., BGE). The answer MUST use true 32-bit MIPS instructions: if(j < k ) a[j] = 1; else j = a[j];
C to MIPS Conversion C variable h i j k x int a[] or &a[0] MIPS register replacement $s0 $s1 $s2 $s3 $s4 $a0 Translate to MIPS. DO NOT USE pseudo MIPS instructions (e.g., BGE). Answer MUST use true 32-bit MIPS instructions: Note that all variables (h,i,j,x,a[]) are 32-bit signed integers. while ( h < 3 ) { a[j++]= 0; x = i >> 3; }
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;
Translate the following C code to MIPS assembly code. Use a minimum number of instructions. Register allocations - i $s0 - j $s1 - base of A[] $s2 - base of B[] $s3 2) A[3] = B[i] + B[j]; 3) i = 0; while (j != A[i]) { i++; }
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 MIPS: Consider the following fragment of C code: for i=0: i < = 100: i = i + 1) {a[i] = b[i] + c;} Assume that a and bare arrays of words and the base address of a is in $a0 and the base address of b is in $a1. Register $t0 is associated with variable i and register $s0 with c. Write the code for MIPS. How many instructions are executed during the running of this code? How...