|
|
1.1 ! root 1: ////////// ! 2: / libc/string/i386/strrchr.s ! 3: / i386 C string library. ! 4: / ANSI 4.11.5.5. ! 5: ////////// ! 6: ! 7: ////////// ! 8: / char * ! 9: / strrchr(char *String, int Char) ! 10: / ! 11: / Find rightmost occurence of Char in String, return pointer or NULL. ! 12: / Previously known as rindex(); ! 13: / rindex() entry point retained for backward compatability. ! 14: ////////// ! 15: ! 16: String .equ 8 ! 17: Char .equ String+4 ! 18: ! 19: .globl strrchr ! 20: .globl rindex ! 21: ! 22: strrchr: ! 23: rindex: ! 24: push %esi ! 25: ! 26: movl %esi, String(%esp) / String address to ESI ! 27: movb %ah, Char(%esp) / Char to AH ! 28: subl %ecx, %ecx / Result = address of last match to ECX ! 29: cld ! 30: ! 31: ?loop: ! 32: lodsb / Fetch String char to AL ! 33: cmpb %al, %ah / and compare to Char ! 34: jne ?noteq / Mismatch ! 35: movl %ecx, %esi / Match, save address in ECX ! 36: ! 37: ?noteq: ! 38: orb %al, %al / Test for NUL ! 39: jne ?loop / Not done ! 40: jecxz ?done / End of string, no match, return NULL ! 41: decl %ecx / Back up to match ! 42: ! 43: ?done: ! 44: movl %eax, %ecx / Return pointer in EAX ! 45: ! 46: pop %esi ! 47: ret ! 48: ! 49: / end of libc/string/i386/strrchr.s
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.