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

Homework #1 Due Feb. 22 (a write MIPs assembly code that will execute the follow

ID: 3796850 • Letter: H

Question

Homework #1 Due Feb. 22 (a write MIPs assembly code that will execute the following c statement. Assume that the c following registers are used to represent the variables: a in register sso, b in register ssl, and in register Ss2 a (a b) (c-33) (b) Replace the C code for by a set of equivalent MIPs instructions, using as few instructions as possible. Assume that h is in register S8, and the staring addresses for arrays a and in registers respectively. (c) Replace the C code for by a set of equivalent MIPS instructions, using as few instructions as possible. Assume that f and g are in register Sti and St0 respectively, and the staring addresses for arrays A and Bare stored in registers Sao and Sal, respectively. (a) Follow the instructions below CONSECUTIVELY, and after each instruction write the value of destination register in decimal into the space provided. ori Ss1, Szero, 2 assi- sll $s2, Ss1, 3 andi Ss3, $s2, 19 #$s3 4- (b) Translate the following C statement into the corresponding MIPS code. Assume that the variables f and g are assigned to registers Ss0 and Ssl, the base address of the arrays A and B and are in register Ss6 and Ss7, respectively. 3. Memory (a) How many locations of memory can you address with 16-bit address? (b) How many bits are required to address a 4 Mega location memory, ie, what is the length of the memory address?

Explanation / Answer

2.

a)

ori $s1,$zero,2   $s1=2
sll $s2,$s1,3   $s2=16
andi $s3,$s2,19 $s3=16
sub $s4,$s3,$s2   $s4=0

3)

(a) 65,536 locations can be addressed by 16 bit address

(b) 22 bits are required to address 4 mega of locations

(c) memory address = intArray[13] = $t5 + 52

(d)memory address = charArray[11] = $s5 + 11

5)

$s0 = 10   $s6 = 256
$s1 = 20
$s2 = 30
$s3 = 40

a)

add $s0,$s0,$s1 = $s0 = 30
add $s0,$s3,$s2 = $s0 = 70
add $s0,$s0,$s3 = $s0 = 110

b)

addi $s6,$s6,-20 = $s6 = 236
add $s6,$s6,$s1 = $s6 = 256
Lw $s0,8($s6) = $s0 = 300

8)

a. x= array[3] => c. lw $t1 , 12($t0)

b. x* = x => add $t1,$t1,0

c.x = array[x] => e. NONE OF THE ABOVE

d.x = y * 128 => e. sll $t1,$t2,7

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote