"sum of squares" program in assebly language programming?

The objective is to write a MIPS Assembly language program, that prompts a user to enter a positive integer n, and computes and print the sum 1sqaure + 2square + ....+ nsquare. (should not use formula).

Can somebody help me with a sample working code.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

We can't really give full code, as this is an assignment.

Maybe I can give some pointers.

1. You should use a counter... say CX, initialize this to your integer n.

2. You should use a a conditional jump (jz or jnz) together with a loop to ensure that you are able to loop n number of times.

3. n ^ 2 is simply a number multiplied by itself. So you can use the MUL operation.

4. You should use a temporary address (or register) to store your results as you loop.

Maybe you can post some code, and then we can take it from here:

Hope that helps
- Kelvin
thirst4truthAuthor Commented:
Hi Kelvin King

I made the previous program working,  Thank you.
However, Now i am writing a program for harmonic series..
following is my code. I am getting syntax error for div instruction in the code

# ***** This program caluculates the Hormonic Series ****

# $t0 - n , No. of loops
# $t1 - temporary reg, hold 1/nth value
# $t2 - sum of the series
# $t3 - counter

      li $v0, 5
      move $t0, $v0

        li $t2, 0
      li $t3, 0
      beq $t3, $t0, endloop
      add $t3, $t3, 1
      div $t1, 1, $t3
      add $t2, $t2, $t1
      b loop
      ## Print out $t2.
      move $a0, $t2
      li $v0, 1

      li $v0, 10
thirst4truthAuthor Commented:
I got the program working. thx

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
thirst4truthAuthor Commented:
I got it working by myself
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.