Faster C

William G. Fish fish at aati.UUCP
Fri Feb 5 07:15:07 AEST 1988


I wish to make the following C code run as fast as possible under 4.1 BSD 
on a VAX 11/750.  I've seen VAX instructions such as movc3 and cmpc3 make
code run 10 to 50 times faster.  Are there any CISC instructions that can
be used in this case?

scan(in, out, c, C, S)
    register short *in;
    register float *out;
    register c;
    int C, S;
{
    register sample;
    register peak;
    register s;

    for (s = 0; s < S; s++, c += C)
    {
	out[s] = sample = in[c];	/* short to float conversion */
	if (sample < 0)
	    sample = -sample;		/* absolute value */
	if (peak < sample)
	    peak = sample;		/* peak detection */
    }
    return peak;
}
--
Bill Fish                       Analysis & Technology
321 River Road                  153 Williams Street
Mystic, CT 06355                New London, CT 06320
(203) 536-3301 (evenings)       (203) 444-7722 (days)
(203) 536-0137 (2nd line)       ihnp4!{hsi,rayssd}!aati!fish



More information about the Comp.lang.c mailing list