/* This C language subroutine provides support for the double and long double types of the language. The double precision representation is a two word 64-bit format, identical to IEEE 754 double. The long double is the same as the double. The Run Time Library for the C Language. Gordon A. Sterling (617) 461 - 3076 DSP Development Tools Engineering Created on 6/14/90 Updated on 5/94 by AS long double ___ldmult(long double x, long double y); double ___dmult(double x, double y); long_double ___lddiv(long double num, long double denom); double ___ddiv(double num, double denom); long double ___ldadd(long double x, long double y); double ___dadd(double x, double y); long double ___ftold(float x); double ___ftod(float x); long double ___xtod(fract x); double ___xtod(float x); long double ___itold(int i); double ___itod(int i); MMH: added entry points for GCC divdf3, muldf3, adddf3, extendsfdf2, floatsidf */ #include "lib_glob.h" #include "dbl_glob.h" #include "flt_glob.h" .SEGMENT/CODE Code_Space_Name; .FILE RTL_FILENAME; .GLOBAL ___dmult, ___ldmult; .GLOBAL ___ddiv, ___lddiv; .GLOBAL ___dadd, ___ldadd; .GLOBAL ___ftod, ___ftold; .GLOBAL ___xtod, ___xtold; .GLOBAL ___itod, ___itold; .GLOBAL ___divdf3, ___muldf3, ___adddf3; .GLOBAL ___extendsfdf2, ___floatsidf; ___muldf3: ___ldmult: ___dmult: R2=MR2F; put(R2); R2=MR1F; put(R2); R2=MR0F; put(R2); put(R3); put(R5); put(R6); put(R7); put(R9); put(R10); put(R11); put(R13); put(R14); put(R15); reads(R14,1); reads(R15,2); CALL (PC, ___lib_dmult) (DB); /*Used library routine*/ reads(R12,3); reads(R13,4); /*Read Y mantissa*/ restore_state2: get(R15,1); get(R14,2); get(R13,3); get(R11,4); get(R10,5); get(R9,6); get(R7,7); get(R6,8); get(R5,9); get(R2,11); FETCH_RETURN MR0F=R2, get(R2,12); MR1F=R2, get(R2,13); MR2F=R2, get(R3,10); RETURN (DB); RESTORE_STACK RESTORE_FRAME restore_state: get(R15,1); get(R14,2); get(R13,3); get(R11,4); get(R10,5); get(R9,6); get(R7,7); get(R6,8); get(R5,9); FETCH_RETURN get(R3,10); RETURN (DB); RESTORE_STACK RESTORE_FRAME ___divdf3: ___lddiv: ___ddiv: R2=MR2F; put(R2); R2=MR1F; put(R2); R2=MR0F; put(R2); put(R3); put(R5); put(R6); put(R7); put(R9); put(R10); put(R11); put(R13); put(R14); put(R15); reads(R4,1); reads(R8,2); reads(R12,3); R7=PASS R4, R11=R8; /* Hold these values for later*/ R14=PASS R12, reads(R15,4); /*Read lower word of denom*/ R10=D_EXP_BIAS; /*Take recip of 0 exp number*/ R12=FEXT R14 BY 20:11; /*Extract biased exponent*/ R0=FEXT R14 BY 0:20; /*Copy mantissa*/ CALL (PC, ___lib_dtof) (DB); /*Convert to flt for recip*/ R0=R0 OR LSHIFT R10 BY 20; /*Place exponent*/ F0=F0 COPYSIGN F14, F1=F15; /*Copy sign*/ CALL (PC, ___lib_ftod) (DB); /*Convert back to dbl*/ F0=RECIPS F0; /*Get flt recip*/ R12=R12-R10; /*Compute unbiased exponent*/ R10=FEXT R0 BY 20:11; /*Extract exponent*/ R10=R10-R12; IF LT JUMP (PC, underflow); R9=D_MAX_BIASED_EXP; COMP(R10,R9); IF GT JUMP (PC, overflow); R12=FEXT R0 BY 0:20; /*Copy mantissa*/ CALL (PC, ___lib_dmult) (DB); /*Compute D'=D*R0*/ R12=R12 OR LSHIFT R10 BY 20; F12=F12 COPYSIGN F0, F13=F1; R8=D_TWO_MSW; /*Prepare for divide*/ R9=D_TWO_LSW; /* by loading a 2.0*/ CALL (PC, ___lib_dmult) (DB); /*Compute N*R0*/ R10=PASS R0, R14=R7; /*Read MSW of num*/ R11=PASS R1, R15=R11; /*Read LSW of num*/ R14=PASS R8, R15=R9; /*Load 2.0*/ CALL (PC, ___lib_dsub) (DB); /*Compute R1=2-D'*/ R6=PASS R0, R7=R1; /*Save N*R0*/ R12=PASS R10, R13=R11; /*Load D'*/ CALL (PC, ___lib_dmult) (DB); /*Compute N*R0*R1*/ R14=PASS R6, R15=R7; /*Load N*R0*/ R12=PASS R0, R13=R1; /*Load R1*/ CALL (PC, ___lib_dmult) (DB); /*Compute D'=D'*R1*/ R6=PASS R0, R7=R1; /*Save N*R0*R1*/ R14=PASS R10, R15=R11; /*Load D'*/ R14=PASS R8, R15=R9; /*Load 2.0*/ CALL (PC, ___lib_dsub) (DB); /*Compute R2=2-D'*/ R10=PASS R0, R11=R1; /*Save D'*/ R12=PASS R0, R13=R1; /*Move D'*/ CALL (PC, ___lib_dmult) (DB); /*Compute N*R0*R1*R2*/ R14=PASS R6, R15=R7; /*Load N*R0*R1*/ R12=PASS R0, R13=R1; /*Load R2*/ CALL (PC, ___lib_dmult) (DB); /*Compute D'=D'*R2*/ R6=PASS R0, R7=R1; /*Save N*R0*R1*R2*/ R14=PASS R10, R15=R11; /*Load D'*/ R14=PASS R8, R15=R9; /*Load 2.0*/ CALL (PC, ___lib_dsub) (DB); /*Compute R3=2-D'*/ R10=PASS R0, R11=R1; /*Save D'*/ R12=PASS R0, R13=R1; /*Move D'*/ CALL (PC, ___lib_dmult) (DB); /*Compute N*R0*R1*R2*R3*/ R14=PASS R6, R15=R7; /*Load N*R0*R1*R2*/ R12=PASS R0, R13=R1; /*Load R3*/ CALL (PC, ___lib_dmult) (DB); /*Compute D'=D'*R3*/ R6=PASS R0, R7=R1; /*Save N*R0*R1*R2*R3*/ R14=PASS R10, R15=R11; /*Load D'*/ R14=PASS R8, R15=R9; /*Load 2.0*/ CALL (PC, ___lib_dsub) (DB); /*Compute R4=2-D'*/ R10=PASS R0, R11=R1; /*Save D'*/ R12=PASS R0, R13=R1; /*Move D'*/ CALL (PC, ___lib_dmult) (DB); /*Compute N*R0*R1*R2*R3*R4*/ R14=PASS R6, R15=R7; /*Load N*R0*R1*R2*R3*/ R12=PASS R0, R13=R1; /*Load R4*/ CALL (PC, ___lib_dmult) (DB); /*Compute D'=D'*R4*/ R6=PASS R0, R7=R1; /*Save N*R0*R1*R2*R3*R4*/ R14=PASS R10, R15=R11; /*Load D'*/ R14=PASS R8, R15=R9; /*Load 2.0*/ CALL (PC, ___lib_dsub) (DB); /*Compute R5=2-D'*/ R10=PASS R0, R11=R1; /*Save D'*/ R12=PASS R0, R13=R1; /*Move D'*/ CALL (PC, ___lib_dmult) (DB); /*Compute N*R0*R1*R2*R3*R4*R5*/ R14=PASS R6, R15=R7; /*Load N*R0*R1*R2*R3*R4*/ R12=PASS R0, R13=R1; /*Load R5*/ /*Should be 96-bits accurate*/ /*All jump to restore_state2 */ overflow: /*Also set HUGEVAL*/ underflow: JUMP (PC, restore_state2); /*Also set 0*/ ___adddf3: ___ldadd: ___dadd: put(R3); put(R5); put(R6); put(R7); put(R9); put(R10); put(R11); put(R13); put(R14); put(R15); reads(R14,1); reads(R15,2); CALL (PC, ___lib_dadd) (DB); /*Compute X+Y*/ reads(R12,3); reads(R13,4); /*Read Y LSW*/ JUMP (PC, restore_state); ___extendsfdf2: ___ftold: ___ftod: CALL (PC, ___lib_ftod) (DB); R0=PASS R4, put(R3); FETCH_RETURN get(R3,1); RETURN (DB); RESTORE_STACK RESTORE_FRAME ___xtold: ___xtod: CALL (PC, ___lib_xtod) (DB); R0=PASS R4, put(R3); FETCH_RETURN get(R3,1); RETURN (DB); RESTORE_STACK RESTORE_FRAME ___floatsidf: ___itold: ___itod: CALL (PC, ___lib_itod) (DB); R0=PASS R4, put(R3); FETCH_RETURN get(R3,1); RETURN (DB); RESTORE_STACK RESTORE_FRAME .ENDSEG;