]> git.lizzy.rs Git - plan9front.git/blob - sys/src/libc/amd64/memset.s
libc: change usize to 64-bit for amd64 and arm64, make memory(2) functions use usize
[plan9front.git] / sys / src / libc / amd64 / memset.s
1 TEXT    memset(SB),$0
2
3         CLD
4         MOVQ    RARG, DI
5         MOVBLZX c+8(FP), AX
6         MOVQ    n+16(FP), BX
7 /*
8  * if not enough bytes, just set bytes
9  */
10         CMPQ    BX, $9
11         JLS     c3
12 /*
13  * if not aligned, just set bytes
14  */
15         MOVQ    RARG, CX
16         ANDL    $3,CX
17         JNE     c3
18 /*
19  * build word in AX
20  */
21         MOVB    AL, AH
22         MOVL    AX, CX
23         SHLL    $16, CX
24         ORL     CX, AX
25 /*
26  * set whole longs
27  */
28 c1:
29         MOVQ    BX, CX
30         SHRQ    $2, CX
31         ANDL    $3, BX
32         REP;    STOSL
33 /*
34  * set the rest, by bytes
35  */
36 c3:
37         MOVL    BX, CX
38         REP;    STOSB
39 ret:
40         MOVQ    RARG,AX
41         RET