Starting from:
$30

$24

Homework assignment 1 Solution

Exercises:

2.8 [2 points] Translate 0xabcdef12 into decimal.




2.7 [2 points] Show how the value 0xabcdef12 would be arranged in memory of a little-endian and a big-endian machine. Assume the data is stored starting at address 0.




2.1 [2 points] For the following C statement, what is the corresponding MIPS assembly code? Assume that the variables f, g, h, and i are given and could be considered 32-bit integers as declared in a C program. Use a minimal number of MIPS assembly instructions: f = g + (h − 5);




2.3 [6 points] For the following C statement, what is the corresponding MIPS assembly code? Assume that the variables f, g, h, i, and j are assigned to registers $s0, $s1, $s2, $s3, and $s4, respectively. Assume that the base address of the arrays A and B are in registers $s6 and $s7, respectively.

B[8] = A[i - j];




2.10 [4 points] Translate the following MIPS code to C. Assume that the variables f, g, h, i, and j are assigned to registers $s0, $s1, $s2, $s3, and $s4, respectively. Assume that the base address of the arrays A and B are in registers $s6 and $s7, respectively.




addi $t0, $s6, 4

add $t1, $s6, $0

sw $t1, 0($t0)

lw $t0, 0($t0)

add $s0, $t1, $t0




2.23 [1 point] Assume $t0 holds the value 0x00101000. What is the value of $t2 after the following instructions?

slt $t2, $0, $t0

bne $t2, $0, ELSE

j DONE

ELSE: addi $t2, $t2, 2

DONE:




Computer Project: [6 + 7 = 13 points]

Write MIPS codes to compute the following sums:

More products