|
|
1.1 ! root 1: ////////// ! 2: / libc/string/i386/_memxchg.s ! 3: / i386 C string library. ! 4: / Not in ANSI C standard. ! 5: ////////// ! 6: ! 7: ! 8: ////////// ! 9: / void _memxchg(char *S1, char *S2, size_t Count) ! 10: / ! 11: / Exchange records of Count bytes pointed to by S1 and S2. ! 12: / Copies first by dwords, then by words, then by bytes, for efficiency; ! 13: / does not try to align the arguments. ! 14: ////////// ! 15: ! 16: S1 .equ 12 ! 17: S2 .equ S1+4 ! 18: Count .equ S2+4 ! 19: ! 20: .globl _memxchg ! 21: ! 22: _memxchg: ! 23: push %esi ! 24: push %edi ! 25: ! 26: movl %ecx, Count(%esp) / Count to ECX ! 27: movl %esi, S2(%esp) / S2 address to ESI ! 28: movl %edi, S1(%esp) / S1 address to EDI ! 29: cld ! 30: movl %edx, %ecx / Save Count in EDX ! 31: shrl %ecx, $2 / Convert byte count to dword count ! 32: jz ?word / No dwords to move ! 33: ! 34: ?dword: ! 35: movl %eax, (%edi) / S1 dword to EAX ! 36: movsl / S2 dword to S1, bump EDI and ESI ! 37: movl -4(%esi), %eax / S1 word to old S2 ! 38: loop ?dword / Decrement dword count and repeat ! 39: ! 40: ?word: ! 41: jnc ?byte / No word move, CF is set from shrl above ! 42: movw %ax, (%edi) / S1 word to AX ! 43: movsw / S2 word to S1, bump EDI and ESI ! 44: movw -2(%esi), %ax / S1 word to old S2 ! 45: ! 46: ?byte: ! 47: shrl %edx, $1 / Check bit 0 of Count ! 48: jnc ?done / No byte move ! 49: movb %al, (%edi) / S1 byte to AL ! 50: movsb / S2 byte to S1, bump EDI and ESI ! 51: movb -1(%esi), %al / S1 byte to old S2 ! 52: ! 53: ?done: ! 54: pop %edi ! 55: pop %esi ! 56: ret ! 57: ! 58: / end of libc/string/i386/_memxchg.s
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.