1. For the MIPS assembly instructions below, what is the corresponding C statement?
max:
lw $t0, 0($a0) #load the first array value into $t0
addi $t1, $0, 1 #intialize the counter to one
loop:
beq $t1, $a1, exit #exit if we reach the end of the array
addi $a0, $a0, 4 #increment the pointer by one word
addi $t1, $t1, 1 #increment the loop counter
lw $t2, 0($a0) #store the next array value into $t2
slt $t3, $t0, $t2
beq $t3, $0, end_if
add $t0, $0, $t2 #found a new maximum,store it in t0
end_if:
j loop #repeat the loop
exit:


int a =arr[0];
int i=1;
for(i; i<sizeof(arr)/sizeof(arr[0]); i++)
{
int b=arr[i];
if(a<b) //compare next element
in the array
a=b;//our new
maximum value
}
1. For the MIPS assembly instructions below, what is the corresponding C statement? max: lw &
I have this MIPS program and I'm having trouble with it. This program is user inputs numbers until zero and sorts and print the numbers in order. Please soove this issue. You can use any sorting algorithm except bubble sort. Need it as soon as possible. Here is the code:.datanum: .word 0space: .byte ' ' .text main: # la $t0, val # loads val into a register # li $t1, 0 #keeps track of how many numbers entered la $a0,...
2.4 For the MIPS assembly instructions below, what is the corresponding C statement? Assume that the variables f, g, h, i, and j are assigned to registers $s0, $s1, $s2, $s3, and $s4, respectively. Assume that the base address of the arrays A and B are in registers $s6 and $s7, respectively. sll $t0, $s0, 2 # $t0 = f * 4 add $t0, $s6, $t0 # $t0 = &A[f] sll $t1, $s1, 2 # $t1 =...
Question 4) (12 Marks) This question is based on the MIPS assembly code shown below. data the Array: space 160 main: li $t6, 1 li $17, 4. sw $17, the Array($0) sw $17, theArray($17) li $t0, 8 loop: addi $t3, $t0, -8 addi $t4, $t0, -4 lw 1, the Array($t3) lw $12, the Array(St4) add $15, $t1, $t2 sw $15, theArray($to) addi $t0, $t0, 4 blt $t0, 160, loop jr Sra. Question 4 Assembly code a) what is the contents...
1. (15 pts) For the following C statement, what is the corresponding MIPS assembly code? Assume f, g, h correspond to $80, $s1, and $s2, respectively. f=g+(h-5) 2. (15 pts) For the following pseudo-MIPS assembly instructions, what is the corresponding C code? add f, g, h add f,i, f 3. (30 pts) Provide the instruction type, assembly language instruction, and binary representation of the instruction described by the following MIPS fields: a. op = 0, rs = 18, rt=9, rd...
Compiling C Programs into MIPS Assembly and Machine Code sll $t1, $a1, 2 add $t1, $a0. $t1 lw $t0, 0($t1) lw $t2, 4($t1) sw $t2, 0($t1) sw $t0, 4($t1) 1. From the assembly code, what machine code might a MIPS assembler produce? 2. What does this program do? Write the C code for this assembly program.
im trying to complete mips program code about a calculator program that can calculate integer addition / subtraction written using the MIPS assembler. im having hard times to debug this. The input is given to the array of Formula char (base address $ s0) in the form of a formula. The null character (\ 0, ASCII code 0) is placed at the end. The calculation result is given to the register $ s1 and the overflow is ignored. For example,...
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...
Please comment the MIPS code to help me understand.
Here is what the code accomplishes.
Here is the code, partially commented.
.data
Matrix: .word 41,45,5, 34,8,
15,16,23,44,48,12,32,18,47,22,8,22
.word 46,40,42,33,13,38,27,6, 29,25,18,40,47,22,26,14,3
.word 7, 48,35,9, 43,38,9, 49,28,25,42,5, 44,10,5, 38,14
.word 46,33,16,6, 13,20,31,1, 8, 17,1, 47,28,46,14,28,7
.word 32,2, 48,25,41,29,14,39,43,46,3, 39,32,49,41,28,46
.word 5, 43,2, 48,13,4, 33,41,32,19,9, 25,30,22,2, 9, 40
.word 14,47,22,18,47,3, 35,44,18,6, 33,22,11,6, 47,50,4
.word 28,34,20,30,18,27,38,5, 26,40,37,23,16,13,37,8,7
.word 48,38,39,12,10,39,23,20,21,20,33,16,24,21,25,3,46
.word 49,38,40,38,13,47,5, 13,4, 13,23,26,12,30,29,29, 3
.word 8, 20,10,13,31,7, 12,41,12,21,28,26,43,14,35,10,19
.word 49,33,25,26,24,29,46,22,7, 5, 15,41,10,31,19,41,27
.word 48,9,...
what is the output of the following assembly code ? .data A: .word 84 111 116 97 108 32 105 115 32 . text main:li $v0, 1l li $s0,0 la $s1, A li $t3, 0 loop: slti $t0, $s0, 17 beq: $t0, $zero, end sll $t1, $s0 2 add $t2 $s1 $t1 syscall addi $s0, $s0, 1 j loop end: li $v0, 1 add $a0, $zero, $t3 syscall
MIPS assembly language question
If $s0 has the base address of array A, and A has the following elements: 9, 6, 4, 24, 33, 0, 1; What is the value of $t1 after the instructions are executed? addi $t1, $zero, 20 add $t0, $t1, $S0 lw $t1, (Sto)