Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

Assume that registers \(s0 and \)s1 hold the values 0x80000000 and 0xD0000000, respectively.

1. What is the value of \(t0 for the following assembly code?

add \)t0,\(s0,\)s1

2. Is the result in \(t0 the desired result, or has there been an overflow?

3. For the contents of registers \)s0 and \(s1 as specified above, what is the value of \)t0 for the following assembly code?

sub \(t0,\)s0,\(s1

4. Is the result in \)t0 the desired result, or has there been an overflow?

5. For the contents of registers \(s0 and \)s1 as specified above, What is the value of \(t0 for the following assembly code?

add \)t0,\(s0,\)s1

add \(t0,\)t0,\(s0

6. Is the result in \)t0 the desired result, or has there been an overflow?

Short Answer

Expert verified

The results of each instruction:

  1. The value of $t0=50000000
  2. Yes, it has overflow.
  3. The value of $t0=B0000000
  4. No, there is no overflow.
  5. The value of $t0=D0000000
  6. Yes, there is an overflow

Step by step solution

01

Determine the MIPS instruction number formats:

In MIPS assembly language, instructions use hexadecimal numbers. The machine will convert them into binary digits represented as bits. The rightmost bit is referred to as the Least Significant Bit. The left-most bit is referred to as the Most Significant Bit.

MIPS takes the 32-bit inputs, which means all the input data will be considered in 32 bits format.

02

Determine the value of $t0

Given that the values of registers $s0 and $s1 :

$s0=0×80000000$s1=0×D0000000

1.Given instruction : add $t0,$s0,$s1

Add instruction will add the $s0 and $s1 . the result will be stored in $t0.

The value of $t0 for the given assembly code is as follows:

Hexadecimal values will be converted into binary values.

$s0=1000000000000000$s1=1101000000000000$s0+$s1=$t0=0101000000000000

Now, the value of $t0 will be converted to hexadecimal.

$t0=0×50000000

03

Determine whether overflow occurred or not

Given that the values of registers $s0 and $s1:

2. Given instruction: add $t0,$s0,$s1

$s0=1000000000000000$s1=1101000000000000$s0+$s1=$t0=0101000000000000

In the given instruction while performing addition, the overflow will occur at the left-most bit.

In the above addition, the leftmost bits of $s0 and $s1 are 1. While adding 1+1 in binary addition the value is 10. In 10,1 is neglect due to overflow only 0 is considered.

So the value of $t0 is considered as 0101 0000 0000 0000 due to overflow.

04

Determine the value of $t0.

Given that the values of registers $s0 and $s1:

$s0=0×80000000$s1=0×D0000000

3. Given instruction: sub $t0,$s0,$s1

Sub instruction will subtract the $s0 and $s1 . the result will be stored in $t0.

The value of $t0 for the given assembly code is as follows:

Hexadecimal values will be converted into binary values.

$s0=1000000000000000$s1=1101000000000000

$s0-$s1=$t0=1011000000000000

Now, the value of $t0 will be converted to hexadecimal.

$t0=0×B0000000

05

Determine whether overflow occurred or not.

Given that the values of registers $s0 and $s1 :

$s0=0×80000000$s1=0×D0000000

4. Given instruction: sub $t0,$s0,$s1

In the given instruction while performing addition, the overflow will occur at the left-most bit.

$s0=1000000000000000$s1=1101000000000000

$s0-$s1=$t01011000000000000

In the above subtraction, the leftmost bits of $s0 and $s1 are 1 and 0 when getting borrowed. While subtracting 1 and 0 the result is 1. So there is no overflow occurred.

06

Determine the value of $t0.

Given that the values of registers $s0 and $s1 :

5. Given instruction:

$s0=0×80000000$s1=0×D0000000

add $t0, $s0, $s1

add $t0,$t0,$s0

add instruction will add the $s0 and $s1 . the result will be stored in $t0.

The value of $t0 for the given assembly code is as follows:

Hexadecimal values will be converted into binary values.

$s0=1000000000000000$s1=1101000000000000

$s0+$s1=$t0=0101000000000000

Now, the value of $t0 will be converted to hexadecimal.

$t0=0×B0000000

The next instruction will add the values of $t0 and $s0 as follows:

$t0=0101000000000000$s0=1000000000000000

$t0+$s0=1101000000000000

The value of $t0 can be obtained by converting the binary to hexadecimal

$t0=0×D0000000

07

Determine whether overflow occurred or not

Given that the values of registers $s0 and $s1 :

$s0=0×80000000$s1=0×D0000000

6. Given instruction:

add $t0, $s0, $s1

add $t0,$t0,$s0

add instruction will add the $s0 and $s1 . the result will be stored in $t0.

The value of $t0 for the given assembly code is as follows:

Hexadecimal values will be converted into binary values.

$s0=1000000000000000$s1=1101000000000000

$s0+$s1=$t0=0101000000000000

In the above addition, the leftmost bits of $s0 and $s1 are 1. While adding 1+1 in binary addition the value is 10. In 10,1 is neglect due to overflow only 0 is considered.

So the value of $t0 is considered as 0101 0000 0000 0000 due to overflow.

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

Question: Show how the value would be arranged in memory of a little-endian and a big-endian machine. Assume the data is stored starting at address 0

Consider the following code:

lbu \(t0, 0(\)t1)

sw \(t0, 0(t2)

Assume that the register \)t1 contains the address 0×10000000and the register \(t2 contains the address 0×10000010. Note the MIPS architecture utilizes big-endian addressing. Assume that the data (in hexadecimal) at the address role="math" localid="1650309285539" 0×10000000is 0×11223344 . What value is stored at the address pointed to by register \)t2?

Question: Translate the following loop into C. Assume that the C-level integer i is held in register \(t1, \)s2 holds the C-level integer called result, and \(s0 holds the base address of the integer MemArray.

addi \)t1, \(0, \)0

LOOP: lw \(s1, 0(\)s0)

add \(s2, \)s2, \(s1

addi \)s0, \(s0, 4

addi \)t1, \(t1, 1

slti \)t2, \(t1, 100

bne \)t2, $s0, LOOP

Question: Right before your function f from Exercise 2.34 returns, what do we know about contents of registers \(t5, \)s3, \(ra, and \)sp? Keep in mind that we know what the entire function f looks like, but for function func, we only know its declaration.

Question: The table below shows 32-bit values of an array stored in memory.

2.6.1 For the memory locations in the table above, write C code to sort the data from lowest to highest, placing the lowest value in the smallest memory location shown in the figure. Assume that the data shown represents the C variable called Array, which is an array of type int, and that the first number in the array shown is the first element in the array. Assume that this particular machine is a byte-addressable machine and a word consists of four bytes.

2.6.2 For the memory locations in the table above, write MIPS code to sort the data from lowest to highest, placing the lowest value in the smallest memory location. Use a minimum number of MIPS instructions. Assume the base address of Array is stored in register $s6.

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.

Sign-up for free