diff options
Diffstat (limited to 'rgo/src/strlen.S')
-rw-r--r-- | rgo/src/strlen.S | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/rgo/src/strlen.S b/rgo/src/strlen.S index d7ad03e..37b5780 100644 --- a/rgo/src/strlen.S +++ b/rgo/src/strlen.S @@ -18,7 +18,22 @@ rgo_strlen: /* char const * str */ -#if defined(__x86_64__) +#if defined(__i386__) + /* eax: Address of the current character. */ + movl 0x4(%esp),%eax + /* ecx: Address of the first character. */ + movl %eax,%ecx + /* edx: Current character. */ +.loop: + movb (%eax),%dl + testb %dl,%dl + jz .done /* Exit loop if we have reached the null-terminator. */ + incl %eax /* Continue to the next character. */ + jmp .loop +.done: + subl %ecx,%eax + ret +#elif defined(__x86_64__) /* rax: Address of the current character. */ movq %rdi,%rax /* rdx: Current character. */ |