Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7703605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:29:51+00:00 2026-05-31T23:29:51+00:00

I am in a computer arch class and we are doing mips using single

  • 0

I am in a computer arch class and we are doing mips using single precision. The homework involves creating newtons method. I have written all the functions required but cannot figure out exactly what is wrong with the code. I am also not exactly sure how to print values out to the screen. All help is much appreciated. I have written comments line by line to explain what i am doing.

Here is my code:

# Newtons Method
# g(x) = (-x^3) + 11
# g'(x) = -3x^2


.data
precision: .float .00001


main:
jal newtons_gee

newtons_top:

li $s2, 11      # stores 11 into the $s2 register
mtc1 $s2, $f5       # moves the value of $s1 (3) to the coproc 1
mul.s $f1,$f0,$f0   # This finds x^2 
mul.s $f1,$f0,$f1   # This finds x^3
add.s $f2,$f1,$f5   # adds the value of (x^3) + 11 and stores it into $f2 as         asked

newtons_bot:
li $s1, -3      # stores -3 into the $s1 register
mtc1 $s1, $f3       # moves the value of $s1 (-3) to the coproc 1   
mul.s $f5, $f3,$f0  # Calculating -3x in derivative of the original function
mul.s $f4,$f5,$f0   # Calculates -3x^2 and stores it in $f4 as asked

newtons_err:
jal newtons_top     # Calls newtons_top
jal newtons_bot     # Calles newtons_bot
div.s $f6,$f2,$f4   # Calculates g(Xn)/ g'(Xn) and stores it in $f6 as asked

newtons_nth:
addi $a0,$a0,1      # Increases the current iteration by 1
jal newtons_err     # Call newtons_err
sub.s $f7,$f0,$f6   # Calculate value of En
mov.s $f7,$f0       # Find the new nth 
abs.s $f3, $f3      # Flag Case
l.s $f9, precision  # Precision 
c.lt.s $f3, $f9         # set the flag if |x'-x| < 0.00001    stores in $v0
j newtons_nth       # Repeat
newtons_gee:
li $f0, 1       # Sets the Xn to 1
li $a0, 1       # Sets the current iteration
jal newtons_nth # Calls newtons_nth
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T23:29:53+00:00Added an answer on May 31, 2026 at 11:29 pm

    Some tips:

    • When you call a function, you need to return or else your code will just continue to the next section. Newtons_top is going to run into newtons_bot, newtons_bot is going to run into newtons_err, and then they’ll just get called again, resulting in an infinite loop. Labels are just labels; they don’t magically end your function. The return address is automatically loaded into $ra when you use the jal instruction. You can therefore return by using jr $ra.

    • When you have nested calls, such as in newtons_err, your $ra gets squashed. So you need to back up $ra before using jal, and then restore it before returning.

    • When does your loop end? You don’t have an exit condition. You’re checking the precision, but you don’t have a conditional jump afterward. It’ll continue forever.

    • You want to use the values of 11 and -3, but you’re not properly loading them into the floating-point registers. When you use mtc1 you’re copying the values verbatim. The problem is that 11 as an integer is not the same as 11 in floating-point. You need an additional instruction to convert it to a float:

      cvt.s.w $f5, $f5

      Here’s a reference containing that conversion: http://www.doc.ic.ac.uk/lab/secondyear/spim/node20.html

    • li $f0, 1 isn’t valid. You can’t actually load an immediate into a float register. You can use the same method as you used for the 11 and the -3, but you’ll still need the conversion instruction above.

    • Since you’re loading constants (11, -3, 1) into float registers, you can save an instruction by declaring them as floats in your data section, and using l.s $fX, someLabel instead of li $s2, someConstant -> mtc1 $s2, $fX.

    • The MIPS instruction set doesn’t know what printing to the screen means. Printing to the screen involves communicating with other hardware, so to answer that question you need to know what hardware is on your board.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My computer graphics homework is to implement OpenGL algorithms using only the ability to
The computer is connected to measuring device via a physical COM1. I have simple
Are computer languages copyrighted or have some restrictions imposed on them how they can
I'm in a computer systems course and have been struggling , in part, with
I only have one computer (running OS X), and need to test in both
My computer crashed recently. We have a Delphi app that takes a lot of
My computer is a dual core core2Duo. I have implemented multithreading in a slow
The About of most computer programs have a version number, such as 2.1 where
I'm in my first year of Computer Sciences and I have to design a
My computer have a proxy server defined globally (in internet options configuration). I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.