/* This C language subroutine computes the value of the smallest integer greater then or equal to the input. The Run Time Library for the C Language. Gordon A. Sterling (617) 461 - 3076 DSP Development Tools Engineering Created on 4/28/90 upgraded on 5/94 by AS #include
float ceilf(float x); */ #include "lib_glob.h" #include "mth_glob.h" .SEGMENT/CODE Code_Space_Name; .FILE RTL_FILENAME; .GLOBAL _ceilf; _ceilf: F8=1.0; /*Used later*/ R0=31; /*Used for exponent test*/ R12=LOGB F4; /*Extract exponent of input*/ COMP(R12,R0), F1=F4; /*If greater then 31, return*/ IF GT JUMP (PC, restore_state) (DB); /*Input contains no fractional part*/ FETCH_RETURN R2=R2-R2; IF EQ F2=SCALB F8 BY R12; /*Must remove an MSB of input if big exp*/ F2=F2 COPYSIGN F4; /*Get sign of input into F3 */ F1=F4-F2; /*Subtract scale (sometimes 0)*/ R0=FIX F1; /*Convert to fixed point*/ F1=FLOAT R0; /*Refloat R0*/ F0=F1+F2; /*Add back scale if necessary*/ F4=F4-F0; /*Find sign of input*/ IF GT F0=F0+F8; /*Add 1 if input was positive*/ restore_state: RETURN (DB); RESTORE_STACK RESTORE_FRAME .ENDSEG;