diff options
Diffstat (limited to 'rgo/src/fndbyte.S')
-rw-r--r-- | rgo/src/fndbyte.S | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/rgo/src/fndbyte.S b/rgo/src/fndbyte.S index c0e4382..4d1e482 100644 --- a/rgo/src/fndbyte.S +++ b/rgo/src/fndbyte.S @@ -20,7 +20,33 @@ rgo_fndbyte: size_t num uint8_t byte */ -#if defined(__x86_64__) +#if defined(__i386__) + /* eax: Address of the current element. */ + movl 0x4(%esp),%eax + /* ecx: Address of the element after the last element. */ + movl 0x8(%esp),%ecx + addl %eax,%ecx + /* edx: Byte value. */ + movb 0xC(%esp),%dl + /* ebx: Current element. */ + pushl %ebx +.loop: + cmpl %eax,%ecx + je .nfnd /* We have went through the entire array without finding the byte. */ + movb (%eax),%bl + cmpb %bl,%dl + je .fnd /* We have found the byte. */ + incl %eax + jmp .loop +.fnd: + popl %ebx + subl 0x4(%esp),%eax + ret +.nfnd: + popl %ebx + movl $0xFFFFFFFF,%eax + ret +#elif defined(__x86_64__) /* rax: Address of the current element. */ movq %rdi,%rax /* rsi: Address of the element after the last element. */ |