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.
75 lines
1.4 KiB
75 lines
1.4 KiB
;/***
|
|
;*ceil.a -
|
|
;*
|
|
;* Copyright (c) 1991-91, Microsoft Corporation
|
|
;*
|
|
;*Purpose:
|
|
;*
|
|
;*
|
|
;*Revision History:
|
|
;*
|
|
;* 05-12-92 PLM written
|
|
;*/
|
|
;
|
|
;/***
|
|
;*double ceil(double x) - round to next highest integer
|
|
;*
|
|
;*Purpose:
|
|
;* Round to integer according to next highest integer.
|
|
;*
|
|
;*Entry:
|
|
;*
|
|
;*Exit:
|
|
;*
|
|
;*Exceptions:
|
|
;*******************************************************************************/
|
|
;
|
|
;
|
|
;double ceil(double x)
|
|
|
|
#include <traps.a>
|
|
#include <sane.a>
|
|
#include <trans.a>
|
|
|
|
|
|
cProc _CIceil,PUBLIC
|
|
localD fpstat
|
|
cBegin _CIceil
|
|
#ifdef SANE
|
|
movem.l <d0/d1>, -(a7)
|
|
pea fpstat ;get current control word
|
|
move.w #FOGETENV,-(a7)
|
|
FP68K
|
|
|
|
move.w fpstat,d0 ;save current control word
|
|
move.w #IRC_UP,fpstat ;set sounding to up
|
|
pea fpstat ;set new control word
|
|
move.w #FOSETENV,-(a7)
|
|
FP68K
|
|
|
|
move.l a0, -(a7)
|
|
move.w #FORTI,-(a7)
|
|
FP68K ;round result
|
|
|
|
move.w d0,fpstat ;restore control word
|
|
pea fpstat
|
|
move.w #FOPROCEXIT,-(a7)
|
|
FP68K
|
|
movem.l (a7)+, <d0/d1>
|
|
#else
|
|
fmove.l fpcr,d0 ;save current control word
|
|
|
|
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 #IRC_UP,fpcr ;set rounding mode to up
|
|
fint.x fp0 ;round it up
|
|
endif
|
|
fmove.l d0,fpcr ;restore control word
|
|
#endif
|
|
cEnd _CIceil
|
|
|