Annotation of coherent/b/lib/libc/string/i8086/strncat.m, revision 1.1.1.1

1.1       root        1: //////////
                      2: / i8086 C string library.
                      3: / strncat()
                      4: / ANSI 4.11.3.2.
                      5: //////////
                      6: 
                      7: //////////
                      8: / char *
                      9: / strncat(To, From, Count)
                     10: / char *To, *From;
                     11: / int Count;
                     12: /
                     13: / Append not more than Count characters (NOT including the NUL) from From to To.
                     14: / Always append a NUL.
                     15: //////////
                     16: 
                     17: #include <larges.h>
                     18: 
                     19: To     =       LEFTARG
                     20: From   =       To+DPL
                     21: Count  =       From+DPL
                     22: 
                     23:        Enter(strncat_)
                     24:        Les     di, To(bp)      / To address to ES:DI
                     25:        mov     cx, $-1         / Max count to CX
                     26:        sub     ax, ax
                     27:        cld
                     28:        repne
                     29:        scasb                   / Find end of To
                     30:        dec     di              / and back up ES:DI to point at NUL
                     31: 
                     32:        mov     cx, Count(bp)   / Limit of move (not limit of result) to CX
                     33:        or      cx, cx
                     34:        je      2f              / Move nothing
                     35:        Lds     si, From(bp)    / From address to DS:SI
                     36: 
                     37: 1:     lodsb                   / Fetch from From
                     38:        stosb                   / and store to To
                     39:        orb     al, al
                     40:        loopne  1b              / Count nonzero and NUL not seen yet, continue
                     41:        je      2f              / NUL has been copied, done
                     42:        subb    al, al          / Count ran out before NUL found,
                     43:        stosb                   / NUL-terminate the string
                     44: 
                     45: 2:     mov     ax, To(bp)      / Return the destination
                     46: #if    LARGEDATA
                     47:        mov     dx, es
                     48: #endif
                     49:        Leave

unix.superglobalmegacorp.com

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