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

the question is above. and the solution to this question is below. can you pleas

ID: 2080833 • Letter: T

Question

the question is above. and the solution to this question is below. can you please explain step by step on how they got the solution

3. The following codes are a set of MIPS instructions (hexadecimal form) and their corresponding addresses in the memory. For each line, the information is [Address] Instruction [00400024] 00008020 [00400028] 20110003 [0040002 cl 20120014 [00400030] 16120002 [00400034] 2231ffff [00400038] 08100010 [0040003c] 22310001 [00400040] 00118020 (1) Write down the corresponding MIPS ASM instructions (2 points x 80 (2) Write down the corresponding C codes (4 points) Solution

Explanation / Answer

(1)The corresponding MIPS ASM instructions given are..

The given instructions are given in the hexadecimal are converted in binary i.e;

binary to hexadecimal

0000 0

0001 1

0010 2

0011 3

0100 4

0101 5

0110 6

0111 7

1000 8

1001 9

1010 a

1011 b

1100 c

1101 d

1110 e

1111 f

so the instructions given are

00008020 can be written in binary as 0000 0000 0000 0000 0100 0000 0010 0000

0 0 0 0 8 0 2 0

similarly remaining instructions can be arranged i.e;

20110003 can be written in binary as 0010 0000 0001 0001 0000 0000 0000 0011

2 0 1 1 0 0 0 3

similarly you can understand remaining instructions given in the last block by comapringwith binary to hexadecimal table.

Now let us discuss the C program part as well as assembly level part

as in the C program block given

int a=0; int b=3;

if(a!=20) //since a = 0 initially. given a!=20 means a not equal 20 therfore that is true it goes to the statement b=b+1; that mens b becomes 3+1; b=4;

{

b=b+1; //=> b=3+1=4.

else

b=b-1;

}

a=b; //a=b means a becomes 4.. again a=4 goes to the loop [ if(a!=20) ] that means now a =4 which is not equal to 20. therefore now b=b+1; takes place that means b=4+1; b=5;

now after 16 times loop a=20 that means loop [ if(a!=20) ] false. therefore now b=b-1; statement takes place. now b=19 then a=b => i.e; a=19 again loop repeats.

Now we'll discuss the asm level language.

given that.

add $s0,$0,$0 # statement means s0 = 0+0 =0 initially s0=0

addi $s1,$0,03   # statement means s1 = 0+3 =3 initially s1=3

addi $s2,$0,20    # statement means s2 = 0+20 =20 initially s2=20

bne $s0,$s2, LabelA   # statement means next instruction is at LabelA if s0 not equal to s2 (i.e s0!=s2)

addi $s1,$s1,-1   # statement means [s1= s1-1 ]

j labelB  # statement means jump to LabelB

LabelA: addi $s1,$s1,$1  # statement means s1 = s1+1 =3+1 = 4; initially s1=3

LabelB: add $s0,$0,$s1  # statement means s0 = 0+1 = 1 initially s0=1

here add= addition, addi = signed addition, bne= b not equal to and j = jump.

These programs are very easy if u understand the C program it is similar to assembly level language. Both are creating a loop. In C program it is given variables as a, b whereas in Assembly language it is given as s0,s1.

I hope you have got this problem.