/* 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 ___histogramPP; ___histogramPP: histo_core: put(R7); readparam5(R1); pm_pm: R0=R0-R0, pm_ptr=R4; /* The output array is */ /* set to zero by this */ LCNTR=R12, DO ppzero_array UNTIL LCE; /* loop. This histo*/ ppzero_array: PM(pm_ptr,pm_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, dm_ptr=pma_i; /* quotient must be set */ IF NE R7=FIX F7 BY R0; /* to 0x7fffffff to */ /* avoid overflow of FIX*/ pma_i=R8; /* Point to input array */ R12=PASS R4, pm_ptr=R4; /* Point to output array*/ R1=PM(pma_i,pm_1); /* Read first input */ R8=R1*R7 (SSFR), R3=PM(pma_i,pm_1); /* Multiply by scale*/ R2=R2-1, pm_mdf=R8; /* Use for next modify */ R2=R2-1, R11=PM(pm_ptr,pm_mdf); /* Point to bin */ LCNTR=R2, DO ddhisto_loop UNTIL LCE; /* Compute next bin, &*/ R0=R1*R7 (SSFR), R2=PM(pm_ptr,pm_0);/* rd the last count*/ R4=R0-R8, R1=PM(pma_i, pm_1); /* Compute bin offset */ R2=R2+1, pm_mdf=R4; /* Save current bin ptr */ ddhisto_loop: R8=PASS R0, PM(pm_ptr,pm_mdf)=R2; /* and set modify for*/ /* next, increment count*/ R0=R1*R7 (SSFR), R2=PM(pm_ptr,pm_0); R5=R0-R8, pm_mdf=R8; R2=R2+1, pma_i=dm_ptr; PM(pm_ptr,pm_mdf)=R2; R2=PM(pm_ptr,pm_0); R2=R2+1, get(R11,1); PM(pm_ptr,pm_0)=R2; restore_state: R0=PASS R12, FETCH_RETURN /*Set return value*/ get(R7,2); RETURN (DB); RESTORE_STACK RESTORE_FRAME .ENDSEG;