mirror of https://github.com/lianthony/NT4.0
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
138 lines
2.5 KiB
138 lines
2.5 KiB
;/***
|
|
;*trig.a - sin, cos, tan functions
|
|
;*
|
|
;* Copyright (c) 1991-1991, Microsoft Corporation. All rights reserved.
|
|
;*
|
|
;*Purpose:
|
|
;* Trig functions to be used with M68K version
|
|
;*
|
|
;*Revision History:
|
|
;* 05-07-92 PLM MAC version
|
|
;*
|
|
;*******************************************************************************/
|
|
|
|
#include <traps.a>
|
|
#ifdef SANE
|
|
#include <sane.a>
|
|
#endif
|
|
|
|
|
|
;double sin(double x)
|
|
|
|
cProc _CIsin,PUBLIC
|
|
localW fpstat
|
|
cBegin _CIsin
|
|
#ifdef SANE
|
|
movem.l <d0/d1>, -(a7)
|
|
pea fpstat
|
|
move.w #FOPROCENTRY,-(a7)
|
|
FP68K ;save current status & set default control
|
|
|
|
move.l a0, -(a7)
|
|
move.w #FOSINX,-(a7)
|
|
Elems68K ;sin x
|
|
|
|
pea fpstat
|
|
move.w #FOPROCEXIT,-(a7)
|
|
FP68K ;set result status & restore control
|
|
movem.l (a7)+, <d0/d1>
|
|
#else
|
|
fmove.l fpcr,d0
|
|
|
|
ftst.x fp0 ;see if it is a valid number
|
|
fmove.l fpsr, d1 ;get status word
|
|
and.l #0x03007c00, d1 ;see if we get an exception
|
|
cmp.l #0, d1
|
|
bne domain_error_fpu
|
|
|
|
fmove.l #0,fpcr
|
|
fsin.x fp0
|
|
jra to_end_fpu
|
|
|
|
domain_error_fpu:
|
|
move.l #33, _errno
|
|
to_end_fpu:
|
|
fmove.l d0,fpcr
|
|
#endif
|
|
cEnd _CIsin
|
|
|
|
;double cos(double x)
|
|
|
|
cProc _CIcos,PUBLIC
|
|
localW fpstat
|
|
cBegin _CIcos
|
|
#ifdef SANE
|
|
movem.l <d0/d1>, -(a7)
|
|
pea fpstat
|
|
move.w #FOPROCENTRY,-(a7)
|
|
FP68K ;save current status & set default control
|
|
|
|
move.l a0, -(a7)
|
|
move.w #FOCOSX,-(a7)
|
|
Elems68K ;cos x
|
|
|
|
pea fpstat
|
|
move.w #FOPROCEXIT,-(a7)
|
|
FP68K ;set result status & restore control
|
|
movem.l (a7)+, <d0/d1>
|
|
#else
|
|
fmove.l fpcr,d0
|
|
|
|
ftst.x fp0 ;see if it is a valid number
|
|
fmove.l fpsr, d1 ;get status word
|
|
and.l #0x03007c00, d1 ;see if we get an exception
|
|
cmp.l #0, d1
|
|
bne domain_error_fpu2
|
|
|
|
fmove.l #0,fpcr
|
|
fcos.x fp0
|
|
jra to_end_fpu2
|
|
|
|
domain_error_fpu2:
|
|
move.l #33, _errno
|
|
to_end_fpu2:
|
|
fmove.l d0,fpcr
|
|
#endif
|
|
cEnd _CIcos
|
|
|
|
;double tan(double x)
|
|
|
|
|
|
cProc _CItan,PUBLIC
|
|
localW fpstat
|
|
cBegin _CItan
|
|
#ifdef SANE
|
|
movem.l <d0/d1>, -(a7)
|
|
pea fpstat
|
|
move.w #FOPROCENTRY,-(a7)
|
|
FP68K ;save current status & set default control
|
|
|
|
move.l a0, -(a7)
|
|
move.w #FOTANX,-(a7)
|
|
Elems68K ;ln x
|
|
|
|
pea fpstat
|
|
move.w #FOPROCEXIT,-(a7)
|
|
FP68K ;set result status & restore control
|
|
movem.l (a7)+, <d0/d1>
|
|
#else
|
|
fmove.l fpcr,d0
|
|
|
|
ftst.x fp0 ;see if it is a valid number
|
|
fmove.l fpsr, d1 ;get status word
|
|
and.l #0x03007c00, d1 ;see if we get an exception
|
|
cmp.l #0, d1
|
|
bne domain_error_fpu3
|
|
|
|
fmove.l #0,fpcr
|
|
ftan.x fp0
|
|
jra to_end_fpu3
|
|
|
|
domain_error_fpu3:
|
|
move.l #33, _errno
|
|
to_end_fpu3:
|
|
fmove.l d0,fpcr
|
|
#endif
|
|
cEnd _CItan
|
|
|
|
|