Question

Simulation: Write a MIPS program which computes the vector dot product. Vector dot product involves calculations of two vecto

0 0
Add a comment Improve this question Transcribed image text
Answer #1
 1 ;-------------------------------------------------
 2 ; mult3.asm - this calculates a "dot product" of
 3 ;  two n-element arrays, according to this C ftn:
 4 ;
 5 ;   int mult3( int *dst, int *src)
 6 ;   {
 7 ;       int sum = 0;
 8 ;       int i;
           int n; // no.of element in arrary
           cin>>n;
 9 ;       for (i = 0; i < n; i++)
10 ;           sum += dst[i] * src[i];
11 ;       return sum;
12 ;   }
13 ;
14 ; This also introduces a very simple Nasm "macro".
15 ;-------------------------------------------------
16 global _mult3
17 
18 sum equ 16      ; like C " #define sum 16 "
19 
20     section .text
21 _mult3:
22     push ebp
23     mov ebp,esp
24     push esi
25     push edi
       mov ebx , 7 //here n is number of elements

26     sub esp, 4  ; "sum"
27 
28     mov esi, [ebp+12]
29     mov edi, [ebp+8]
30     mov dword [ebp-sum], 0
31     mov ecx, 0
32 .forloop:
33     mov eax, [edi + ecx*4]
34     imul dword [esi + ecx*4]
35     inc ecx
36 
37     add [ebp-sum], eax
38 
39     cmp ecx, ebx
40     jb .forloop
41 
42     mov eax, [ebp-sum]
43     add esp, 4

44     pop edi
45     pop esi
46     pop ebp
47     ret
48 ;-------------------------------------------------
Add a comment
Know the answer?
Add Answer to:
Simulation: Write a MIPS program which computes the vector dot product. Vector dot product involv...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • MIPS Assembly Vector (array) addition Create, in the memory, the following two 2-integer arrays (vectors): Array(A),...

    MIPS Assembly Vector (array) addition Create, in the memory, the following two 2-integer arrays (vectors): Array(A), Array(B). *****PLEASE USE MIPS FOR THIS PROGRAM ONLY***** Create, in the memory, the following two 2-integer arrays (vectors): Array (A), Array(B). Array (A) = [2 3], Array (B) = [4 5] (a) Add the two created arrays (vectors): Array (A) + Array (B) = Array(C). (b) Print (console) the elements of the resulting vector [Array(C)].

  • in c++ Write a program which can find the dot product of two vectors of the...

    in c++ Write a program which can find the dot product of two vectors of the same length ?. The user will enter the length ?. Use the length to control how many times you loop. The result is a scalar value and not a vector. If the dot product is zero, then the two vectors are perpendicular.

  • C++ Create a program that finds the dot product of two vectors. I'm currently trying to...

    C++ Create a program that finds the dot product of two vectors. I'm currently trying to display the dot product by calling the dotProduct member function however I am confused as to how to do this. What would be the proper way to display the dot product? I don't believe my dotProduct member function is set up correctly to access the proper data. Feel free to modify the dotProduct member function to allow for it to work with the other...

  • Create a program named my_dotProduct which USING LOOPS calculates the dot product of two vectors

    Problem 2: Matrix Vector Operationsa) Create a program named my_dotProduct which USING LOOPS calculates the dot product of two vectors (of dimensions \(1 \times n\) ) from the keyboard. The program should check the input from the user making sure that the vectors are the right dimensions. If the vectors are not then an error message should be outputted to the user. If the vectors are of the right dimensions then the answer should be outputted to the user. Using...

  • programing C,already write part of code (a) Write a function print.array that receives an array of...

    programing C,already write part of code (a) Write a function print.array that receives an array of real numbers and the number of el stored in the array. This function must display the elements of the array in order with each one on a line by itself in a field width of 7 with two decimal places. (See sample output. Recall the format specifier would be "%7.21f"). (b) Sometimes we want to treat an array as a mathematical vector and compute...

  • Problem 3 - Find the dot product between vectors A and B where Pa Worksheet 6 Vector Dot and Cross Products Problem 4...

    Problem 3 - Find the dot product between vectors A and B where Pa Worksheet 6 Vector Dot and Cross Products Problem 4 - Use the vector dot product to find the angle between vectors A and B where: Defining the Vector Cross Product: It turns out that there are some weird effects in physics that require us to invent a new kind of vector multiplication. For example, when a proton moves through a magnetic field, the force on the...

  • the furthest i could get is that the dot product between vector N and vector V,...

    the furthest i could get is that the dot product between vector N and vector V, as well as vector X and vector V must be zero but that's about it. I get stuck when trying to use the cosine relation with the dot product but since the question doesn't allow me to write it in terms of an angle, i can't really use that. If someone could show me how this would help incredibly! 3. X is an unknown...

  • Need to write a MIPS assembly program that finds the minimum and maximum and sum of...

    Need to write a MIPS assembly program that finds the minimum and maximum and sum of a stored array. It also finds the locations of the minimum and maximum. The interaction between the main program and the function is solely through the stack. The function stores $ra immediately after being called and restores $ra before returning to main. The main program reserves a static C like array (index starts from 0) of 10 elements and initializes it. The maximum should...

  • 4. (3 pts. each) Write the hexadecimal representation of each MIPS assembly instruction: (4.1) sub $s3,...

    4. (3 pts. each) Write the hexadecimal representation of each MIPS assembly instruction: (4.1) sub $s3, $t1, $s2 (4.2) bne $t3, $t4, 18 (4.3) sll $s0, $t5, 2 5. (20 pts.) Consider the following C (or java) code: else f=f+2; By storing the value of j in Ss0, write a sequence of MIPS assembly instructions that will execute these lines of code for the following two cases: (5.1) assuming that the values of f, g and h are stored in...

  • In MIPS: Write an assembly program that reads two lists of floating point numbers A and...

    In MIPS: Write an assembly program that reads two lists of floating point numbers A and B from users, and displays the measures given above on the simulator’s console. The program’s specifications are given below: • Each input vector should be of size 10, i.e., N=10 • The program should use PROCEDURES to compute dot product. Sample input vectors: A = [0.11 0.34 1.23 5.34 0.76 0.65 0.34 0.12 0.87 0.56] B = [7.89 6.87 9.89 7.12 6.23 8.76 8.21...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT