Backport of fix from asynchvfs branch for PM-LOG-VFS-PM deadlock that resulted in...
[minix3-old.git] / lib / i86 / string / memset.s
bloba36a31a33beaa38d5902b57ee869f371276e4e2b
1 ! memset() Author: Kees J. Bot
2 ! 27 Jan 1994
3 .sect .text; .sect .rom; .sect .data; .sect .bss
5 ! void *memset(void *s, int c, size_t n)
6 ! Set a chunk of memory to the same byte value.
8 .sect .text
9 .define _memset
10 _memset:
11 push bp
12 mov bp, sp
13 push di
14 mov di, 4(bp) ! The string
15 movb al, 6(bp) ! The fill byte
16 mov cx, 8(bp) ! Length
17 cld
18 cmp cx, #16
19 jb sbyte ! Don't bother being smart with short arrays
20 test di, #1
21 jnz sbyte ! Bit 0 set, use byte store
22 sword: movb ah, al ! One byte to two bytes
23 sar cx, #1
24 rep stos ! Store words
25 adc cx, cx ! One more byte?
26 sbyte:
27 rep stosb ! Store bytes
28 done: mov ax, 4(bp) ! Return some value you have no need for
29 pop di
30 pop bp
31 ret