a) Fill in the blanks. .data A: .word 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 i: .word 7 B: .word 40 45 50 55 60 65 k: .word 1 m: .word 5 # how many f: .word 15 #size of A g: .word 6 #size of B .text .globl main main: # load registers for array A la $s0, A # load address of A lw $s2, i # load word i into s2 # load registers for array B la $s1, B # load address of B lw $s3, k # load word k into s3 #how many to overwrite lw $s4, m # load word g (how many) into s4 # initialize registers to get A[i] sll $s6, $s2, 2 add $s6, $s6, ____ # address of A[i] (new base) # initialize registers to get B[k] sll $s7, $s3, 2 add $s7, $s7, ____ # address of B (new base) #what is the A index to stop? Let's put it into s5 ______________________________ #Loop through A and B Loop: # use slt to compare $s5 and $s2, place the result in t0 ___________________________ beq $t0, $zero, end # load A[i] and store into B[k] lw $t0, 0($s6) sw $t0, 0($s7) #update of the indices addi $s3, $s3, ____ addi $s2, $s2, ____ #update the address addi $s7, $s7, ____ addi $s6, $s6, ____ j Loop end: ori $v0, $zero, 10 #exit syscall b) What would have happened if m=6? What would have happened if m=10? What kind of tests should be performed in the loop to address the cases such as m=6 and m=10? Describe in words.
a)
Fill in the blanks.
.data
A: .word 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
i: .word 7
B: .word 40 45 50 55 60 65
k: .word 1
m: .word 5 # how many
f: .word 15 #size of A
g: .word 6 #size of B
.text
.globl main
main:
# load registers for array A
la $s0, A # load address of A
lw $s2, i # load word i into s2
# load registers for array B
la $s1, B # load address of B
lw $s3, k # load word k into s3
#how many to overwrite
lw $s4, m # load word g (how many) into s4
# initialize registers to get A[i]
sll $s6, $s2, 2
add $s6, $s6, ____ # address of A[i] (new base)
# initialize registers to get B[k]
sll $s7, $s3, 2
add $s7, $s7, ____ # address of B (new base)
#what is the A index to stop? Let's put it into s5
______________________________
#Loop through A and B
Loop:
# use slt to compare $s5 and $s2, place the result in t0
___________________________
beq $t0, $zero, end
# load A[i] and store into B[k]
lw $t0, 0($s6)
sw $t0, 0($s7)
#update of the indices
addi $s3, $s3, ____
addi $s2, $s2, ____
#update the address
addi $s7, $s7, ____
addi $s6, $s6, ____
j Loop
end:
ori $v0, $zero, 10 #exit
syscall
b)
What would have happened if m=6?
What would have happened if m=10?
What kind of tests should be performed in the loop to address the cases such as m=6 and m=10?
Describe in words.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps