Hi Peter,
Yes, good idea.
Though some of these function were needed before calculators came along. I would find secants, cosecants ant cotans quite confusing.
Anyway, here are the macro equivalents of your functions. The main advantages of using FPU macros are:
1 They will compute using the full precision of the FPU: no loss due to memory variables.
2 Slightly better performance since all the calculations are done in registers. And there is no function call overhead.
def ArcTan atan
def Arctn atn
def ArcSin asin
def ArcCos acos
deff Secant
fcos : fld1 : fdivrp st1
end deff
deff Cosecant
fsin : fld1 : fdivrp st1
end deff
deff Cotan
fptan : fld1 : fdivrp st1
end deff
deff ArcCotan
fld1 : fdivrp st1
fpatan
end deff
deff ArcSecant
fld1 : fdivrp st1
fld st0 : fmul st0 : fld1 : fsubp st1,st0 : fchs : fsqrt : fxch : fpatan
end deff
deff ArcCoSecant
fld1 : fdivrp st1
fld st0 : fmul st0 : fld1 : fsubp st1,st0 : fchs : fsqrt : fpatan
end deff
deff sgn
fldz
fcomip
fstp st0
(
ja fwd lt
jb fwd gt
fldz : exit
.gt
fld1 : exit
.lt
fld1 : fchs
)
end deff
jmp fwd nex
.exp_
sub esp,16 : fstcw [esp] : fstcw [esp+2] : or [esp],0xc00 : fldcw [esp]
fldl2e : fmulp st1 : fld st0 : frndint : fsub st1,st0
fxch : f2xm1 : fld1 : faddp st1 : fscale : fstp st1
fldcw [esp+2] : add esp,16
ret
.nex
deff sinh
'(Exp(x) - Exp(-x)) /2 'Hyperbolic Sine
fld st0
call exp_
fxch st1
fchs
call exp_
fld st1
fsub st1
fld1
fadd st0
fdivp st1
fxch st2
fstp st0
fstp st0
end deff
deff cosh
'(Exp(x) + Exp(-x)) /2 'Hyperbolic Cosine
fld st0
call exp_
fxch st1
fchs
call exp_
fld st1
fadd st1
fld1
fadd st0
fdivp st1
fxch st2
fstp st0
fstp st0
end deff
deff tanh
'(Exp(x)-Exp(-x)) / (Exp(x)+Exp(-x)) 'Hyperbolic Tan
fld st0
call exp_
fxch st1
fchs
call exp_
fld st1
fsub st1
fld st2
fadd st2
fdivp st1
fxch st2
fstp st0
fstp st0
end deff
Charles