source: trunk/minix/lib/i86/string/memset.s@ 9

Last change on this file since 9 was 9, checked in by Mattia Monga, 13 years ago

Minix 3.1.2a

File size: 713 bytes
Line 
1! memset() Author: Kees J. Bot
2! 27 Jan 1994
3.sect .text; .sect .rom; .sect .data; .sect .bss
4
5! void *memset(void *s, int c, size_t n)
6! Set a chunk of memory to the same byte value.
7!
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
22sword: movb ah, al ! One byte to two bytes
23 sar cx, #1
24 rep stos ! Store words
25 adc cx, cx ! One more byte?
26sbyte:
27 rep stosb ! Store bytes
28done: mov ax, 4(bp) ! Return some value you have no need for
29 pop di
30 pop bp
31 ret
Note: See TracBrowser for help on using the repository browser.