/* This C language subroutine scales a floating point number by an 2^x The Run Time Library for the C Language. Gordon A. Sterling (617) 461 - 3076 DSP Development Tools Engineering Created on 04/22/90 Updated on 5/94 by AS #include
double ldexp(double x, int exp); */ #include "lib_glob.h" #include "mth_glob.h" .SEGMENT/CODE Code_Space_Name; .FILE RTL_FILENAME; .GLOBAL _ldexp; _ldexp: reads(R4,1); reads(R8,2); reads(R12,3); R1=FEXT R4 BY 20:11; /*Extract biased exponent*/ R1=R1+R12, FETCH_RETURN /*Add scale factor*/ R2=D_MAX_BIASED_EXP; /*Check for maximum exp*/ COMP(R1,R2), R12=R1; IF GT JUMP (PC, overflow); R2=0x800FFFFF; R0=R4 AND R2, R1=R8; R0=R0 OR LSHIFT R12 BY 20; /*Place exponent bits*/ restore_state: RETURN (DB); RESTORE_STACK RESTORE_FRAME overflow: R1=HUGE_VAL_LSW; JUMP (PC, restore_state) (DB); R2=HUGE_VAL_MSW; F0=F2 COPYSIGN F0; .ENDSEG;