|
|
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: ////////// ! 14: ! 15: String .equ 8 ! 16: Char .equ String+4 ! 17: ! 18: .globl strrchr ! 19: ! 20: strrchr: ! 21: push %esi ! 22: ! 23: movl %esi, String(%esp) / String address to ESI ! 24: movb %ah, Char(%esp) / Char to AH ! 25: subl %ecx, %ecx / Result = address of last match to ECX ! 26: cld ! 27: ! 28: ?loop: ! 29: lodsb / Fetch String char to AL ! 30: cmpb %al, %ah / and compare to Char ! 31: jne ?noteq / Mismatch ! 32: movl %ecx, %esi / Match, save address in ECX ! 33: ! 34: ?noteq: ! 35: orb %al, %al / Test for NUL ! 36: jne ?loop / Not done ! 37: jecxz ?done / End of string, no match, return NULL ! 38: decl %ecx / Back up to match ! 39: ! 40: ?done: ! 41: movl %eax, %ecx / Return pointer in EAX ! 42: ! 43: pop %esi ! 44: ret ! 45: ! 46: / 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.