diff options
| author | Miquel Sabaté Solà <mikisabate@gmail.com> | 2024-11-26 22:27:02 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <mikisabate@gmail.com> | 2024-11-26 22:27:02 +0100 |
| commit | fa8f9e9f44d47f5b2d0b4cc6a2cc8f328e0caa80 (patch) | |
| tree | 46dea3fa328b013d1d9bd021d2afea2fa9b69c30 /kernel/string.S | |
| parent | 87d1a2597ceedd03a7d4005db1bf82b72b423a18 (diff) | |
| download | fbos-fa8f9e9f44d47f5b2d0b4cc6a2cc8f328e0caa80.tar.gz fbos-fa8f9e9f44d47f5b2d0b4cc6a2cc8f328e0caa80.zip | |
Move 'memcpy' to assembly
And apparently 'memmove' is not needed anymore, so we dodged a bullet
there.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'kernel/string.S')
| -rw-r--r-- | kernel/string.S | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/kernel/string.S b/kernel/string.S index 4fb1ccc..271e8f3 100644 --- a/kernel/string.S +++ b/kernel/string.S @@ -51,7 +51,7 @@ strcmp: * int memcmp(const void *ptr1, const void *ptr2, size_t n) * * Returns (a0): comparison result as in stdlib. - * Parameter (a0, a1): strings to compare. + * Parameters (a0, a1): strings to compare. * Clobbers: t0, t1. */ .global memcmp @@ -70,3 +70,28 @@ memcmp: 2: sub a0, t0, t1 ret + +/* + * Defined in include/fbos/string.h + * + * void memcpy(const void *dest, const void *src, size_t count) + * + * Parameter a0: destination string. + * Parameter a1: source string. + * Parameter a2: number of bytes to copy. + * Clobbers: t0. + */ +.global memcpy +.type memcpy, @function +memcpy: +1: + beqz a2, 3f +2: + lbu t0, 0(a1) + sb t0, 0(a0) + addi a0, a0, 1 + addi a1, a1, 1 + addi a2, a2, -1 + bnez a2, 2b +3: + ret |
