In: Computer Science
.data
#Declaring and initializing A and B arrays
A: .word 2,4,-6,8
B: .word 1,2,3,7
#Declaring array C to store 4 integer elements
C: .space 16
prompt: .asciiz "The resultant
array is:\n"
space: .asciiz " "
.text
.globl main
main:
#Loading addresses of A,B and C arrays into temporary
registers
la $t0,A
la $t1,B
la $t2,C
li $t3,4 #Initializing
the loop variables
#Loading the elements of the array from memory
loop: lw $t4,0($t0)
lw $t5,0($t1)
mul $t6,$t4,$t5
#Multiplying the elements of A and B arrays
sw $t6,0($t2) #Storing
the result into C array in memory
#Pointing the temporary registers to next element in
array
addi $t0,$t0,4
addi $t1,$t1,4
addi $t2,$t2,4
addi $t3,$t3,-1
bnez $t3,loop
#Displaying the resultant array stored in
memory
li $v0,4
la $a0,prompt
syscall
la $t2,C
li $t3,4
#Printing the elements in resultant array onto
console
again: li $v0,1
lw $a0,0($t2)
syscall
li $v0,4
la $a0,space
syscall
#Pointing the temporary registers to next element in
array
addi $t2,$t2,4
addi $t3,$t3,-1
bnez $t3,again