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.
108 lines
2.1 KiB
108 lines
2.1 KiB
;/***
|
|
;*fmod.a - fmod(x,y)
|
|
;*
|
|
;* Copyright (c) 1991-1991, Microsoft Corporation. All rights reserved.
|
|
;*
|
|
;*Purpose:
|
|
;* Log and power functions to be used with M68K version
|
|
;*
|
|
;*Revision History:
|
|
;* 04-20-92 PLM MAC version
|
|
;*
|
|
;*******************************************************************************/
|
|
|
|
|
|
#include <traps.a>
|
|
#ifdef SANE
|
|
#include <sane.a>
|
|
#endif
|
|
|
|
|
|
;double fmod(double x, double y) x to the y power
|
|
|
|
|
|
cProc fmod,PUBLIC
|
|
parmQ x
|
|
parmQ y
|
|
localW sign
|
|
localW fpstat
|
|
localV xlocalx,10
|
|
localV ylocalx,10
|
|
localW xtestw
|
|
cBegin fmod
|
|
#ifdef SANE
|
|
clr.w sign ;assume positive x
|
|
btst #7,x
|
|
ifne
|
|
not.w sign ;x is negative
|
|
endif
|
|
pea fpstat
|
|
move.w #FOPROCENTRY,-(a7)
|
|
FP68K ;save current status & set default control
|
|
pea x
|
|
pea xlocalx
|
|
move.w #FFDBL+FOZ2X,-(a7)
|
|
FP68K ;convert to extended
|
|
|
|
pea y
|
|
pea ylocalx
|
|
move.w #FFDBL+FOZ2X,-(a7)
|
|
FP68K ;convert to extended
|
|
|
|
pea ylocalx
|
|
pea xlocalx
|
|
move.w #FFEXT+FOREM,-(a7) ;remainder
|
|
FP68K
|
|
btst #7,xlocalx ;test sign of result
|
|
ifne
|
|
not.w sign
|
|
endif
|
|
tst.w sign ;test for correction
|
|
ifne
|
|
btst #7,x ;set y to sign of x
|
|
ifne
|
|
ori.b #0x80,ylocalx
|
|
else
|
|
andi.b #0x7f,ylocalx
|
|
endif
|
|
pea ylocalx
|
|
pea xlocalx
|
|
move.w #FFEXT+FOADD,-(a7)
|
|
FP68K ;correct result to right sign
|
|
endif
|
|
lea xlocalx,a1
|
|
move.w (a1)+,d0 ;load result for return
|
|
move.l (a1)+,d1
|
|
move.l (a1),a0
|
|
|
|
pea fpstat
|
|
move.w #FOPROCEXIT,-(a7)
|
|
FP68K ;set result status & restore control
|
|
|
|
#else
|
|
fmove.l fpcr,d0
|
|
|
|
fmove.d x, fp0
|
|
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
|
|
ifneq
|
|
jbsr __Domain_error ; if not equal, domain error
|
|
endif
|
|
|
|
fmove.d y, fp0
|
|
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
|
|
ifneq
|
|
jbsr __Domain_error ; if not equal, domain error
|
|
endif
|
|
|
|
fmove.l #0,fpcr
|
|
fmove.d x,fp0
|
|
fmod.d y,fp0
|
|
fmove.l d0,fpcr
|
|
#endif
|
|
cEnd fmod
|