Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 6: The following table holds various binary values for register $t0. Giv

ID: 3713021 • Letter: P

Question

Problem 6: The following table holds various binary values for register $t0. Given the value of $t0, you will be asked to evaluate the outcome of different branches.

a. 0010 0100 1001 0010 0100 1001 0010 0100two

b. 0101 1111 1011 1110 0100 0000 0000 0000two

Also assume $t1 holds the value: 0011 1111 1111 1000 0000 0000 0000 0000two

Note the result of executing these instructions on particular registers. What is the value of $t2 after the following instructions?

slt $t2, $t0, $t1

beq $t2, $0, ELSE

j DONE

ELSE: addi $t2, $0, 2

DONE:

Problem 7: Assume that the variables f, g, and h are assigned to registers $t0, $t1 and $t2, respectively. What is the corresponding C code for the above instructions? Please SHOW WORK

Explanation / Answer

Problem 6)

when $t1 =a

slt $t2, $t0, $t1 will set $t2=1 since  $t0 < $t1.

beq $t2, $0, ELSE , here control wont barnch to ELSE since $t2=1

j DONE, finally the control will flow to DONE

VALUE OF T2=1

===========================

when $t1 =b

slt $t2, $t0, $t1 , here t2 wont be set since  $t0 > $t1.

beq $t2, $0, ELSE , so in this step control will barnch to ELSE since $t2=0

ELSE: addi $t2, $0, 2, in this step t2 = 0+2 = 2

VALUE OF T2=2

-----------------------------------------------------------------------------------------

Problem 7)

Equivalent C code

if(f<g){

h=1;

}else{

h=2;

}