Assembly square root function
Thread Starter
Member
iTrader: (2)
Joined: Mar 2006
Posts: 236
Likes: 0
From: Hudson, OH
Car: '87 Formula
Engine: Ramjet 350
Transmission: T56
Axle/Gears: 3.23
Assembly square root function
Does anyone know of or have a square root procedure (mathematical or assembly). So far I've only found long approximation methods but maybe this is really the best way of doing it? In that case how do they get so accurate with say sqrt function in high level languages (my own thought but feel free to answer if you care to).
I'm messing around trying to calculate something as practice and learning (HP and Torque due to drag) but I need to raise to power of 2.5, which can be done by square root of 5th power, but I need that sqaure root model.
I'm messing around trying to calculate something as practice and learning (HP and Torque due to drag) but I need to raise to power of 2.5, which can be done by square root of 5th power, but I need that sqaure root model.
Moderator
Joined: Jan 2000
Posts: 20,981
Likes: 11
From: Mercedes Norte, Heredia, Costa Rica
Car: 1984 Z28 Hardtop
Engine: 383 Carb
Transmission: 4L60
Axle/Gears: 3.54 Dana 44
Re: Assembly square root function
All methods of calculating irrational roots are approximate, but can be improved through iteration to any precision desired.
Do you want an implementation in floating point? fixed point? integer? what format?
What's the equation you're trying to use?
Do you want an implementation in floating point? fixed point? integer? what format?
What's the equation you're trying to use?
Moderator
iTrader: (1)
Joined: Mar 2002
Posts: 18,432
Likes: 233
From: Chasing Electrons
Car: check
Engine: check
Transmission: check
Re: Assembly square root function
Apeiron, glad to see that you have this one. My level of math doesn't mesh that well with assembler.
Another thought would be to use a lookup table.
RBob.
Another thought would be to use a lookup table.
RBob.
Moderator
Joined: Jan 2000
Posts: 20,981
Likes: 11
From: Mercedes Norte, Heredia, Costa Rica
Car: 1984 Z28 Hardtop
Engine: 383 Carb
Transmission: 4L60
Axle/Gears: 3.54 Dana 44
Re: Assembly square root function
I'd also use a lookup table, since speed is the only variable that needs a fractional root.
There are a number of interesting algorithms for calculating square roots to any desired precision though, depending on which format you're using. All of them are slow.
There are a number of interesting algorithms for calculating square roots to any desired precision though, depending on which format you're using. All of them are slow.
Last edited by Apeiron; Jun 28, 2007 at 05:47 PM.
Thread Starter
Member
iTrader: (2)
Joined: Mar 2006
Posts: 236
Likes: 0
From: Hudson, OH
Car: '87 Formula
Engine: Ramjet 350
Transmission: T56
Axle/Gears: 3.23
Re: Assembly square root function
Thanks guys, didn't think of the lookup table, thats a good idea. I'll give it a go.
I didn't think about implementing the equation until I was actually writing the code. I think I got too far ahead of myself. BTW, I'm doing it the hard way...with a hex editor, since I don't have a source with the wideband patch, let alone all my values transferred. I guess it's not really that much harder, just have to watch the addressing. Good learning though
Thanks again.
I didn't think about implementing the equation until I was actually writing the code. I think I got too far ahead of myself. BTW, I'm doing it the hard way...with a hex editor, since I don't have a source with the wideband patch, let alone all my values transferred. I guess it's not really that much harder, just have to watch the addressing. Good learning though

Thanks again.
Thread
Thread Starter
Forum
Replies
Last Post
Dragonsys
Engine/Drivetrain/Suspension Parts for Sale
2
Sep 25, 2015 03:51 PM





