Question

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 7.32 7.32 8.22]

The program’s output should be similar to given in the following:

The dot product of A and B = 78.45

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hello user, I will answer your question gladly :D

. data asking 1: .asciiz \Enter the 10 float numbers of vect。r A(one line each):\n asking2: .asciiz \Enter the 10 fl。at nu#else la Şa0,asking2 #1 ads the value 4 into register $v0 which is the op code for print string #reads register $v0 for op codot product: la Şa0,arrayA la Şal,arrayB la Şa2,aux lwcl $f12,0 (Şa2) li $t0 , 0 11 Şti,10 cycle: lwcl $f1,0 (Şal) mul.s ŞE3,

And here is some output I got, using the example in the statement:

nter the 10 float numbers of vector A (one line each) 0.11 0.34 1.23 5.34 0.76 0.65 0.34 0.12 0.87 0.56 ter the 10 float numb

And here is the functional code:

.data

asking1: .asciiz "\Enter the 10 float numbers of vector A(one line each):\n"
asking2: .asciiz "\Enter the 10 float numbers of vector B(one line each):\n"
arrayA: .float 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
arrayB: .float 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
aux: .float 0.0

.text

main:
   la $a0,asking1
   li $v0, 4        #loads the value 4 into register $v0 which is the op code for print string
   syscall        #reads register $v0 for op code, sees 4 and prints the string located in $a0

   la $a0,arrayA
   li $t0,0
   li $t1,10
cycle1:  
   li $v0, 6        #loads the value 6 into register $v0 which is the op code for read float
   syscall        #reads register $v0 for op code, reads and saves the float in $f0
   swc1 $f0,0($a0)
   addi $a0,$a0,4
   addi $t0,$t0,1
   bne $t0,$t1,cycle1

#else
   la $a0,asking2
   li $v0, 4        #loads the value 4 into register $v0 which is the op code for print string
   syscall        #reads register $v0 for op code, sees 4 and prints the string located in $a0
  
   la $a0,arrayB
   li $t0,0
   li $t1,10
cycle2:  
   li $v0, 6        #loads the value 6 into register $v0 which is the op code for read float
   syscall        #reads register $v0 for op code, reads and saves the float in $f0
   swc1 $f0,0($a0)
   addi $a0,$a0,4
   addi $t0,$t0,1
   bne $t0,$t1,cycle2
   jal dot_product
   li $v0, 10        #exit
   syscall

  
dot_product:
   la $a0,arrayA
   la $a1,arrayB
   la $a2,aux
   lwc1 $f12,0($a2)
   li $t0,0
   li $t1,10
cycle:
   lwc1 $f0,0($a0)
   lwc1 $f1,0($a1)
   mul.s $f3,$f0,$f1
   add.s $f12,$f12,$f3
   addi $a0,$a0,4
   addi $a1,$a1,4
   addi $t0,$t0,1
   bne $t0,$t1,cycle
   li $v0, 2
   syscall
   jr $ra


answered by: ANURANJAN SARSAM
Add a comment
Know the answer?
Add Answer to:
In MIPS: Write an assembly program that reads two lists of floating point numbers A and...
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
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