Question

In: Computer Science

What is the value stored in variable perimeter after the code has been executed? (6 pts)...

What is the value stored in variable perimeter after the code has been executed? (6 pts)

.data

              length:        .word 16

              width:        .word 24

              perimeter:     .word 0

       .text

              la $s0, length

              la $s1, width

              la $s2, perimeter

              lw $s3,0($s0)

              lw $s4, 0($s1)

              add $s3, $s3, $s3

              add $s4, $s3, $s4

              add $s5, $s3, $s4

              sw $s5, 0($s2)

Perimeter:__________________________________________

Solutions

Expert Solution

la $s0, length //address of length stored in $s0

              la $s1, width //address of width stored in $s1

              la $s2, perimeter //address of perimeter stored in $s2

              lw $s3,0($s0) //value of length stored in $s3 [ 16 ]

              lw $s4, 0($s1) //value of width stored in $s4 [ 24 ]

              add $s3, $s3, $s3 //add the value in $s3 & $s3 & store it in $s3 [ $s3=16+16 =32 ]

              add $s4, $s3, $s4 //add the value in $s3 & $s4 & store it in $s4 [ $s4= 32+24 =56 ]

              add $s5, $s3, $s4 //add the value in $s3 & $s4 & store it in $s5 [ $s5= 32+56 =88 ]

              sw $s5, 0($s2) //Store the value in address of $s5 to $s2

=> Perimeter = 88

******************************************************************************************
PLEASE LIKE IT RAISE YOUR THUMBS UP
IF YOU ARE HAVING ANY DOUBT FEEL FREE TO ASK IN COMMENT SECTION
******************************************************************************************


Related Solutions

1. What will be the value of numbers[1] after the following code is executed? int[] numbers...
1. What will be the value of numbers[1] after the following code is executed? int[] numbers = {22, 33, 44}; for(int k = 0; k < 3; k++) { numbers[k] = numbers[k] + 5; } } 2. What will be the results of the following code? final int ARRAY_SIZE = 5; double[] x = new double[ARRAY_SIZE]; for(int i = 1; i <= ARRAY_SIZE; i++) { x[i] = 10.0; } 3.What is the value of numbers [3] after the following line...
What is the Opcode? What is the Operand? What is the value in Register 5 after the instruction is executed?
What is the Opcode? What is the Operand? What is the value in Register 5 after the instruction is executed?
1) What's the contents of array vals after the following code is executed? int[] vals =...
1) What's the contents of array vals after the following code is executed? int[] vals = {6, 1, 4, 5, 1}; int size = vals.length; for(int i = 0; i < size; i++) vals[i] = vals[i] * i; q) [ 6, 1, 4, 5, 1 ] b)[ 0, 1, 2, 3, 4] c)[0, 1, 8, 15, 4] d)[6, 2, 12, 20, 5] 2) Consider function foo defined below: static int[] foo(int vals[]) { int result[] = new int[vals.length - 1];...
assume that the data are stored in variable names x and y. write a matlab code...
assume that the data are stored in variable names x and y. write a matlab code to plot the quadratic spline and along with the data points x= 1 2 3 4 5 6 y= 40 78 125 256 348 425
After the PICmicro code has been written, compiled, assembled and linked, what tools in the MPLAB...
After the PICmicro code has been written, compiled, assembled and linked, what tools in the MPLAB IDE is most useful in determining the correctness and completion of your code?
Perimeter Road has 4 streetlights. A streetlight burns out after an average of 100 days of...
Perimeter Road has 4 streetlights. A streetlight burns out after an average of 100 days of use (exponentially distributed). It takes an average of 10 days to replace a burned-out street lamp (exponentially distributed). Model the number of functioning streetlights as a birth-and-death process. (a) What is the long-run proportion of time that all streetlights are burned out? (b) On average how many streetlights are illuminating the Perimeter Road?
What is the value of n after this code runs? 1 Point int n = 0;...
What is the value of n after this code runs? 1 Point int n = 0; int j = 7; if ((j!=0) && (n < 25)) { n = 1; if (j > 4) { n = 2; } else { n = 3; } } else { n = 4; if (j%2 >= 2) { n = 5; } else { n = 6; } }
Explain What is being executed in this code. State all changes in values when traversing loops....
Explain What is being executed in this code. State all changes in values when traversing loops. #include <stdio.h> #define NUM_PRODUCTS 2 #define NUM_CATEGORIES 2 #define NUM_DIGITS 2 struct ProductInfo { int prodID; int numberInStock; double unitPrice; }; int main(void) { struct ProductInfo productList[NUM_PRODUCTS] = { {78, 8, 19.95}, {95, 14, 22.98} }; int categoryCount[NUM_CATEGORIES] = { 0 }; int i, j, sum, id, divisors[] = { 10, 1 }; for (i = 0; i < NUM_PRODUCTS; i++) { sum =...
What are stored-value cards and how they are used in electronic commerce
What are stored-value cards and how they are used in electronic commerce
a) Given a variable word that has been assigned a string value,write a string expression...
a) Given a variable word that has been assigned a string value, write a string expression that parenthesizes the value of word. So, if word contains "sadly", the value of the expression would be the string "(sadly)"b) Assume that price is an integer variable whose value is the price (in US currency) in cents of an item. Write a statement that prints the value of price in the form "X dollars and Y cents" on a line by itself. So,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT