diff options
Diffstat (limited to 'rgo/src/memfill.S')
-rw-r--r-- | rgo/src/memfill.S | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/rgo/src/memfill.S b/rgo/src/memfill.S index d131c48..c22547e 100644 --- a/rgo/src/memfill.S +++ b/rgo/src/memfill.S @@ -15,24 +15,39 @@ .global rgo_memfill rgo_memfill: -#if defined(__x86_64__) /* - rdi: void const * ptr - rsi: size_t num - dl: int_least8_t val + void const * ptr + size_t num + uint8_t val */ - /* We don't need to preserve any of the registers we use according to the ABI. */ - /* rcx: Address of the current element. */ +#if defined(__i386__) + /* eax: Address of the current element. */ + movl 0x4(%esp),%eax + /* ecx: Address of the element after the last element. */ + movl 0x4(%esp),%ecx + addl 0x8(%esp),%ecx + /* rdx: Byte value. */ + movb 0xC(%esp),%dl +.loop: + cmpl %eax,%ecx + je .done /* Exit loop if we have reached the final element. */ + movb %dl,(%eax) + incl %eax + jmp .loop /* Continue to next element. */ +.done: + ret +#elif defined(__x86_64__) + /* rax: Address of the current element. */ + movq %rdi,%rax + /* rax: Address of the element after the last element. */ movq %rdi,%rcx - /* rcx: Address of the element after the last element. */ - movq %rdi,%r8 - addq %rsi,%r8 + addq %rsi,%rcx .loop: - cmpq %r8,%rcx + cmpq %rcx,%rax je .done /* Exit loop if we have reached the final element. */ - movb %dl,(%rcx) - incq %rcx /* Continue to next element. */ - jmp .loop + movb %dl,(%rax) + incq %rax + jmp .loop /* Continue to next element. */ .done: ret #endif |