Category : C Source Code
Archive   : ECSTR.ZIP
Filename : MEMCHR.C

 
Output of file : MEMCHR.C contained in archive : ECSTR.ZIP
/* File : memchr.c
Author : Richard A. O'Keefe.
Updated: 25 May 1984
Defines: memchr()

memchr(src, chr, len)
searches the memory area pointed to by src extending for len bytes,
looking for an occurrence of the byte value chr. It returns NullS
if there is no such occurrence. Otherwise it returns a pointer to
the FIRST such occurrence.

See the "Character Comparison" section in the READ-ME file.
*/

#include "strings.h"

#if VaxAsm

char *memchr(src, chr, len)
char *src;
char chr;
int len;
{
asm("locc 8(ap),12(ap),*4(ap)");
asm("bneq L1");
asm("movl r1,r0");
asm("L1: ret");
}

#else ~VaxAsm

char *memchr(src, chr, len)
register char *src;
register int chr; /* should be char */
register int len;
{
while (--len >= 0)
if (*src++ == chr) return src-1;
return NullS;
}

#endif VaxAsm



  3 Responses to “Category : C Source Code
Archive   : ECSTR.ZIP
Filename : MEMCHR.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/