Cygwin: access: Fix X_OK behaviour for backup operators and admins
[newlib-cygwin.git] / newlib / libc / machine / z8k / memset.S
blob43184c7093480827891b56affb91490fd5f2cb13
1 /*
2  * memset routine for Z8000
3  * Copyright (C) 2004 Christian Groessler <chris@groessler.org>
4  *
5  * Permission to use, copy, modify, and distribute this file
6  * for any purpose is hereby granted without fee, provided that
7  * the above copyright notice and this notice appears in all
8  * copies.
9  *
10  * This file is distributed WITHOUT ANY WARRANTY; without even the implied
11  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12  */
14 /* void *memset(void *buffer, int value, size_t length);
15  */
17         name    "memset.S"
19         .text
20         even
21 global  _memset
23 _memset:
25 #ifdef __Z8001__
26         segm
28 #ifdef __STD_CALL__
29         ldl     rr6,rr14(#4)
30         ld      r5,rr14(#8)
31         ldl     rr2,rr14(#10)
32 #else
33         pushl   @rr14,rr6
34 #endif
36 /* rr2  - length
37  * rl5  - value
38  * rr6  - buffer
39  */
40         testl   rr2
41         jr      z,finish
43         ldb     rh5,rl5
44         ld      r1,r5           /* r1 contains value */
45         bit     r7,#0
46         jr      z,not_odd
48         ldb     @rr6,rl1
49         inc     r7,#1
50         subl    rr2,#1
51         jr      z,finish
53 not_odd:ld      r0,r3           /* remember length */
54         srl     r3,#1
55         jr      z,no_words
57         ldl     rr4,rr6
58         ld      @rr6,r1
59         inc     r7,#2
60         dec     r3,#1
61         jr      z,no_words
63         ldir    @rr6,@rr4,r3    /* fill words */
65 no_words:
66         bit     r0,#0           /* one byte remaining? */
67         jr      z,finish
69         ldb     @rr6,rl1
71 finish:
72 #ifdef __STD_CALL__
73         ldl     rr6,rr14(#4)
74 #else
75         popl    rr2,@rr14
76 #endif
79 #else           /* above Z8001, below Z8002 */
82         unsegm
84 #ifdef __STD_CALL__
85         ld      r7,r15(#2)
86         ld      r6,r15(#4)
87         ld      r5,r15(#6)
88 #else
89         ld      r2,r7           /* buffer pointer return value */
90 #endif
92 /* r5  - length
93  * r6  - value
94  * r7  - buffer
95  */
96         test    r5
97         jr      z,finish
99         ldb     rh6,rl6
100         ld      r1,r6           /* r1 contains value */
101         bit     r7,#0
102         jr      z,not_odd
104         ldb     @r7,rl1
105         inc     r7,#1
106         dec     r5,#1
107         jr      z,finish
109 not_odd:ld      r0,r5           /* remember length */
110         srl     r5,#1
111         jr      z,no_words
113         ld      r4,r7
114         ld      @r7,r1
115         inc     r7,#2
116         dec     r5,#1
117         jr      z,no_words
119         ldir    @r7,@r4,r5      /* fill words */
121 no_words:
122         bit     r0,#0           /* one byte remaining? */
123         jr      z,finish
125         ldb     @r7,rl1
127 finish:
128 #ifdef __STD_CALL__
129         ld      r7,r15(#2)
130 #endif
132 #endif  /* Z8002 */
134         ret
135         .end