Question

Consider the following C statement:           a = (b + d) + (b – c) +...

Consider the following C statement:
          a = (b + d) + (b – c) + (c + d)

Which of the following assembly instructions can be used to replicate all or part of this statement in MIPS, without changing or reducing the equation. Assume variables a, b, c, and d are assigned to registers $s0, $s1, $s2 and $s3 respectively.

  1. sub $t0, $s2, $s3
  2. sub $t0, $s0, $s3
  3. sub $t1, $s1, $s2
  4. add $t2, $s1, $s3
  5. add $t2, $s0, $s3
  6. add $t0, $s2, $s3

Choose from the following options:

Group of answer choices

1, 2, 3

1, 3, 5

2, 5, 6

1, 2, 5

2, 3, 4

3, 4, 6

4, 5, 6

None of the above

Homework Answers

Answer #1

Given that  a = (b + d) + (b – c) + (c + d). Also  variables a, b, c, and d are assigned to registers $s0, $s1, $s2 and $s3 respectively.

According to the question, we aren't allowed to change or reduce the equation.

(b-c) can be calculated using add sub $t1, $s1, $s2 and (c+d) can be calculated using add $t0, $s2, $s3.

(b+d) can be calculated using add $t2, $s1, $s3.

Hence the correct answer choice is 3, 4, 6.

If you have any doubt regarding the solution then let me know in comment. If it helps, kindly give an upVote to this answer.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
For the MIPS assembly instructions below, what is the corresponding C statement? Assume that the variables...
For the MIPS assembly instructions below, what is the corresponding C statement? Assume that the variables f, g, h, and I are assigned to registers $s0 - $s3, respectively. Assume that the base address of arrays X, Y, and Z are in registers $s4 - $s6, respectively. Be conservative and use a single temp register as possible. It is a C arithmetic command with two source operands and a destination. Each part is 3 points. Add $t0, $s0, $s1 addi...
Question: Write down the corresponding MIPS machine language of the following assembly language code. lw $S0,...
Question: Write down the corresponding MIPS machine language of the following assembly language code. lw $S0, 64($S1) add $t0,$S0,$S1 sub $t1,$S3,$S4 sw $t1,100($S1) addi $S4,$S6,100
The following multi-threaded program uses 3 concurrent threads (T0, T1, and T2). The threads are synchronized...
The following multi-threaded program uses 3 concurrent threads (T0, T1, and T2). The threads are synchronized by 3 semaphores (S0, S1, S2). What is the maximum number of times '0' will be printed by thread T0? // Global to all threads Semaphore S0(1), S1(0), S2(0) Thread T0 While (true) S0.wait() print( '0' ) S1.signal() S2.signal() endWhile Thread T1 S1.wait() S0.signal() Thread T2 S2.wait() S0.signal()

2.  Suppose we have 3 arrays A, B, and C, array A’s base address is in $S3,...
2.  Suppose we have 3 arrays A, B, and C, array A’s base address is in $S3, B’s base address is in $S4, C’s base address is in $S5. You can only use two temporal registers $t0 and $t1. Convert the following code into MIPS assembly language code. Suppose every array element occupies 1 word in MIPS (32 bits). A[21] = B[0] + C[16];
We assume the following $s0 = a $s1 = b $s2 = c $s3 = i...
We assume the following $s0 = a $s1 = b $s2 = c $s3 = i $s4 = address of ar[0] Write MIPS assembly code for the following C code. for (i = 10; i < 30; i ++) { if ((ar[i] > b) || (ar[i] <= c)) ar[i] = 0; else ar[i] = a; }
1. Assume there are three memory locations named h hand area, translate the following expression into...
1. Assume there are three memory locations named h hand area, translate the following expression into MIPS assembly language. No Floating point. Area= 1/2 b. h 2. Show the assembly statement that allocates a word in the data segment named area with an initial value of 10. 3. What are the contents of register $t0, $t1, and $t2? .data str:    .asciiz   "ab" .text main:   la $t0, str li    $t1, 0 loop: lb $t2, ($t0) beqz   $t2, eloop addi $t1,...
Question 1. Answer the following questions on MIPS Instruction Set. a) Show the minimal sequence of...
Question 1. Answer the following questions on MIPS Instruction Set. a) Show the minimal sequence of MIPS instruction for the following pseudocode segment: A[3] = A[10] + B; Assume that B corresponds to register $t3 and the array A has a base address of 1000C41016 which is required to be loaded to register $t0 in your code. Provide comments for each line of your MIPS instruction. b) Assume that Loop starts at memory location 0xC010. Provide a) instruction format of...
This is a homework assignment for Computer Architecture and some question use MIPS Assembly language. 1.    ...
This is a homework assignment for Computer Architecture and some question use MIPS Assembly language. 1.     In the following MIPS assembly code, translate all the instructions to their corresponding machine code in hexadecimal format. This code is stored in the memory from address 0x1fff0000. Loop: sw $t1, 4($s0)        addi $t1, $t1, -1    sll $t1, $t1, 2        bne $t1, $s5, Exit    addi $s0, $s0, 4          j Loop Exit: … 2.     Find the MIPS...
1a. Using the MIPS program below (with bugs intact), determine the instruction format for each instruction...
1a. Using the MIPS program below (with bugs intact), determine the instruction format for each instruction and write the decimal values of each instruction field. addi $v0, $zero, 0 loop: lw $v1, 0($a0) sw $v1, 0($a1) sll $a0, $a0, 2 add $a1, $a1, $a0 beq $v1, $zero, loop 1b. Translate the following C/Java code to MIPS assembly code. Assume that the values of a, i, and j are in registers $s0, $t0, and $t1, respectively. Assume that register $s2 holds...
The C++ program steps through the array x[]. For each i, if x[i] < x[i+1], i...
The C++ program steps through the array x[]. For each i, if x[i] < x[i+1], i is saved in the array ascend[], in order. Compile and run the program; it should print 0 4 5. In this exercise, you’ll try to translate the C++ program to MIPS. Some of the more tedious parts are already given in Assignment3.F19.s. You won’t have to write the data allocation sections, some of the initializations, and the output loop at the end. So the...