/* This C language subroutine computes the histogram of its integer input. The Run Time Library for the C Language. Gordon A. Sterling (617) 461 - 3076 DSP Development Tools Engineering Created on 5/27/90 Updated on 5/94 by AS Updated on 1/95 by AS - separated polymorphic functions #include
int *histogram(int out[], int in[], int out_len, \ int samples, int bin_size); 1 level of DO loops */ #include "lib_glob.h" #include "sts_glob.h" .SEGMENT/CODE Code_Space_Name; .FILE RTL_FILENAME; .GLOBAL ___histogramDP; ___histogramDP: histo_core: put(R7); readparam5(R1); dm_pm: R0=R0-R0, dm_ptr=R4; /* The output array is */ /* set to zero by this */ LCNTR=R12, DO dpzero_array UNTIL LCE; /* loop. This histo*/ dpzero_array: DM(dm_ptr,dm_1)=R0; /* will add one to each */ /* bin value. */ F7=1.0; /* The reciprocal of the*/ CALL (PC, ___float_divide) (DB); /* bin size is computed*/ F11=F7+F7, put(R11); /* Each bin value will */ F12=FLOAT R1, readparam4(R2); /* be multiplied by this*/ /* reciprocal. */ R0=31; /* If the quotient is 1 */ R7=0x7fffffff; /* then the fractional */ R11=R1-1,pm_ptr=R8; /* quotient must be set */ IF NE R7=FIX F7 BY R0; /* to 0x7fffffff to */ /* avoid overflow of FIX*/ /* Point to input array */ R12=PASS R4, dm_ptr=R4; /* Point to output array*/ R1=PM(pm_ptr,pm_1); /* Read first input */ R8=R1*R7 (SSFR), R3=PM(pm_ptr,pm_1); /* Multiply by scale*/ R2=R2-1, dm_mdf=R8; /* Use for next modify */ R2=R2-1, R11=DM(dm_ptr,dm_mdf); /* Point to bin */ LCNTR=R2, DO dphisto_loop UNTIL LCE; /* Compute next bin, &*/ R0=R1*R7 (SSFR), R2=DM(dm_ptr,dm_0);/* rd the last count*/ R4=R0-R8, R1=PM(pm_ptr, pm_1); /* Compute bin offset */ R2=R2+1, dm_mdf=R4; /* Save current bin ptr */ dphisto_loop: R8=PASS R0, DM(dm_ptr,dm_mdf)=R2; /* and set modify for*/ /* next, increment count*/ R0=R1*R7 (SSFR), R2=DM(dm_ptr,dm_0); R5=R0-R8, dm_mdf=R8; R2=R2+1, dma_i=pm_ptr; DM(dm_ptr,dm_mdf)=R2; R2=PM(pm_ptr,pm_0); R2=R2+1, FETCH_RETURN PM(pm_ptr,pm_0)=R2; restore_state: R0=PASS R12, get(R11,1); /*Set return value*/ get(R7,2); RETURN (DB); RESTORE_STACK RESTORE_FRAME .ENDSEG;