/* This C language subroutine seperates the integer part of a floating point number from its fractional part. The Run Time Library for the C Language. Gordon A. Sterling (617) 461 - 3076 DSP Development Tools Engineering Created on 04/25/90 Updated on 6/94 by AS Updated on 2/95 by AS - separated polymorphic functions #include
double modf(double x, double *iptr); */ #include "lib_glob.h" #include "mth_glob.h" .SEGMENT/CODE Code_Space_Name; .FILE RTL_FILENAME; .GLOBAL _modf; .GLOBAL ___modfD; _modf: ___modfD: modf_core: put(R5); R6=R6-R6, put(R6); /* Zero R6 and add until*/ R6=R6+1, put(R7); /* you get a 4 in there */ R6=R6+R6, reads(R4,1); R6=R6+R6, reads(R8,2); R5=PASS R8, reads(R12,3); R1=FEXT R4 BY 20:11; /*Extract biased exponent*/ R0=D_EXP_BIAS; R1=R1-R0, R2=R12; /*Compute unbiased exponent*/ IF LT JUMP (PC, all_fraction); R0=52; COMP(R1,R2), dm_ptr=R2; /*save R2 for later */ IF GT JUMP (PC, no_fraction); R8=0xFFFFFFFF; R0=R0-R1, dm_mdf=R6; /* put a 4 in m reg for modify later*/ R7=ASHIFT R8 BY R0; /*Determine mask */ R7=R5 AND R7; /*R7 holds LSW integer part only*/ R0=20; R0=R0-R1; R8=ASHIFT R8 BY R0; R6=R4 AND R8, put(R7); /*R6 holds MSW int part only*/ put(R6); /*Store LSW of integer */ R5=PASS R2, put(R5); /*save R2 in compiler reg (R5)*/ put(R4); CALLER_HOLD(R0) CALLER_SWAP RTLCALL (PC, ___dsub) (DB); /* Does not alter dm_ptr*/ SAVE_OLD_FRAME(R0) SAVE_RET_ADDR R2=PASS R5, MODIFY (I7, dm_mdf); /* restore from pushes made*/ dm_write: dm_ptr=R2; DM(dm_ptr,1)=R6; DM(dm_ptr,0)=R7; restore_state: FETCH_RETURN get(R7,1); get(R6,2); get(R5,3); RETURN (DB); RESTORE_STACK RESTORE_FRAME no_fraction: JUMP (PC, dm_write) (DB); R0=R0-R0, R6=R4; R1=R1-R1, R7=R5; all_fraction: JUMP (PC, dm_write) (DB); R6=R6-R6, R0=R4; R7=R7-R7, R1=R5; .ENDSEG;