Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
atomic.inc
Go to the documentation of this file.
1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2;
3; x86_64/atomic.inc
4;
5; $Id$
6;
7;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8;
9; Licensed to the Apache Software Foundation (ASF) under one or more
10; contributor license agreements. See the NOTICE file distributed
11; with this work for additional information regarding copyright
12; ownership. The ASF licenses this file to you under the Apache
13; License, Version 2.0 (the "License"); you may not use this file
14; except in compliance with the License. You may obtain a copy of
15; the License at
16;
17; http://www.apache.org/licenses/LICENSE-2.0
18;
19; Unless required by applicable law or agreed to in writing, software
20; distributed under the License is distributed on an "AS IS" BASIS,
21; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
22; implied. See the License for the specific language governing
23; permissions and limitations under the License.
24;
25; Copyright 2003-2006 Rogue Wave Software.
26;
27;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
28
29
30 .code
31
32;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
33; extern "C" int8_t __rw_atomic_xchg8 (int8_t *x, int8_t y);
34;
35; Atomically assigns the 8-bit value y to *x and returns
36; the original (before assignment) 8-bit value of *x.
37;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
38
39 align 16
40 public __rw_atomic_xchg8
41__rw_atomic_xchg8 proc ; int8_t (int8_t *x, int8_t y)
42 ; %rcx = x
43 mov al, dl ; %al = y
44 xchg al, [rcx] ; %al <-> (%rcx)
45 ret
46__rw_atomic_xchg8 endp
47
48
49;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
50; extern "C" int16_t __rw_atomic_xchg16 (int16_t *x, int16_t y);
51;
52; Atomically assigns the 16-bit value y to *x and returns
53; the original (before assignment) 16-bit value of *x.
54;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
55
56 align 16
57 public __rw_atomic_xchg16
58__rw_atomic_xchg16 proc ; int16_t (int16_t *x, int16_t y)
59 ; %rcx = x
60 mov ax, dx ; %ax = y
61 xchg ax, [rcx] ; %ax <-> (%rcx)
62 ret
63__rw_atomic_xchg16 endp
64
65
66;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
67; extern "C" int32_t __rw_atomic_xchg32 (int32_t *x, int32_t y);
68;
69; Atomically assigns the 32-bit value y to *x and returns
70; the original (before assignment) 32-bit value of *x.
71;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
72
73 align 16
74 public __rw_atomic_xchg32
75__rw_atomic_xchg32 proc ; int32_t (int32_t *x, int32_t y)
76 ; %rcx = x
77 mov eax, edx ; %eax = y
78 xchg eax, [rcx] ; %eax <-> (%rcx)
79 ret
80__rw_atomic_xchg32 endp
81
82
83;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
84; extern "C" int32_t __rw_atomic_xchg64 (int64_t *x, int64_t y);
85;
86; Atomically assigns the 64-bit value y to *x and returns
87; the original (before assignment) 64-bit value of *x.
88;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
89
90 align 16
91 public __rw_atomic_xchg64
92__rw_atomic_xchg64 proc ; int64_t (int64_t *x, int64_t y)
93 ; %rcx = x
94 mov rax, rdx ; %rax = y
95 xchg rax, [rcx] ; %rax <-> (%rcx)
96 ret
97__rw_atomic_xchg64 endp
98
99
100;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
101; extern "C" int8_t __rw_atomic_add8 (int8_t *x, int8_t y);
102;
103; Atomically increments the 8-bit value *x by y and returns
104; the new (after increment) 8-bit value of *x.
105;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
106
107 align 16
108 public __rw_atomic_add8
109__rw_atomic_add8 proc ; int8_t (int8_t *dst, int8_t inc)
110 ; %rcx = dst
111 mov eax, edx ; %eax = inc
112
113 lock xadd [rcx], al ; tmp = *dst
114 ; dst += inc
115 ; %al = tmp
116 add eax, edx ; return %al + inc
117 ret
118__rw_atomic_add8 endp
119
120
121;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
122; extern "C" int16_t __rw_atomic_add16 (int16_t *x, int16_t y);
123;
124; Atomically increments the 16-bit value *x by y and returns
125; the new (after increment) 16-bit value of *x.
126;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
127
128 align 16
129 public __rw_atomic_add16
130__rw_atomic_add16 proc ; int16_t (int16_t *dst, int16_t inc)
131 ; %rcx = dst
132 mov ax, dx ; %ax = inc
133
134 lock xadd [rcx], ax ; tmp = *dst
135 ; dst += inc
136 ; eax = tmp
137
138 add ax, dx ; return %ax + inc
139 ret
140__rw_atomic_add16 endp
141
142
143;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
144; extern "C" int32_t __rw_atomic_add32 (int32_t *x, int32_t y);
145;
146; Atomically increments the 32-bit value *x by y and returns
147; the new (after increment) 32-bit value of *x.
148;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
149
150 align 16
151 public __rw_atomic_add32
152__rw_atomic_add32 proc ; int32_t (int32_t *dst, int32_t inc)
153 ; %rcx = dst
154 mov eax, edx ; %eax = inc
155
156 lock xadd [rcx], eax ; tmp = *dst
157 ; dst += inc
158 ; %eax = tmp
159
160 add eax, edx ; return %eax + inc
161 ret
162__rw_atomic_add32 endp
163
164
165;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
166; extern "C" int64_t __rw_atomic_add64 (int64_t *x, int64_t y);
167;
168; Atomically increments the 32-bit value *x by y and returns
169; the new (after increment) 32-bit value of *x.
170;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
171
172 align 16
173 public __rw_atomic_add64
174__rw_atomic_add64 proc ; int64_t (int64_t *dst, int64_t inc)
175 ; %rcx = dst
176 mov rax, rdx ; %eax = inc
177
178 lock xadd [rcx], rax ; tmp = *dst
179 ; dst += inc
180 ; %eax = tmp
181
182 add rax, rdx ; return %eax + inc
183 ret
184__rw_atomic_add64 endp
#define y
Definition 17.names.cpp:141
#define x
Definition 17.names.cpp:140
#define a
Definition 17.names.cpp:109
#define tmp
Definition 17.names.cpp:553
T value(const T &val)
const int in
volatile int one
Definition LIMITS.cpp:61