Annotation of coherent/b/lib/libc/string/i8086/memchr.m, revision 1.1

1.1     ! root        1: //////////
        !             2: / i8086 C string library.
        !             3: / memchr()
        !             4: / ANSI 4.11.5.1.
        !             5: //////////
        !             6: 
        !             7: //////////
        !             8: / char *
        !             9: / memchr(String, Char, Count)
        !            10: / char *String;
        !            11: / int Char, Count;
        !            12: /
        !            13: / Find Char in String, return pointer or NULL.
        !            14: //////////
        !            15: 
        !            16: #include <larges.h>
        !            17: 
        !            18: String =       LEFTARG
        !            19: Char   =       String+DPL
        !            20: Count  =       Char+2
        !            21: 
        !            22:        Enter(memchr_)
        !            23:        mov     cx, Count(bp)   / Count to CX
        !            24:        or      cx, cx
        !            25:        je      1f              / No match possible in first 0 characters
        !            26:        Les     di, String(bp)  / String address to ES:SI
        !            27:        movb    al, Char(bp)    / Char to AL
        !            28:        cld
        !            29:        repne
        !            30:        scasb                   / Look for character
        !            31:        je      2f              / Matched
        !            32: 
        !            33: 1:     sub     ax, ax          / No match, return NULL
        !            34: #if    LARGEDATA
        !            35:        mov     dx, ax
        !            36: #endif
        !            37:        jmp     3f
        !            38: 
        !            39: 2:     dec     di              / Back up to match
        !            40:        mov     ax, di          / AX = offset
        !            41: #if    LARGEDATA
        !            42:        mov     dx, es          / DX = segment
        !            43: #endif
        !            44: 
        !            45: 3:     Leave

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.