Not Yet Answered # square root?

Salem 5,138 Discussion Starter homeryansta 36 Salem 5,138 Discussion Starter homeryansta 36 Discussion Starter homeryansta 36 Discussion Starter homeryansta 36 wildgoose 420 Discussion Starter homeryansta 36 wildgoose 420 OK, so HostGator for some reason no longer allows gcc/g++ access unless you have a Designated Server account, which is a lot of money to spend just to compile my "Hello World" program. Thus I figured I'd compile at home, then upload. Program is your regular old bare-bones Hello World ...

0

> how do you do a square root in MIPS?

Same as anywhere else, assuming you lack a library to do it

- research algorithms (you've got google, do some searches)

- write code

- test code

0

Same as anywhere else, assuming you lack a library to do it

- research algorithms (you've got google, do some searches)

- write code

- test code

I tried looking for an algorithm to do so. however, the only ones I came upon requires me to split the number being rooted by 2's. Not possible.

0

> the only ones I came upon requires me to split the number being rooted by 2's. Not possible.

Are there more restrictions on the answer that you're not telling us?

What does "split the number by 2" mean anyway - divide?

0

not divide by 2 but separate the digits into 2.

example: if the number I want to root is 96358

9, 63, 58 is what i split it into.

0

> the only ones I came upon requires me to split the number being rooted by 2's. Not possible.

Are there more restrictions on the answer that you're not telling us?What does "split the number by 2" mean anyway - divide?

the instruction just says, find the hypotenuse of 2 user input leg of a right triangle. the 2 input are floating points.

0

newton's method means i have to use derivative.... according to that formula.

0

What were the rules your teacher gave you?

Which flavor of MIPS are you using?

There are scalar and vector square root functions and estimated reciprocal square root vector functions, dependent upon which MIPS family chipset you're using!

There are also algorithmic guesstimation formulas for integer only processors.

0

What were the rules your teacher gave you?

Which flavor of MIPS are you using?There are scalar and vector square root functions and estimated reciprocal square root vector functions, dependent upon which MIPS family chipset you're using!

There are also algorithmic guesstimation formulas for integer only processors.

there are different MIPS?

here is the program i'm working on. hopefully you can determine what flavor it is by looking at it because I'm clueless.

```
#stuck, cannot figure out square root
.text
.globl __start
__start:
la $a0, prompt #print the directions to screen
li $v0,4
la $a0,prompt # prompt user for a
li $v0,4 # print string
syscall
li $v0,6 # read single
syscall # x stored to f0
mov.s $f2,$f0
la $a0,prompt2 # prompt user for b
li $v0,4 # print string
syscall
li $v0,6 # read single
syscall
# evaluate a and b to get c
mul.s $f2,$f2,$f2 # square a
mul.s $f0,$f0,$f0 # square b
add.s $f2,$f2,$f0 # add a^2 and b^2
# print the result
mov.s $f12,$f2 # $f12 = argument
li $v0,2 # print single
syscall
la $a0,newl # new line
li $v0,4 # print string
syscall
li $v0,10 # code 10 == exit
syscall # Return
## Data Segment
.data
pi: .float 3.14
degree: .float 180.0
prompt: .asciiz "Enter a: "
prompt2:.asciiz "Enter b: "
blank: .asciiz " "
newl: .asciiz "\n"
```

0

I used the word 'flavor' but that's one of my descriptive words like 'squirelly'. "The code is acting squirelly!" There are many MIPS architectures and cores within the MIPS family.

Visit www.mips.com are review the Cores and Architectures.

The processor is designed for co-processors to be plugged in like building blocks. I'm over simplifying the mechanism but read their documents.

That code isn't really going to help as I doubt you're using 3D instructions yet, or SIMD, etc. Are you using a MIPS simulator or a prototyping board, or a custom design? What model processor does it use?

I believe the MIPS 3000 didn't have a square root function. It had basic Single/Double-Precision functionality. +-*/

```
SQRT.S fd,fs MIPS II Square Root
SQRT.D fd,fs
fd = sqrt( fs )
RSQRT.S fd,fs MIPS IV Estimated reciprocal square root
RSQRT.D fd,fs
fd = 1 / sqrt( fs )
and to get it to square root
fe = fs * fd
```

This article has been dead for over six months. Start a new discussion instead.

Recommended Articles

Hi. I have a form with list box : lst_product, datagridview : grd_order and button: btn_addline. lst_product has a list of product ids selected from database (MS Acess 2013) , grd_order is by default empty except for 2 headers and btn_addline adds rows to grd_order.

btn_addline :

`Private Sub btn_addline_Click(ByVal ...`

I don’t want at this stage work on a big separate project as I've already got plenty ...