|
|
1.1 ! root 1: ////////// ! 2: / libc/string/i386/strcat.s ! 3: / i386 C string library. ! 4: / ANSI 4.11.3.1., 4.11.3.2. ! 5: ////////// ! 6: ! 7: ////////// ! 8: / char * ! 9: / strcat(char *To, char *From) ! 10: / Append From to To. ! 11: / ! 12: / char * ! 13: / strncat(char *To, char *From, size_t Count) ! 14: / Append not more than Count characters (NOT including the NUL) from From to To. ! 15: / Always append a NUL. ! 16: ////////// ! 17: ! 18: To .equ 12 ! 19: From .equ To+4 ! 20: Count .equ From+4 ! 21: ! 22: .globl strcat ! 23: .globl strncat ! 24: ! 25: strncat: ! 26: movl %edx, Count-8(%esp) / Limit of move to EDX ! 27: orl %edx, %edx ! 28: jnz strcat0 / Fall in to common code ! 29: ret / Move nothing ! 30: ! 31: strcat: ! 32: movl %edx, $-1 / Max count to EDX ! 33: ! 34: strcat0: ! 35: push %esi ! 36: push %edi ! 37: ! 38: movl %esi, From(%esp) / From to ESI ! 39: movl %edi, To(%esp) / To to EDI ! 40: movl %ecx, $-1 / Max count to ECX ! 41: subb %al, %al / NUL to AL ! 42: cld ! 43: repne ! 44: scasb / Find end of To ! 45: decl %edi / and back up to NUL ! 46: movl %ecx, %edx / Count to ECX ! 47: ! 48: ?loop: ! 49: lodsb / Fetch From char to AL ! 50: stosb / and store through To ! 51: orb %al, %al ! 52: loopne ?loop / Count nonzero and NUL not seen, continue ! 53: je ?done / NUL has been copied, done ! 54: subb %al, %al / Count ran out before NUL found, ! 55: stosb / NUL-terminate the string ! 56: ! 57: ?done: ! 58: movl %eax, To(%esp) / Return the destination ! 59: ! 60: pop %edi ! 61: pop %esi ! 62: ret ! 63: ! 64: / end of libc/string/i386/strcat.s
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.