C language to MIPS assembly code pleaseee
int hw_func (int num_hws, int avg_hours) {
int total_hw_time;
total_hw_time = num_hws x avg_hours;
return total_hw_time;
}
int exercise_func (int num_exercises, int avg_hours) {
int total_exercise_time;
total_exercise_time = num_exercises x avg_hours;
return total_exercise_time;
}
int total (int nhws, int hours, int nexercises, int ehours) {
int total;
total = hw_func (nhws, hours) + exercise_func (nexercises, ehours);
return total;
}
void main( ) {
int num_homeworks = 4;
int average_hws_hours = 1;
int num_exercises_per day = 2;
int average_exercise_hours = 2;
int total_time = total(num_homeworks, average_hws_hours,
num_exercises_perday, average_exercises_hours);
printf(“%d\n”, total_time);
}
We need at least 9 more requests to produce the answer.
1 / 10 have requested this problem solution
The more requests, the faster the answer.
Can anyone help to solve this MIPS assembly language problem? Please help. Translate the fowlowwing C code to MIPS assembly language. void main() { int i, sum, begin, end; for(i=0; i < 5; i++){ scanf(“%d, %d”, &begin, &end); sum = accum_range(begin, end); printf(“sum[%d: %d] = %d\n”, begin, end, sum); } int accum_range(int a, int b){ return accum (b) - accum(a); } int accum(int final) { int sum = 0; for (int I = 1; I <= final; I = I...
MIPS assembly language Implement the following code in MIPS int array [ ] {2, 3, 4, 5, 6); int main) int num, position; scanf("%d",&num) ; position search(array, printf("The position is: num, 5); %d\n",positio int search(int array, int num, int size int position =-1; for(int i-0;i<size; i++) if(array [i]=num) { position-i; break; return position; Register map $s1: position $a0: array address $a1: num . $a2: size . $VO: return value
How can I convert the following C code to MIPS Assembly? +++++++++++++++++++++++++++++++++ MIPS main program ++++++++++++++++++++++++++++++++ .data # Defines variable section of an assembly routine. array: .word x, x, x, x, x, x, x, x, x, x # Define a variable named array as a word (integer) array # with 10 unsorted integer numbers of your own. # After your program has run, the integers in this array # should be sorted. .text # Defines the start of the code...
MIPS assembly language Covert this code to MIPS: #include <stdio.h> int function (int a) int main)i int x=5 ; int y: y function(x); printf "yd",y); return 0; int function (int a) return 3*a+5; Assumptions: . Place arguments in $a0-$a3 . Place return values in $vO-$v1 Return address saved automatically in $ra . lgnore the stack for this example. (Thus, the function will destroy registers used by calling function
Convert the below C code to basic MIPS. The result of this code should be a^b of the two numbers that you input. For example if you input the numbers 3 and 5 you should get a result of 3^5=6 #include int main(void) { printf("Insert two numbers\n"); int a,b,c; scanf("%d",&a); scanf("%d",&b); c=a^b; printf("%d^%d=%d\n",a,b,c); return 0; }
Convert the below C code to basic MIPS. Please leave comments for explanation #include <stdio.h> int main(void) { printf("Insert two numbers\n"); int a,b; scanf("%d",&a); scanf("%d",&b); a=a<<2; b=b<<2; printf("%d&%d\n",a,b); return 0; }
Convert the below C code to basic MIPS. Leave comments for explanation please #include <stdio.h> int main(void) { printf("Insert two numbers\n"); int a,b,c; scanf("%d",&a); scanf("%d",&b); c=a|b; printf("%d|%d=%d\n",a,b,c); return 0; }
Translate function f into MIPS assembly language. The code for function f is as follows: int func(int a, int b){ return a + b; } int f(int a, int b, int c, int d){ return func(func(a, b), c - d);
Translate the following C code into RISC-V Assembly. (no need to implement the prints just use ecall) int a[] = {2,2,5,3,4,8,3}; int b[] = {1,4,2,0,-1,5,4}; int z[7]; void multiply(int* a, int* b, int* c, int d) { for (int i=0; i < d; i++) { c[i] = a[i] * b[i]; } } int main() { int n = 7; multiply(a,b,z,n); printf("%s", "res: "); for (int i = 0; i < z; i++) { printf("%d", d[i]); } printf("\n"); return 0; }
Implement the functionality of "main" function for the following C code in MIPS assembly. Comment your code including which registers represent the variables in the main function. Include the .data and the .text sections. Do not write the bit_count function. int main() { int count = 149; int num = 432; if (count + num > 534){ count = bit_count(num); printf("%d bits to store the number", count); }else{ printf("cannot count bit in %d",) } }