Please use computer organization and design 5th edition book

Please use computer organization and design 5th edition \"book\"
3. (40 points] Translate the following statements using only these MIPS instructions li, Iw, sw, add, addi, bne. Use \"loop\" and \"halt\" as the instruction labels. You must use to comment each int A(100], B[100]; for (i 1; ik 100; i++) Ali Ali-11 Blij; Assume the base addresses of AO is in $a0, and for BO it is $al.

Solution

.data
A:   .word 0:100        # array of 100 integers
B:   .word 0:100        # array of 100 integers


.text
main:
    li $t0, 4       # load the value \"1\" into register $t0
    li $t1, 400     # load the value \"100\" into register $t1
    la $a1, B
    la $a0, A

loop:
    add $t2, $a1, $t0 # $t2 = B + i
    lw $s4, 0($a1)     # $s4 = B[i]
    add $t3, $t0, -4   # $t3 = i - 1
    add $t4, $a0, $t3 # $t4 = A + i - 1
    lw $s5, 0($t4)     # $s5 = A[i - 1]
    add $t5, $a0, $t0 # $t5 = A + i
    add $t6, $s4, $s5 # $t6 = B[i] + A[i - 1]
    sw $t6, 0($t5)     # A[i] = $t6
    addi $t0, $t0, 4   # i++

    li $v0, 1 # system call for print_int
    move $a0, $t6 # the sum to print
    syscall # print the sum

    blt $t0, $t1, loop # branches to Loop if $t0 < 100

Please use computer organization and design 5th edition \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site