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
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()

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...
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...
I'm trying to write a nested loop in Mips Assembly that prints out, for example, if...
I'm trying to write a nested loop in Mips Assembly that prints out, for example, if user input x was 5: 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 (spaces in between) So far my code is : li $v0, 5   #Ask for integer syscall move $t5, $v0 addi $t0, $zero, 0 For1:    slt $t1, $t0, $t5    beq $t1, $zero, Exit    add $s0, $s0, $t0    addi $t0, $t0, 1...
(MIPS Assembly Language): Assume the following piece of MIPS code: label1: .text 0x4000fc lui $t0, 1022...
(MIPS Assembly Language): Assume the following piece of MIPS code: label1: .text 0x4000fc lui $t0, 1022 ori $t0, $t0, 2048 srl $t1, $t0, 18 sw $t0, 101($t1) slti $t2, $t1, 5 beq $t2, $0, label3 label2:... ... label3:... a) The code modifies a word in memory at the following address (circle one): (i) 1022 (ii) 101 (iii) 5 (iv) 10220000 (v) Other (provide your own answer): _________________ b) The following value is stored in memory (circle one): (i) 0x17 (ii)...
Use the following expressions for left and right sums left sum = f(t0)Δt + f(t1)Δt +...
Use the following expressions for left and right sums left sum = f(t0)Δt + f(t1)Δt + f(t2)Δt +    + f(tn − 1)Δt right sum = f(t1)Δt + f(t2)Δt + f(t3)Δt +    + f(tn)Δt and the following table. t 0 4 8 12 16 f(t) 25 22 20 18 15 (a) If n = 4, what is Δt? Δt = What are t0, t1, t2, t3, t4? t0 = t1 = t2 = t3 = t4 = What are f(t0), f(t1), f(t2), f(t3),...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT