Starting from:
$30

$24

Problem Assignment 2


Solution: The translated code into C is: f = 2*(&A)


Problem 2 (2.12) Score:


Solution:    1. 0x50000000

    2. over ow, not the desired answer.

    3. 0xb0000000

    4. It is the desired answer.

    5. 0xd0000000

    6. over ow, not the desired answer.


Problem 3 (2.14) Score:



0000 0010 0001 0000 1000 0000 0010 0000
Solution: It is in r-type.











000000

10000
10000
10000
00000
100000



















opcode-add
rs
rt
rd

shamt

funct
$s0,
$s0
So the assembly language instruction i, add $s0,




Problem 4 (2.16) Score:


Solution: From funct=34 and check the table we can know it is a sub operation. So the instruction in assembly language is:
sub $v1, $v1, $v0 (r-type) And it represent in binary form is: 0000 0000 0110 0010 0001 1000 0010 0010(2)


Problem 5 (2.19) Score:


Solution:    1. The value stored in $t0 is shifted four places to the left and bitwise or with the value stored in $t1.

The answer is: 0xbabefef8.

    2. The value stored in $t0 is shifted four places to the left and bitwise joined with 1111 1111 1111 1111 1111 1111 1111 1111 The answer is: 0xaaaaaaa0.

    3. The value stored in $t0 is shifted three places to the right and bitwise joined with 0000 0000 0000 0000 1111 1111 1110 1111 The answer is: 0x00005545.


Problem 6 (2.23) Score:


Solution: The rst instruction set $t2 to 1 because $t0 > 0 is true. Then go into the ‘ELSE’ branch and set $t2 to $t2 plus 2. So after that $t2 equal to 3. 






















1 / 1

More products