Here is a new version with better CtoStr (using wsprintf)
But there is a problem, (where is not), in CLog proc

CLog proc z1:complex,zret:dword

;zt2=sigmul
invoke CAbs,z1,addr zt1
fpucmp zt1,0,CMP_EQU
jne nonZeroR
fldz
mov eax,zret
fstpt eax
nonZeroR:
;until here every thing is ok
invoke FpuLogx,addr zt1, addr zret, SRC1_REAL or DEST_MEM
;[COLOR=red]after this invoke eax is messed and even if i do
;mov eax, zret
;it does not work. i couldn't figure it out :([/COLOR]


;If (z1 >= 0 And z1+10 = 0) Or (z1 = 0 And z1+10 = 0) Then
; CLog+10 = 0
;ElseIf z1 = 0 And z1+10 >= 0 Then
; CLog+10 = PI / 2
;ElseIf z1 <= 0 And z1+10 = 0 Then
; CLog+10 = PI
;ElseIf z1 = 0 And z1+10 <= 0 Then
; CLog+10 = 3 * PI / 2
;Else

fldt z1.r ; zt2 = sgn(z1) * sgn(z1+10)
fsgn
fldt z1.i
fsgn
fmulp st(1),st
fstpt zt2.r
fldt zt2.r

fld1 ; st = ( 1 + sgn(r) - 2 * zt2 ) * pi
fadd st,st
fchs
fmulp st(1),st
fldt z1.r
fsgn
fld1
faddp st(1),st
fadd st(1),st
fldpi
fmulp st(1),st

fldt z1.i ; st = zt2 * atn ( abs(i) / abs(r) )
fabs
fldt z1.r
fabs
fpatan
fldt zt2.r
fmulp st(1),st

faddp st(1),st ; st= ( 1 + sgn(r) - 2 * zt2 ) * pi + zt2 * atn ( abs(i) / abs(r) )
[COLOR=blue];note that at this point stack is valid[/COLOR]
fstpt eax+10

;PI / 2 * (-z1 / Abs(z1) + 1) + PI * z1 / Abs(z1) * (-z1+10 / Abs(z1+10) + 1) + z1 * z1+10 / Abs(z1 * z1+10) * Atn(Abs(z1+10 / z1))
;EndIf
ret

CLog endp


Raymond: not intended for fractals, i did this to improve my fpu skills, and it was nearly succesful(or is it?).:grin:
Posted on 2003-09-05 07:47:14 by inFinie
Congratulations for your patience on this project of yours.:alright:
invoke FpuLogx,addr zt1, addr zret, SRC1_REAL or DEST_MEM
;after this invoke eax is messed and even if i do
;mov eax, zret
;it does not work. i couldn't figure it out

All the functions in the Fpulib are written with the same philosophy as the Windows API functions regarding registers: the EAX, ECX and EDX registers can be used freely and should not be expected to be preserved.

I'll download the zip file and have a closer look at your new code within the next few days.

Meanwhile, it seems as if zret is the address of a global variable. When you use addr zret as the destination for the FpuLogx function, you are pointing to the position on the stack where the zret address is located, effectively overwriting that address with the result of the FpuLogx function!!!
As a preliminary assumption, it should probably be
invoke FpuLogx,addr zt1, zret, SRC1_REAL or DEST_MEM

Raymond
Posted on 2003-09-05 22:49:30 by Raymond
Hi...Nice code.

but missing the file fpucond.inc in the zip file.

Best Regards

Guga
Posted on 2003-09-05 23:41:33 by Beyond2000!
No one uses the C calling convention anymore - that is the easiest solution to the original problem. Using the stack efficiently is a good thing, imho. For those that don't know: the C calling convention has the caller correct the stack after calling (only RETN is used in the PROC). The parameter space becomes a temporary data area for the called PROC allowing complex communication with the parent PROC.
Posted on 2003-09-05 23:59:58 by bitRAKE
fpucond.inc
Posted on 2003-09-06 04:41:58 by inFinie
:rolleyes: never looked to FpuLogx parameters.
Btw there was mistake. In VB Log(x) is Ln(x), so i used FpuLogx, now changed to FpuLnx
Posted on 2003-09-06 14:19:19 by inFinie
A new version
Have a look at CLogQ which will replace CLog when mature
No more fpucond.inc but i will not delete fpucond.inc message from here maybe it will be useful for someone.
Posted on 2003-09-06 17:07:50 by inFinie
Three updates in two days :eek:
I removed FpuLib functions of Raymond because i don't need those error checking and parameter checkings in the lib.
But inverse trigonometric functions does not work properly or i miss sthg.
CarcSin( CSin( z1 ) ) != z1:(
I'm sure it is caused by inverses but i checked them they seem to be true.
Here is definition of arcsin:
http://functions.wolfram.com/ElementaryFunctions/ArcSin/02/
Posted on 2003-09-07 11:39:55 by inFinie
A new listbox to see all functions results,
CtoStr reviewed,
CRecip corrected,
CCoth, CSech, CCsch corrected,
.
.
.

watching your comments ;)
But i will offline from tomorrow till (thurs || fri)day.

