main()
{
int a=10;
int b=10;
int D[a];
for(int i=0;i<a;i++)
{
for(int j=0;j<b;j++)
D[j]=i*2+j*2;
}
}
.file 1 ""
.section .mdebug.abi32
.previous
.nan legacy
.module fp=32
.module nooddspreg
.abicalls
.section .text.startup,"ax",@progbits
.align 2
.globl main
.set nomips16
.set nomicromips
.ent main
.type main, @function
main:
.frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, gp=
0
.mask 0x00000000,0
.fmask 0x00000000,0
.set noreorder
.set nomacro
j $31
move $2,$0
.set macro
.set reorder
.end main
.size main, .-main
.ident "GCC: (Ubuntu 5.4.0-6ubuntu1~16.04.1) 5.4.0 20160609"
IN MIPS AND MUST RUN IN QTSPIM Translate the following C code to MIPS assembly code....
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++)
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;
Assignment 3 Translate the following MIPS code to C. Assume that the variables f, g, h, i and j are assigned to registers Ss0, Ss1, Ss2, Ss3 and Ss4, respectively. Assume that the base address of the arrays A and B are in registers Ss6 and $s7, respectively. addi St0, Ss6, 4 add $t1, $s6, $0 #register $0 always holds 320s sw St1, 0(Sto) add Ss0, St1, Sto
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;
Problem 2 Points (40) The following problems deal with translating from C to MIPS. Assume that the variables g, h, j, and j are assigned to registers Ss0, Ss1, Ss2, Ss3, and Ss4, respectively. Assume that the base address of the arrays A and B are in registers Ss6 and Ss7 respectively 1. Provide the MIPS assembly code for the above C statements. Use a minimal number of MIPS assembly instructions 2. For the C statements above, how many MIPS...
C code to MIPS Translate the following C command into MIPS assembly. Assume that the base address of arrays A is stored in register $s1. 시 I-A[2] + 7;
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];
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++; }
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
Write an equivalent MIPS code for the following C code. Assume that the base address of an array A is stored in register 450. Variables x, i, j and h are stored in registers $t0,$t1, $t2 and $t3 respectively. do{ x = x + A[i]; i = i + j; } (while i != h); Make sure your MIPS code has sufficient comments.