.ORIG x3000 ; forms the inner product of two vectors stored as an array ; each array contains 10 elements. ; array1 is stored starting at address x3100 ; array2 is stored starting at address x3200 ; the inner product (or dot product) is the sum of the products of corresponding array elements ; product = A(1)*B(1) + A(2)*B(2) + ....+ A(10)*B(10) ; program returns the result in register R4 product AND R0, R0, #0 ;clear R0. This will be used to count number of elements processed AND R4, R4, #0 ;clear R4. This will be used to keep track of the running sum (the inner product) ADD R0, R0, #10 ; initialize R0 to 10 -- the number of elements in array ;fill in code below for computing dot product ; the result will be stored in R4 ; load address of first element of array 1 ; load address of first element of array 1 ; fetch first element of each array into a register ; the program must call the subroutine MULT defined below to perform the multiplications ; make sure you save any registers that will be altered by MULT ; figure out how you will store and load address of MULT HALT array1 .FILL x3100 array2 .FILL x3200 ; Create Multiplication subroutine ;.ORIG x4000 -- the origin command has to be removed from the original code ; this code for MULT multiplies two numbers, stored in registers R0, and R1 and the product/result is stored in R7 ; Modify this code so that it is now a subroutine and can be called by any function, and will return to the caller. .ORIG x4000 ; multiplies two non-zero numbers x and y, stored in registers R0 (stores x), and R1 (stores y) and ; returns result in R7 mult AND R7, R7, #0 ;initialize R7 =0 - R7 will store product ; can you insert code here to check if either of the numbers is zero (in which case product is zero) loopmult ADD R7, R7, R1 ; add R1 to itself R0 times and store in R7- add y to itself x times ADD R0, R0, #-1 ;decrement R0 BRp loopmult done HALT ;End of your entire program goes below .END