Category : C Source Code
Archive   : EMXLIB8C.ZIP
Filename : MEMCHR.S

 
Output of file : MEMCHR.S contained in archive : EMXLIB8C.ZIP
/ memchr.s (emx/gcc) -- Copyright (c) 1990-1992 by Eberhard Mattes

.globl _memchr

/ void *memchr (const void *s, int c, size_t n)
/ {
/ size_t i;
/ const char *p;
/
/ p = s;
/ for (i = 0; i < n; ++i)
/ if (p[i] == (char)c)
/ return ((void *)(p+i));
/ return (NULL);
/ }

/ assumes ds=es!

.text
.align 2, 0x90

_memchr:
pushl %edi
movl 2*4(%esp), %edi / s
movb 3*4(%esp), %al / c
movl 4*4(%esp), %ecx / n
jecxz 1f / not found
repne
scasb
jne 1f / not found
lea -1(%edi), %eax
popl %edi
ret

1: xorl %eax, %eax / return (NULL)
popl %edi
ret


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

  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/