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

1.1     ! root        1: //////////
        !             2: / i8086 C string library internals.
        !             3: / _memxchg()
        !             4: / Exchange records of Count bytes pointed to by S1 and S2.
        !             5: //////////
        !             6: 
        !             7: //////////
        !             8: / void _memxchg(char *S1, char *S2, size_t Count)
        !             9: //////////
        !            10: 
        !            11: #include <larges.h>
        !            12: 
        !            13: S1     =       LEFTARG
        !            14: S2     =       S1+DPL
        !            15: Count  =       S2+DPL
        !            16: 
        !            17:        Enter(_memxchg_)
        !            18:        mov     cx, Count(bp)   / Count to CX
        !            19:        jcxz    2f              / Done if Count is 0
        !            20: 
        !            21:        Lds     si, S2(bp)      / S2 address to DS:SI
        !            22:        Les     di, S1(bp)      / S1 address to ES:DI
        !            23:        cld
        !            24:        shr     cx, $1          / Convert byte count to word count
        !            25:        jnc     1f              / Count even, skip byte exchange
        !            26: 
        !            27:        movb    al, Pes (di)    / S1 byte to AL
        !            28:        movsb                   / S2 byte to S1, bump DI and SI
        !            29:        movb    -1(si), al      / S1 byte to old S2
        !            30:        jz      2f              / Done if Count is 0
        !            31: 
        !            32: 1:
        !            33:        mov     ax, Pes (di)    / S1 word to AX
        !            34:        movs                    / S2 word to S1, bump DI and SI
        !            35:        mov     -2(si), ax      / S1 word to old S2
        !            36:        loop    1b              / Decrement byte count and repeat
        !            37: 
        !            38: 2:
        !            39:        Leave

unix.superglobalmegacorp.com

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