logical.py revision 6089:030c2a63fb61
1# Copyright (c) 2007 The Hewlett-Packard Development Company
2# All rights reserved.
3#
4# Redistribution and use of this software in source and binary forms,
5# with or without modification, are permitted provided that the
6# following conditions are met:
7#
8# The software must be used only for Non-Commercial Use which means any
9# use which is NOT directed to receiving any direct monetary
10# compensation for, or commercial advantage from such use.  Illustrative
11# examples of non-commercial use are academic research, personal study,
12# teaching, education and corporate research & development.
13# Illustrative examples of commercial use are distributing products for
14# commercial advantage and providing services using the software for
15# commercial advantage.
16#
17# If you wish to use this software or functionality therein that may be
18# covered by patents for commercial use, please contact:
19#     Director of Intellectual Property Licensing
20#     Office of Strategy and Technology
21#     Hewlett-Packard Company
22#     1501 Page Mill Road
23#     Palo Alto, California  94304
24#
25# Redistributions of source code must retain the above copyright notice,
26# this list of conditions and the following disclaimer.  Redistributions
27# in binary form must reproduce the above copyright notice, this list of
28# conditions and the following disclaimer in the documentation and/or
29# other materials provided with the distribution.  Neither the name of
30# the COPYRIGHT HOLDER(s), HEWLETT-PACKARD COMPANY, nor the names of its
31# contributors may be used to endorse or promote products derived from
32# this software without specific prior written permission.  No right of
33# sublicense is granted herewith.  Derivatives of the software and
34# output created using the software may be prepared, but only for
35# Non-Commercial Uses.  Derivatives of the software may be shared with
36# others provided: (i) the others agree to abide by the list of
37# conditions herein which includes the Non-Commercial Use restrictions;
38# and (ii) such Derivatives of the software include the above copyright
39# notice to acknowledge the contribution from this software where
40# applicable, this list of conditions and the disclaimer below.
41#
42# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
43# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
44# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
45# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
46# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
48# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
49# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
50# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
51# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
52# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53#
54# Authors: Gabe Black
55
56microcode = '''
57def macroop OR_R_R
58{
59    or reg, reg, regm, flags=(OF,SF,ZF,PF,CF)
60};
61
62def macroop OR_M_I
63{
64    limm t2, imm
65    ldst t1, seg, sib, disp
66    or t1, t1, t2, flags=(OF,SF,ZF,PF,CF)
67    st t1, seg, sib, disp
68};
69
70def macroop OR_P_I
71{
72    limm t2, imm
73    rdip t7
74    ldst t1, seg, riprel, disp
75    or t1, t1, t2, flags=(OF,SF,ZF,PF,CF)
76    st t1, seg, riprel, disp
77};
78
79def macroop OR_LOCKED_M_I
80{
81    limm t2, imm
82    ldstl t1, seg, sib, disp
83    or t1, t1, t2, flags=(OF,SF,ZF,PF,CF)
84    stul t1, seg, sib, disp
85};
86
87def macroop OR_LOCKED_P_I
88{
89    limm t2, imm
90    rdip t7
91    ldstl t1, seg, riprel, disp
92    or t1, t1, t2, flags=(OF,SF,ZF,PF,CF)
93    stul t1, seg, riprel, disp
94};
95
96def macroop OR_M_R
97{
98    ldst t1, seg, sib, disp
99    or t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
100    st t1, seg, sib, disp
101};
102
103def macroop OR_P_R
104{
105    rdip t7
106    ldst t1, seg, riprel, disp
107    or t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
108    st t1, seg, riprel, disp
109};
110
111def macroop OR_LOCKED_M_R
112{
113    ldstl t1, seg, sib, disp
114    or t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
115    stul t1, seg, sib, disp
116};
117
118def macroop OR_LOCKED_P_R
119{
120    rdip t7
121    ldstl t1, seg, riprel, disp
122    or t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
123    stul t1, seg, riprel, disp
124};
125
126def macroop OR_R_M
127{
128    ld t1, seg, sib, disp
129    or reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
130};
131
132def macroop OR_R_P
133{
134    rdip t7
135    ld t1, seg, riprel, disp
136    or reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
137};
138
139def macroop OR_R_I
140{
141    limm t1, imm
142    or reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
143};
144
145def macroop XOR_R_R
146{
147    xor reg, reg, regm, flags=(OF,SF,ZF,PF,CF)
148};
149
150def macroop XOR_R_I
151{
152    limm t1, imm
153    xor reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
154};
155
156def macroop XOR_M_I
157{
158    limm t2, imm
159    ldst t1, seg, sib, disp
160    xor t1, t1, t2, flags=(OF,SF,ZF,PF,CF)
161    st t1, seg, sib, disp
162};
163
164def macroop XOR_P_I
165{
166    limm t2, imm
167    rdip t7
168    ldst t1, seg, riprel, disp
169    xor t1, t1, t2, flags=(OF,SF,ZF,PF,CF)
170    st t1, seg, riprel, disp
171};
172
173def macroop XOR_LOCKED_M_I
174{
175    limm t2, imm
176    ldstl t1, seg, sib, disp
177    xor t1, t1, t2, flags=(OF,SF,ZF,PF,CF)
178    stul t1, seg, sib, disp
179};
180
181def macroop XOR_LOCKED_P_I
182{
183    limm t2, imm
184    rdip t7
185    ldstl t1, seg, riprel, disp
186    xor t1, t1, t2, flags=(OF,SF,ZF,PF,CF)
187    stul t1, seg, riprel, disp
188};
189
190def macroop XOR_M_R
191{
192    ldst t1, seg, sib, disp
193    xor t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
194    st t1, seg, sib, disp
195};
196
197def macroop XOR_P_R
198{
199    rdip t7
200    ldst t1, seg, riprel, disp
201    xor t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
202    st t1, seg, riprel, disp
203};
204
205def macroop XOR_LOCKED_M_R
206{
207    ldstl t1, seg, sib, disp
208    xor t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
209    stul t1, seg, sib, disp
210};
211
212def macroop XOR_LOCKED_P_R
213{
214    rdip t7
215    ldstl t1, seg, riprel, disp
216    xor t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
217    stul t1, seg, riprel, disp
218};
219
220def macroop XOR_R_M
221{
222    ld t1, seg, sib, disp
223    xor reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
224};
225
226def macroop XOR_R_P
227{
228    rdip t7
229    ld t1, seg, riprel, disp
230    xor reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
231};
232
233def macroop AND_R_R
234{
235    and reg, reg, regm, flags=(OF,SF,ZF,PF,CF)
236};
237
238def macroop AND_R_M
239{
240    ld t1, seg, sib, disp
241    and reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
242};
243
244def macroop AND_R_P
245{
246    rdip t7
247    ld t1, seg, riprel, disp
248    and reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
249};
250
251def macroop AND_R_I
252{
253    limm t1, imm
254    and reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
255};
256
257def macroop AND_M_I
258{
259    ldst t2, seg, sib, disp
260    limm t1, imm
261    and t2, t2, t1, flags=(OF,SF,ZF,PF,CF)
262    st t2, seg, sib, disp
263};
264
265def macroop AND_P_I
266{
267    rdip t7
268    ldst t2, seg, riprel, disp
269    limm t1, imm
270    and t2, t2, t1, flags=(OF,SF,ZF,PF,CF)
271    st t2, seg, riprel, disp
272};
273
274def macroop AND_LOCKED_M_I
275{
276    ldstl t2, seg, sib, disp
277    limm t1, imm
278    and t2, t2, t1, flags=(OF,SF,ZF,PF,CF)
279    stul t2, seg, sib, disp
280};
281
282def macroop AND_LOCKED_P_I
283{
284    rdip t7
285    ldstl t2, seg, riprel, disp
286    limm t1, imm
287    and t2, t2, t1, flags=(OF,SF,ZF,PF,CF)
288    stul t2, seg, riprel, disp
289};
290
291def macroop AND_M_R
292{
293    ldst t1, seg, sib, disp
294    and t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
295    st t1, seg, sib, disp
296};
297
298def macroop AND_P_R
299{
300    rdip t7
301    ldst t1, seg, riprel, disp
302    and t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
303    st t1, seg, riprel, disp
304};
305
306def macroop AND_LOCKED_M_R
307{
308    ldstl t1, seg, sib, disp
309    and t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
310    stul t1, seg, sib, disp
311};
312
313def macroop AND_LOCKED_P_R
314{
315    rdip t7
316    ldstl t1, seg, riprel, disp
317    and t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
318    stul t1, seg, riprel, disp
319};
320
321def macroop NOT_R
322{
323    limm t1, -1
324    xor reg, reg, t1
325};
326
327def macroop NOT_M
328{
329    limm t1, -1
330    ldst t2, seg, sib, disp
331    xor t2, t2, t1
332    st t2, seg, sib, disp
333};
334
335def macroop NOT_P
336{
337    limm t1, -1
338    rdip t7
339    ldst t2, seg, riprel, disp
340    xor t2, t2, t1
341    st t2, seg, riprel, disp
342};
343
344def macroop NOT_LOCKED_M
345{
346    limm t1, -1
347    ldstl t2, seg, sib, disp
348    xor t2, t2, t1
349    stul t2, seg, sib, disp
350};
351
352def macroop NOT_LOCKED_P
353{
354    limm t1, -1
355    rdip t7
356    ldstl t2, seg, riprel, disp
357    xor t2, t2, t1
358    stul t2, seg, riprel, disp
359};
360'''
361