And five posts of me consecutively :eek:
Posted on 2003-09-08 11:58:50 by inFinie
Did i said something wrong? Because i was excitedly waiting for at least one reply in at most a week. :( :( :(
Posted on 2003-09-29 09:03:27 by inFinie
Don't get discouraged by the lack of replies... think that complex numbers are not often used in programming, so probably most people won't find a use for your library just yet.
Why don't you try coding a math graph program? Something to draw function graphs, etc... that coupled with your library will get some more people interested. :)
Posted on 2003-09-29 17:31:14 by QvasiModo
Well for a start, I havent been following this tread for a while (actualy thought it died).

So i go to the last link and download your latest work, and cant get it to compile. I gave up after the second error:

1) Complexis.inc is not provided
2) macros.inc (on drive C: ) is not provided.

3) ... got other things to do...

You should really try to package each zip with all the necessary support files, and not count on people to 'track' down all the peices they will need, just to take a look at what your up to.. (( I tend to get a bit impatient ;) ))

My guess is this is why your not hearing too much from the 33 downloads....

:NaN:
Posted on 2003-10-03 09:08:43 by NaN
Sorry for that i didn't knew. I'm not at home, and at school they don't allow anything to be installed on drive C. So i can't install masm32 and can't test it. Mentioned files are included in previous files but may be changed after that. Here i attach the latest asm, but may not be the latest inc, but should compile and run. And i don't have .dlg file at the moment.
Macros.asm is in masm32 v8 package. And i thought it is unnecessary to include it. but here it is:
Posted on 2003-10-06 03:21:59 by inFinie
attchmnt
Posted on 2003-10-06 03:24:35 by inFinie
If this doesn't compile then problem is your config.
(Home sweet home)
Posted on 2003-10-18 11:18:53 by inFinie
inFinie,
Sorry I did not notice what you were doing earlier. Anyway, what you are doing has been done many times before. I am submitting a excerpt from a book on numerical procedures. You can use this to compare your code to that of a professional programmer. Notice how well it is documented. It was written for 16-bit mode, but that should not be a problem to change. Enjoy. Ratch
Posted on 2003-10-18 15:50:18 by Ratch
Sorry, but i couldn't see any sin,cos,tan,cot,sec,csc,log in that package, and i need to mention i didn't saw any assembly open source programs for calculating sinh,cosh,tanh,coth,asin,acos,atan,acot,asec,acsc,asinh,acosh,atanh,acoth,asech,acsch,... did you? Or that is a part of that package?
And it is really frustrating to see nothing.:confused: :mad: :(
Posted on 2003-10-20 03:56:11 by inFinie
inFinie,
No, there are no units in the book that pertain to COMPLEX trig, COMPLEX hyperbolic, or COMPLEX log functions. It only contains simple COMPLEX arithmetic operations. The book contains 9 math units that cover the above for REAL numbers, but you were writting a complex math package, were you not? I sent you what there was of the complex number programs to give you a feel for how they could be written. Perhaps you should acquire that book. In the meantime look at this site. Ratch

http://www.efg2.com/Lab/Mathematics/Complex/Trig.htm
Posted on 2003-10-20 08:37:35 by Ratch
I was free for last few days so i decided to continue this project.

    [*]I converted all code to operate on pointers to complex structures which are two REAL10's.
    [*]Commented the code (omg :rolleyes: )
    [*]inverse functions are still wrong or i miss something (some kind of shift? -pi...pi?)
    [*]rewritten some procs to eliminate redundant usage of FPU
    [*]coded some macros operating on memory operands, doing some basic tasks such as change sign, absolute value, divide by two, divide by i, and more like that
    [*]CtoStr recoded

    And i want to ask that which way is faster to copy two real10's from mem to mem:

    ;copy 20 bytes (2 tbytes) from z2 to z1
    mcmov macro z1:req, z2:req
    mov esi, z2 ;move source to esi
    mov edi, z1 ;move dest to esi
    mov ecx, 5 ; 20 bytes = 5 dwords
    rep movsd ; move them.
    endm

    or

    fld tbyte ptr z1
    fld tbyte ptr z1+10
    fstp tbyte ptr z2+10
    fstp tbyte ptr z2

    and lastly why this doesn't work:

    fldt macro value:req
    fld tbyte ptr
    endm

    and this works ?

    fldt macro value:req
    mov eax, value
    fld tbyte ptr
    endm


    I'm hungry for your comments. Just anything.
    Sincerely,
    inFinie
Posted on 2004-08-12 09:12:55 by inFinie
quote:
--------------------------------------------------------------------------------

fldt macro value:req
fld tbyte ptr
endm

--------------------------------------------------------------------------------


and this works ?

quote:
--------------------------------------------------------------------------------

fldt macro value:req
mov eax, value
fld tbyte ptr
endm

Intel provides no way of dereferencing pointers without loading them first into a register. So if you try this:


.data
mydata dd 1234h ;just some data
mypointer dd offset mydata ;now points to "mydata"

.code
mov eax,[mypointer]

won't work simply because there's no opcode for "mov" to do that. So you have to do this:


mov eax,mypointer
mov eax,[eax]

to dereference "mypointer".

Hope that helps :)
Posted on 2004-08-12 13:20:41 by QvasiModo