Question

Write a sequence of MIPS instructions to find the absolute value of the value in register...

Write a sequence of MIPS instructions to find the absolute value of the value in register $s0 and store it into register $t0. Assume you do not have access to multiplication instructions. Use as few instructions as possible. You do not have to assemble your code for this question, but you may do so to validate that it works.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

screenshot:

Add a comment
Know the answer?
Add Answer to:
Write a sequence of MIPS instructions to find the absolute value of the value in register...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Translate each of the following pseudo-instructions into MIPS instructions. You should Produce a minimal sequence of...

    Translate each of the following pseudo-instructions into MIPS instructions. You should Produce a minimal sequence of MIPS instructions to accomplish the required computation. (8 Points) 1) bgt $t1, 100, Label # bgt means branch if greater than 2) ble $s2, 10, Next # ble means branch if less than or equal 3) ror $s0, $s4, 7 # ror means rotate right $s4 by 7 bits and store the result in $s0 4) neg $s5, $s4 # $s5 will have the...

  • 5. Write the MIPS minimal sequence of instructions for the following C procedure code: int array_sum...

    5. Write the MIPS minimal sequence of instructions for the following C procedure code: int array_sum (a[], b[])                                  { int i;                                       i =1; for (i=1; i<100; i=i+1) { b[i] = D + a[i-1] + a[i] + a[i+1] ;}                                                             } Assume that: a and b are arrays of words and the base address of “a” is in $a0 and the base address of “b” is in $a1, Register $S1 is associated with...

  • Write a sequence of MIPS instructions to do the following: set $t1 to 1 if the...

    Write a sequence of MIPS instructions to do the following: set $t1 to 1 if the contents of $s0 is an even number and set $t1 to 0 otherwise. Please do not use the division instruction in you code. Instead, you could use some logical instruction to test if a number is even or odd.       

  • B2. Convert the C code to MIPS assembly with only 2 efficient instructions: Register assignment: ...

    B2. Convert the C code to MIPS assembly with only 2 efficient instructions: Register assignment: timer-v0 int timer = 0x0AC8 0001; B3. Write MIPS assembly code segment for the following C code snippet for (i - 0, i < 100; i++) -array Register assignment: i-) $ao Base of array -> $s0 array [ i+1] [i] / 2; B2. Convert the C code to MIPS assembly with only 2 efficient instructions: Register assignment: timer-v0 int timer = 0x0AC8 0001; B3. Write...

  • Write the program in MIPS Initialize register $t0 (will hold the sum) to zero. Then add...

    Write the program in MIPS Initialize register $t0 (will hold the sum) to zero. Then add 409610 to $t0 sixteen times. You don't know how to loop yet, so do this by making 16 copies of the same instruction. The hexadecimal value of 409610 is 0x1000 Next, initialize register Stl to 409610. Shift St1 left by the correct number of positions so that registers $t0 and $tl contain the same bit pattern. Finally, initialize register $t2 to 409610. Add $t2...

  • Using MIPS: Consider the following fragment of C code: for i=0: i < = 100: i...

    Using MIPS: Consider the following fragment of C code: for i=0: i < = 100: i = i + 1) {a[i] = b[i] + c;} Assume that a and bare arrays of words and the base address of a is in $a0 and the base address of b is in $a1. Register $t0 is associated with variable i and register $s0 with c. Write the code for MIPS. How many instructions are executed during the running of this code? How...

  • Could someone explain the shortest sequence of MIPS instructions that extracts four bits, bits 18-15, from...

    Could someone explain the shortest sequence of MIPS instructions that extracts four bits, bits 18-15, from register $s0 and uses the value of this field to replace bits 12-9 in register $s1 without changing other bits of register $s1?

  • Translate the following C code to MIPS assembly code. Assume that the value of i is...

    Translate the following C code to MIPS assembly code. Assume that the value of i is in register $t0, and $s0 holds the base address of the integer MemArray if (i > 10) MemArray[i] = 0; else MemArray[i] = -MemArray[i];

  • 5. a. Given the following MIPS instructions with their corresponding addresses, answer the following questions. Address...

    5. a. Given the following MIPS instructions with their corresponding addresses, answer the following questions. Address 1000 Instruction sll St1, $s2, 4 1w $t0, 128(Stl) bne Sto, $15, Exit j Here Start: 1004 Here: 1008 1012 Exit: 1096 i. Write the machine code for each of the above MIPS instructions (5 pts) ii. Find the total number of bits required to store the instructions (3 pts) 5. a. Given the following MIPS instructions with their corresponding addresses, answer the following...

  • Find the value for $t2 Assume the following register contents: $t0 = 0xAAAAAABA, $t1 = 0x82345678...

    Find the value for $t2 Assume the following register contents: $t0 = 0xAAAAAABA, $t1 = 0x82345678 For the register values shown above, what is the value of $t2 for the following sequence of instructions? sr1 $t2, $t0,5 and i $t2, $t2, 0xEFE2 For the register values shown above, what is the value of $t2 for the following sequence of instructions? sr1 $t2, $t0, 5 add i $t2, $t2, 0xEFE2

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT