.text
.globl DiagAdd
DiagAdd:
# ARGUMENTS WILL BE PASSED AS FOLLOWS:
#a0 = address of row-major NxN matrix A; Equivalently, address of A[0][0]
#a1 = address row-major N-vector B; Equivalently, address of B[0]
#a2 = address of row-major NxN matrix C; Equivalently, address of C[0][0]
#a3 = N
#
# Assume N >= 1; A, B, C elements all 32-bit integers
# EXPECTED BEHAVIOR AFTER EXECUTION:
# Sets the value of C = A except along diagonal, where B is added to the diagonal, i.e.
# when i!=j C[i][j] = A[i][j]; when i==j, C[i][j]=A[i][j]+B[i]
# Provided code currently loops over all i, j values, but does nothing — replace with code implementing expected behavior
add $t0, $0, $0 # i = 0;
iLOOP: # DO {
add $t1, $0, $0 # j = 0;
jLOOP: # DO {
addi $t1, $t1, 1 # j++
bne $t1, $a3, jLOOP # } while j < N
addi $t0, $t0, 1 # i++
bne $t0, $a3, iLOOP # } while i < N
jr $ra # return