Question

CDA-3101 – MIPS Assembly Programming 1. Write the following code segment in MIPS assembly language code:...

CDA-3101 – MIPS Assembly Programming 1. Write the following code segment in MIPS assembly language code: 3. Write a MIPS program to find the sum of squares from 1 to n. Where n=10. For example, the sum of squares for 10 is as follows: 12+22+32+……+n2=385

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

Please find the code below::::

.data
prompt0: .asciiz "\nPlease enter value for n : "
prompt1: .asciiz "\nThe sum of squares is : "

.text
li $v0,4
la $a0,prompt0 #it will print prompt
syscall
li $v0,5
syscall #ask user input
move $t1,$v0 #save a to t1

li $s0,0 #store the sum
loop:
beqz $t1,exit
mul $s1,$t1,$t1 #get square
add $s0,$s0,$s1 #add to sum
sub $t1,$t1,1 #reduce one from t1
j loop
exit:
li $v0,4
la $a0,prompt1 #it will print prompt
syscall
li $v0,1
move $a0,$s0
syscall

output:

Add a comment
Know the answer?
Add Answer to:
CDA-3101 – MIPS Assembly Programming 1. Write the following code segment in MIPS assembly language code:...
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