logical.py (5119:a4469f2919f3) logical.py (6082:5db340cc3c47)
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
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
79def macroop OR_M_R
80{
81 ldst t1, seg, sib, disp
82 or t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
83 st t1, seg, sib, disp
84};
85
86def macroop OR_P_R
87{
88 rdip t7
89 ldst t1, seg, riprel, disp
90 or t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
91 st t1, seg, riprel, disp
92};
93
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
94def macroop OR_R_M
95{
96 ld t1, seg, sib, disp
97 or reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
98};
99
100def macroop OR_R_P
101{
102 rdip t7
103 ld t1, seg, riprel, disp
104 or reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
105};
106
107def macroop OR_R_I
108{
109 limm t1, imm
110 or reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
111};
112
113def macroop XOR_R_R
114{
115 xor reg, reg, regm, flags=(OF,SF,ZF,PF,CF)
116};
117
118def macroop XOR_R_I
119{
120 limm t1, imm
121 xor reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
122};
123
124def macroop XOR_M_I
125{
126 limm t2, imm
127 ldst t1, seg, sib, disp
128 xor t1, t1, t2, flags=(OF,SF,ZF,PF,CF)
129 st t1, seg, sib, disp
130};
131
132def macroop XOR_P_I
133{
134 limm t2, imm
135 rdip t7
136 ldst t1, seg, riprel, disp
137 xor t1, t1, t2, flags=(OF,SF,ZF,PF,CF)
138 st t1, seg, riprel, disp
139};
140
141def macroop XOR_M_R
142{
143 ldst t1, seg, sib, disp
144 xor t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
145 st t1, seg, sib, disp
146};
147
148def macroop XOR_P_R
149{
150 rdip t7
151 ldst t1, seg, riprel, disp
152 xor t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
153 st t1, seg, riprel, disp
154};
155
156def macroop XOR_R_M
157{
158 ld t1, seg, sib, disp
159 xor reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
160};
161
162def macroop XOR_R_P
163{
164 rdip t7
165 ld t1, seg, riprel, disp
166 xor reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
167};
168
169def macroop AND_R_R
170{
171 and reg, reg, regm, flags=(OF,SF,ZF,PF,CF)
172};
173
174def macroop AND_R_M
175{
176 ld t1, seg, sib, disp
177 and reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
178};
179
180def macroop AND_R_P
181{
182 rdip t7
183 ld t1, seg, riprel, disp
184 and reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
185};
186
187def macroop AND_R_I
188{
189 limm t1, imm
190 and reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
191};
192
193def macroop AND_M_I
194{
195 ldst t2, seg, sib, disp
196 limm t1, imm
197 and t2, t2, t1, flags=(OF,SF,ZF,PF,CF)
198 st t2, seg, sib, disp
199};
200
201def macroop AND_P_I
202{
203 rdip t7
204 ldst t2, seg, riprel, disp
205 limm t1, imm
206 and t2, t2, t1, flags=(OF,SF,ZF,PF,CF)
207 st t2, seg, riprel, disp
208};
209
210def macroop AND_M_R
211{
212 ldst t1, seg, sib, disp
213 and t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
214 st t1, seg, sib, disp
215};
216
217def macroop AND_P_R
218{
219 rdip t7
220 ldst t1, seg, riprel, disp
221 and t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
222 st t1, seg, riprel, disp
223};
224
225def macroop NOT_R
226{
227 limm t1, -1
228 xor reg, reg, t1
229};
230
231def macroop NOT_M
232{
233 limm t1, -1
234 ldst t2, seg, sib, disp
235 xor t2, t2, t1
236 st t2, seg, sib, disp
237};
238
239def macroop NOT_P
240{
241 limm t1, -1
242 rdip t7
243 ldst t2, seg, riprel, disp
244 xor t2, t2, t1
245 st t2, seg, riprel, disp
246};
247'''
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_M_R
174{
175 ldst t1, seg, sib, disp
176 xor t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
177 st t1, seg, sib, disp
178};
179
180def macroop XOR_P_R
181{
182 rdip t7
183 ldst t1, seg, riprel, disp
184 xor t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
185 st t1, seg, riprel, disp
186};
187
188def macroop XOR_R_M
189{
190 ld t1, seg, sib, disp
191 xor reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
192};
193
194def macroop XOR_R_P
195{
196 rdip t7
197 ld t1, seg, riprel, disp
198 xor reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
199};
200
201def macroop AND_R_R
202{
203 and reg, reg, regm, flags=(OF,SF,ZF,PF,CF)
204};
205
206def macroop AND_R_M
207{
208 ld t1, seg, sib, disp
209 and reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
210};
211
212def macroop AND_R_P
213{
214 rdip t7
215 ld t1, seg, riprel, disp
216 and reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
217};
218
219def macroop AND_R_I
220{
221 limm t1, imm
222 and reg, reg, t1, flags=(OF,SF,ZF,PF,CF)
223};
224
225def macroop AND_M_I
226{
227 ldst t2, seg, sib, disp
228 limm t1, imm
229 and t2, t2, t1, flags=(OF,SF,ZF,PF,CF)
230 st t2, seg, sib, disp
231};
232
233def macroop AND_P_I
234{
235 rdip t7
236 ldst t2, seg, riprel, disp
237 limm t1, imm
238 and t2, t2, t1, flags=(OF,SF,ZF,PF,CF)
239 st t2, seg, riprel, disp
240};
241
242def macroop AND_M_R
243{
244 ldst t1, seg, sib, disp
245 and t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
246 st t1, seg, sib, disp
247};
248
249def macroop AND_P_R
250{
251 rdip t7
252 ldst t1, seg, riprel, disp
253 and t1, t1, reg, flags=(OF,SF,ZF,PF,CF)
254 st t1, seg, riprel, disp
255};
256
257def macroop NOT_R
258{
259 limm t1, -1
260 xor reg, reg, t1
261};
262
263def macroop NOT_M
264{
265 limm t1, -1
266 ldst t2, seg, sib, disp
267 xor t2, t2, t1
268 st t2, seg, sib, disp
269};
270
271def macroop NOT_P
272{
273 limm t1, -1
274 rdip t7
275 ldst t2, seg, riprel, disp
276 xor t2, t2, t1
277 st t2, seg, riprel, disp
278};
279'''