Annotation of coherent/b/lib/libc/string/i8086/memccpy.s, revision 1.1.1.1

1.1       root        1: ////////
                      2: /
                      3: / #include <string.h>
                      4: /
                      5: / char *
                      6: / memccpy(dest, src, c, n)
                      7: / char *dest, *src;
                      8: /
                      9: /      Action: Copy characters from memory area src into dest, stopping
                     10: /              after  the first occurrence of  character C has  been
                     11: /              been copied, or after N characters have been copied.
                     12: /
                     13: /      Return: A pointer to the character after the copy of C in dest,
                     14: /              or a NULL pointer  if C was not found  in the first N
                     15: /              characters of src.
                     16: ////////
                     17:        .globl  memccpy_
                     18: 
                     19: memccpy_:                              / char *
                     20:        push    si                      / memccpy ( dest, src, c, n )
                     21:        push    di                      /
                     22:        mov     bx, sp                  / char *dest, *src;
                     23:        movb    al, 10(bx)              / register int c;               /* AX */
                     24:        mov     dx, 12(bx)              / register unsigned n;          /* DX */
                     25:                                        /
                     26:        mov     di, 8(bx)               / {     register char *cp = src; /* DI */
                     27:        mov     cx, dx                  /       register cnt = n;       /* CX */
                     28:                                        /
                     29:        jcxz    0f                      /       for (; cnt != 0; --cnt)
                     30:        cld                             /               if (*cp++ == c)
                     31:        repne                           /                       break;
                     32:        scasb                           /
                     33:        jne     0f                      /       if (cp[-1] == c)
                     34:        sub     dx, cx                  /       {       n  -= cnt;
                     35:        mov     cx, di                  /
                     36:        sub     cx, 8(bx)               /               cnt = cp - src + dest;
                     37:        add     cx, 6(bx)               /       }
                     38: 0:     mov     ax, cx                  /       c = cnt;
                     39:        mov     si, 8(bx)               /
                     40:        mov     di, 6(bx)               /
                     41:        mov     cx, dx                  /       for ( cnt = n; cnt != 0; --cnt)
                     42:        rep                             /               *dest++ = *src++;
                     43:        movsb                           /
                     44:        pop     di                      /       return c;
                     45:        pop     si                      / }
                     46:        ret

unix.superglobalmegacorp.com

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