How to perform dot product of two vectors in low level language ?

·

1 min read

Given->

2000: 1 2004: 2 2008: 3

3000: 4 3004: 5 3008: 6

4000: 3

5000: AFSASDFASDFASD

Find the dot product of above two vectors

  1. Find the initial address of two vectos
                  ```
                  MOV R1,#2000
                  MOV R2,#3000
                  ```
  1. Load the size of two vectos
                  ```

LOAD R3,4000


> 3.  Set up register for storing dot product value

CLEAR R4


> 4.  Perform looping till R3 is zero

LOOP: //CODE BRANCH_IF [R3>=0] LOOP


> 5.  //CODE

LOAD R5,[R1] LOAD R6,[R2] MUL R7,R5,R6 ADD R4,R4,R7 ADD R1,R1,#4 ADD R2,R2,#4 SUB R3,R3,#1


> 6.

STORE R4,5000 ```