;/*** ;*fabs.a - ;* ;* Copyright (c) 1991-91, Microsoft Corporation ;* ;*Purpose: ;* ;* ;*Revision History: ;* ;* 05-12-92 PLM written ;*/ ; ;/*** ;*double fabs(double x) ;* ;*Purpose: ;* Absolute value ;* ;*Entry: ;* ;*Exit: ;* ;*Exceptions: ;*******************************************************************************/ ; ; ;double fabs(double x) #include #include #include cProc fabs,PUBLIC parmQ x localV xlocalx,10 localD fpstat cBegin fabs #ifdef SANE 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 xlocalx move.w #FOABS,-(a7) FP68K ;absolute value 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 ;save current control word 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 else fmove.l #0,fpcr fabs.d x,fp0 ;absolute value endif fmove.l d0,fpcr ;restore control word #endif cEnd fabs