Assume that XI is initialized to 11 and X2 is initialized to

Assume that XI is initialized to 11 and X2 is initialized to 22. Suppose you executed the code below on a version of the pipeline from Section 4.5 that does not handle data hazards (i.e., the programmer is responsible for addressing data hazards by inserting NOP instructions where necessary). What would the final values of registers X3 and X4 be?

Solution

The initial values of register X1 and X2 are given as follows:

X1 = 11

X2 = 22

Since the given code is executed on the version of the pipeline from section 4.5. Thus, it will not handle data hazards.

In this case, there is a need to handle these data hazards by insertion NOP instructions wherever required. The values of the registers X3 and X4 can be computed as follows:

Execute the instruction 1:

ADDI X1, X2, #5

The above instruction is add immediate which will add the immideiate value to the value of the register X2 and store the result into the register X1.

X1 = X2 + 5

      = 22 + 5

      = 27

The value of the register X1 in the first instruction becomes 27.

Execute the instruction 2:

ADD X3, X1, X2

This instruction will add the values of the registers X1 and X2 and store the result into the register X3. The value of register X1 will be 11 instead of 27 in this instruction.

The value of reister X1 in the first instruction was resulted as 27 but there are no data hazard handling instructions like NOP. Thus, the value of X1 will not be changed and remains 11. The second instruction executed as follows:

X3 = X1 + X2

      = 11 + 22

      = 33

Execute the instruction 3:

ADDI X4, X1, #15

The above instruction will add the immediate value 15 to the value of the register X1 and store the result into the register X4.

The value of register X1 will not be changed and remains 11 because there are no data hazard handling instructions like NOP. The third instruction is executed as follows:

X4 = X1 + 15

      = 11 + 15

      = 26

Hence, the value of the registers X3 and X4 are 33 and 26 respectively.

 Assume that XI is initialized to 11 and X2 is initialized to 22. Suppose you executed the code below on a version of the pipeline from Section 4.5 that does no
 Assume that XI is initialized to 11 and X2 is initialized to 22. Suppose you executed the code below on a version of the pipeline from Section 4.5 that does no

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site