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/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 .486
31 .model flat
32 .code
33
34;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
35; extern "C" char __rw_atomic_xchg8 (char *x, char y);
36;
37; Atomically assigns the 8-bit value y to *x and returns
38; the original (before assignment) 8-bit value of *x.
39;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
40
41 align 4
42 public ___rw_atomic_xchg8
43___rw_atomic_xchg8 proc ; char (char *x, char y)
44
45arg_x = dword ptr 4
46arg_y = byte ptr 8
47
48 mov ecx, [esp+arg_x] ; %ecx = x
49 mov al, [esp+arg_y] ; %al = y
50 xchg al, [ecx] ; %al <-> (%ecx)
51 ret
52___rw_atomic_xchg8 endp
53
54
55;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
56; extern "C" short __rw_atomic_xchg16 (short *x, short y);
57;
58; Atomically assigns the 16-bit value y to *x and returns
59; the original (before assignment) 16-bit value of *x.
60;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
61
62 align 4
63 public ___rw_atomic_xchg16
64___rw_atomic_xchg16 proc ; short (short *x, short y)
65
66arg_x = dword ptr 4
67arg_y = word ptr 8
68
69 mov ecx, [esp+arg_x] ; %ecx = x
70 mov ax, [esp+arg_y] ; %eax = y
71 xchg ax, [ecx] ; %ax <-> (%ecx)
72 ret
73___rw_atomic_xchg16 endp
74
75
76;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
77; extern "C" int __rw_atomic_xchg32 (int *x, int y);
78;
79; Atomically assigns the 32-bit value y to *x and returns
80; the original (before assignment) 32-bit value of *x.
81;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
82
83 align 4
84 public ___rw_atomic_xchg32
85___rw_atomic_xchg32 proc ; int (int *x, int y)
86
87arg_x = dword ptr 4
88arg_y = dword ptr 8
89
90 mov ecx, [esp+arg_x] ; %ecx = x
91 mov eax, [esp+arg_y] ; %eax = y
92 xchg eax, [ecx] ; %eax <-> (%ecx)
93 ret
94___rw_atomic_xchg32 endp
95
96
97
98;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
99; extern "C" char __rw_atomic_add8 (char *x, int y);
100;
101; Atomically increments the 8-bit value *x by y and returns
102; the new (after increment) 8-bit value of *x.
103;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
104
105 align 4
106 public ___rw_atomic_add8
107___rw_atomic_add8 proc ; char (char *dst, int inc)
108
109arg_dst = dword ptr 4
110arg_inc = dword ptr 8
111
112 mov ecx, [esp+arg_dst] ; %ecx = dst
113 mov eax, [esp+arg_inc] ; %eax = inc
114 mov edx, eax
115
116 lock xadd [ecx], al ; tmp = *dst;
117 ; dst += inc;
118 ; %al = tmp
119
120 add eax, edx ; return %eax + inc
121 ret
122___rw_atomic_add8 endp
123
124
125;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
126; extern "C" short __rw_atomic_add16 (short *x, short y);
127;
128; Atomically increments the 16-bit value *x by y and returns
129; the new (after increment) 16-bit value of *x.
130;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
131
132 align 4
133 public ___rw_atomic_add16
134___rw_atomic_add16 proc ; short (short *dst, short inc)
135
136arg_dst = dword ptr 4
137arg_inc = dword ptr 8
138
139 mov ecx, [esp+arg_dst] ; %ecx = dst
140 mov eax, [esp+arg_inc] ; %eax = inc
141 mov edx, eax
142
143 lock xadd [ecx], ax ; tmp = *dst;
144 ; dst += inc;
145 ; %ax = tmp
146
147 add eax, edx ; return %eax + inc
148 ret
149___rw_atomic_add16 endp
150
151
152;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
153; extern "C" int __rw_atomic_add32 (int *x, int y);
154;
155; Atomically increments the 32-bit value *x by y and returns
156; the new (after increment) 32-bit value of *x.
157;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
158
159 align 4
160 public ___rw_atomic_add32
161___rw_atomic_add32 proc ; int (int *dst, int inc)
162
163arg_dst = dword ptr 4
164arg_inc = dword ptr 8
165
166 mov ecx, [esp+arg_dst] ; %ecx = dst
167 mov edx, [esp+arg_inc] ; %edx = inc
168 mov eax, edx
169
170 lock xadd [ecx], eax ; tmp = *dst;
171 ; dst += inc;
172 ; %eax = tmp
173
174 add eax, edx ; return %eax + inc
175 ret
176___rw_atomic_add32 endp
#define y
Definition 17.names.cpp:141
#define ptr
Definition 17.names.cpp:525
#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