Re: intel x86 floating point power funtion in assembly?
From: Terje Mathisen (spamtrap_at_crayne.org)
Date: 12/20/04
- Next message: Grumble: "Re: intel x86 floating point power funtion in assembly?"
- Previous message: Terje Mathisen : "Re: clax86-submit@crayne.org"
- In reply to: Matt C.: "intel x86 floating point power funtion in assembly?"
- Next in thread: Grumble: "Re: intel x86 floating point power funtion in assembly?"
- Reply: Grumble: "Re: intel x86 floating point power funtion in assembly?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 20 Dec 2004 21:09:31 +0000 (UTC)
Matt C. wrote:
> I've been trying to find a good power function (x^y) that is
> written in 100% intel x86 fpu assembly language. Does anybody
> have one, or do you know where I can find one?
The naive approach is to simply do exp(ln(x)*y), right?
This is relatively straightforward, except that we'd prefer to use
binary logs and exponentiation:
FYL2X calculates the product of a scale factor (i.e. Y) and the binary
logarithm of the input number (X).
F2XM1 returns the result of binary exponentiation minus 1.0, so the
following code should do it:
; Assume the caller has loaded first Y, then X onto the fp stack!
power proc
fyl2x ; Binary log
f2xm1 ; Result - 1
fld1 ; Load 1.0
faddp st(1),st(0) ; Add together and pop
ret ; Return the result as ST(0)
power endp
Next is to detect some of the special cases:
Integer y?
Negative y?
Y close to zero?
X close to zero or one?
Terje
-- - <Terje.Mathisen@hda.hydro.com> "almost all programming can be viewed as an exercise in caching"
***********************************************************************
NOTICE: This e-mail transmission, and any documents, files or previous
e-mail messages attached to it, may contain confidential or privileged
information. If you are not the intended recipient, or a person
responsible for delivering it to the intended recipient, you are
hereby notified that any disclosure, copying, distribution or use of
any of the information contained in or attached to this message is
STRICTLY PROHIBITED. If you have received this transmission in error,
please immediately notify the sender and delete the e-mail and attached
documents. Thank you.
***********************************************************************
- Next message: Grumble: "Re: intel x86 floating point power funtion in assembly?"
- Previous message: Terje Mathisen : "Re: clax86-submit@crayne.org"
- In reply to: Matt C.: "intel x86 floating point power funtion in assembly?"
- Next in thread: Grumble: "Re: intel x86 floating point power funtion in assembly?"
- Reply: Grumble: "Re: intel x86 floating point power funtion in assembly?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|