hi, after the normals i wanted to try another thing, so here is a procedure to calculate ln x or log(e) x

hope it makes sense

hope it makes sense

```
```

asm_ln PROC X:float ; log(e) X

fldl2e ; log(2) e

fld1 ; calculate 1/log(2)e

fdivrp st(1), st

fld X

fyl2x ; calculate 1/log(2)e * log(2)X = log(e) x

ret

asm_ln ENDP

Is the acurracy of this code limited to [-1,1] range?

uh oh, i have to admit that i don't know for sure.

when i had a look at your macros i didn't quite understand what's going on...and why...

wuold you help me to understand it better?

when i had a look at your macros i didn't quite understand what's going on...and why...

wuold you help me to understand it better?

I got the power function from Agner Fog:

http://www.asdf.org/~fatphil/x86/pentopt/26.html#26_10

...and then I read the Intel manuals. IIRC, the F2XM1 instruction has a limitation of [-1,1] range for accurate results. I was curious, but do not know (without the manual) if that limitation exists in the function you present above. I will read the manual and see what the possible limitations would be. I will document the algo better and repost - Agner didn't really document it either. :)

http://www.asdf.org/~fatphil/x86/pentopt/26.html#26_10

...and then I read the Intel manuals. IIRC, the F2XM1 instruction has a limitation of [-1,1] range for accurate results. I was curious, but do not know (without the manual) if that limitation exists in the function you present above. I will read the manual and see what the possible limitations would be. I will document the algo better and repost - Agner didn't really document it either. :)

bitrake, intel documentaion says:

"the source operand in st(0) must be a non-zero positive number"

so i guess there has to be a check if it's zero at least...

but i don't know how to implement that efficiently.

"the source operand in st(0) must be a non-zero positive number"

so i guess there has to be a check if it's zero at least...

but i don't know how to implement that efficiently.

In REAL4 format a negitive number would have the top bit set, and zero would be 0x00000000. Therefor, there is no difference is testing for a positive non-zero REAL4, and testing for a positive non-zero 32-bit integer.

```
asm_ln PROC X:float ; log(e) X
```

cmp DWORD [X],0

jle Error

fld1 ; calculate 1/log(2)e

fldl2e ; log(2) e

fdiv

fld X

fyl2x ; calculate 1/log(2)e * log(2)X = log(e) x

ret

Error:

;?

ret

asm_ln ENDP

; ln ST(0) :: needs two more free stack spaces and ST(0) > 0

fln MACRO

fld1 ; log(2) e

fldl2e ; calculate 1/log(2)e

fdiv

fxch

fyl2x ; calculate 1/log(2)e * log(2)X = log(e) x

ENDM