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?
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; } }
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,...
Python 1.)Assume that name is a variable of type String that has been assigned a value....
Python 1.)Assume that name is a variable of type String that has been assigned a value. Write an expression whose value is the last character of the value of name. So if the value of name were "Blair" the expression's value would be 'r'. 2.)Assume that word is a variable of type String that has been assigned a value. Write an expression whose value is a String consisting of the last three characters of the value of word. So if...
1. Assume that total has already been declared as a double variable and received a value,...
1. Assume that total has already been declared as a double variable and received a value, and discountRate has been declared as a double variable, you don’t need to declare them again. You write one if statement (not multiple individual if statements) for following requirements. when total is less than 50, set discountRate to 0.0; when total is equal to or greater than 50 and less than 100, set discountRate to 0.05; when total is equal to or greater than...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT