Answer: MIPS code:
.file 1 "" .section .mdebug.abi32 .previous .nan legacy .module fp=32 .module nooddspreg .abicalls .text .align 2 .globl main .set nomips16 .set nomicromips .ent main .type main, @function main: .frame $fp,432,$31 # vars= 416, regs= 1/0, args= 0, gp= 8 .mask 0x40000000,-4 .fmask 0x00000000,0 .set noreorder .set nomacro addiu $sp,$sp,-432 sw $fp,428($sp) move $fp,$sp sw $0,8($fp) b $L2 movz $31,$31,$0 nop $L5: sw $0,12($fp) b $L3 nop $L4: lw $2,12($fp) nop sll $2,$2,2 lw $4,8($fp) lw $3,12($fp) nop addu $3,$4,$3 sll $2,$2,2 addiu $4,$fp,8 addu $2,$4,$2 sw $3,16($2) lw $2,12($fp) nop addiu $2,$2,1 sw $2,12($fp) $L3: lw $3,12($fp) lw $2,20($fp) nop slt $2,$3,$2 bne $2,$0,$L4 nop lw $2,8($fp) nop addiu $2,$2,1 sw $2,8($fp) $L2: lw $3,8($fp) lw $2,16($fp) nop slt $2,$3,$2 bne $2,$0,$L5 nop move $2,$0 move $sp,$fp lw $fp,428($sp) addiu $sp,$sp,432 j $31 nop .set macro .set reorder .end main .size main, .-main .ident "GCC: (Ubuntu 5.4.0-6ubuntu1~16.04.1) 5.4.0 20160609"
7. Translate the following C code to MIPS assembly code. Use a minimum number of instructions....
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+)
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;
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++; }
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...
2. The table below holds MIPS assembly code fragments with different branch instructions LOOP addi $s2. $s2. 2 subi $t1. st1. 1 bne t1. 0. LOOP DONE: LOOP: it st2. $0. stl beq t2. 0. DONE addi $s2. Ss2. 2 LOOP DONE: For the loops written in MIPS assembly in the above table, assume that the register Şt1 is initialized to the value of 10. What is the value in register $s2 assuming that $s2 initially has a value of...
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 each of the following pseudo-instructions into MIPS instructions. You should Produce a minimal sequence of MIPS instructions to accomplish the required computation. (8 Points) 1) bgt $t1, 100, Label # bgt means branch if greater than 2) ble $s2, 10, Next # ble means branch if less than or equal 3) ror $s0, $s4, 7 # ror means rotate right $s4 by 7 bits and store the result in $s0 4) neg $s5, $s4 # $s5 will have the...
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;