1 ! memset
() Author
: Kees J. Bot
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.
14 mov di
, 4(bp
) ! The string
15 movb al
, 6(bp
) ! The fill byte
16 mov cx
, 8(bp
) ! Length
19 jb sbyte
! Don
't bother being smart with short arrays
21 jnz sbyte ! Bit 0 set, use byte store
22 sword: movb ah, al ! One byte to two bytes
24 rep stos ! Store words
25 adc cx, cx ! One more byte?
27 rep stosb ! Store bytes
28 done: mov ax, 4(bp) ! Return some value you have no need for