diff options
author | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
---|---|---|
committer | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
commit | e5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch) | |
tree | d8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/libc/386/memccpy.s |
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/libc/386/memccpy.s')
-rwxr-xr-x | sys/src/libc/386/memccpy.s | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/sys/src/libc/386/memccpy.s b/sys/src/libc/386/memccpy.s new file mode 100755 index 000000000..52af6a9cf --- /dev/null +++ b/sys/src/libc/386/memccpy.s @@ -0,0 +1,53 @@ + TEXT memccpy(SB),$0 + + MOVL n+12(FP), CX + CMPL CX, $0 + JEQ none + MOVL p2+4(FP), DI + MOVBLZX c+8(FP), AX + CLD +/* + * find the character in the second string + */ + + REPN; SCASB + JEQ found + +/* + * if not found, set count to 'n' + */ +none: + MOVL $0, AX + MOVL n+12(FP), BX + JMP memcpy + +/* + * if found, set count to bytes thru character + */ +found: + MOVL DI, AX + SUBL p2+4(FP), AX + MOVL AX, BX + ADDL p1+0(FP), AX + +/* + * copy the memory + */ + +memcpy: + MOVL p1+0(FP), DI + MOVL p2+4(FP), SI +/* + * copy whole longs + */ + MOVL BX, CX + SHRL $2, CX + REP; MOVSL +/* + * copy the rest, by bytes + */ + ANDL $3, BX + MOVL BX, CX + REP; MOVSB + + RET |