Added SSE streaming store instructions, external symbol directives.
[mesa.git] / src / mesa / x86 / assyntax.h
1 /* $Id: assyntax.h,v 1.15 2000/09/18 22:49:04 gareth Exp $ */
2
3 #ifndef __ASSYNTAX_H__
4 #define __ASSYNTAX_H__
5
6 /*
7 * Copyright 1992 Vrije Universiteit, The Netherlands
8 *
9 * Permission to use, copy, modify, and distribute this software and its
10 * documentation for any purpose and without fee is hereby granted, provided
11 * that the above copyright notice appear in all copies and that both that
12 * copyright notice and this permission notice appear in supporting
13 * documentation, and that the name of the Vrije Universiteit not be used in
14 * advertising or publicity pertaining to distribution of the software without
15 * specific, written prior permission. The Vrije Universiteit makes no
16 * representations about the suitability of this software for any purpose.
17 * It is provided "as is" without express or implied warranty.
18 *
19 * The Vrije Universiteit DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
20 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
21 * IN NO EVENT SHALL The Vrije Universiteit BE LIABLE FOR ANY SPECIAL,
22 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
23 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
24 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
25 * PERFORMANCE OF THIS SOFTWARE.
26 */
27
28 /*
29 * assyntax.h
30 *
31 * Select the syntax appropriate to the 386 assembler being used
32 * To add support for more assemblers add more columns to the CHOICE
33 * macro. Note that register names must also have uppercase names
34 * to avoid macro recursion. e.g., #define ah %ah recurses!
35 *
36 * NB 1. Some of the macros for certain assemblers imply that the code is to
37 * run in protected mode!! Caveat emptor.
38 *
39 * NB 2. 486 specific instructions are not included. This is to discourage
40 * their accidental use in code that is intended to run on 386 and 486
41 * systems.
42 *
43 * Supported assemblers:
44 *
45 * (a) AT&T SysVr4 as(1): define ATT_ASSEMBLER
46 * (b) GNU Assembler gas: define GNU_ASSEMBLER (default)
47 * (c) Amsterdam Compiler kit: define ACK_ASSEMBLER
48 * (d) The Netwide Assembler: define NASM_ASSEMBLER
49 * (e) Microsoft Assembler: define MASM_ASSEMBLER (UNTESTED!)
50 *
51 * The following naming conventions have been used to identify the various
52 * data types:
53 * _SR = segment register version
54 * Integer:
55 * _Q = quadword = 64 bits
56 * _L = long = 32 bits
57 * _W = short = 16 bits
58 * _B = byte = 8 bits
59 * Floating-point:
60 * _X = m80real = 80 bits
61 * _D = double = 64 bits
62 * _S = single = 32 bits
63 *
64 * Author: Gregory J. Sharp, Sept 1992
65 * Vrije Universiteit, Amsterdam, The Netherlands
66 *
67 * [support for Intel syntax added by Josh Vanderhoof, 1999]
68 */
69
70 #if !(defined(NASM_ASSEMBLER) || defined(MASM_ASSEMBLER))
71
72 #if !defined(ATT_ASSEMBLER) && !defined(GNU_ASSEMBLER) && !defined(ACK_ASSEMBLER)
73 #define GNU_ASSEMBLER
74 #endif
75
76 #if (defined(__STDC__) && !defined(UNIXCPP)) || (defined (sun) && defined (i386) && defined (SVR4) && defined (__STDC__) && !defined (__GNUC__))
77 #define CONCAT(x, y) x ## y
78 #else
79 #define CONCAT(x, y) x/**/y
80 #endif
81
82 #ifdef ACK_ASSEMBLER
83
84 /* Assume we write code for 32-bit protected mode! */
85
86 /* Redefine register names for GAS & AT&T assemblers */
87 #define AL al
88 #define AH ah
89 #define AX ax
90 #define EAX ax
91 #define BL bl
92 #define BH bh
93 #define BX bx
94 #define EBX bx
95 #define CL cl
96 #define CH ch
97 #define CX cx
98 #define ECX cx
99 #define DL dl
100 #define DH dh
101 #define DX dx
102 #define EDX dx
103 #define BP bp
104 #define EBP bp
105 #define SI si
106 #define ESI si
107 #define DI di
108 #define EDI di
109 #define SP sp
110 #define ESP sp
111 #define CS cs
112 #define SS ss
113 #define DS ds
114 #define ES es
115 #define FS fs
116 #define GS gs
117 /* Control Registers */
118 #define CR0 cr0
119 #define CR1 cr1
120 #define CR2 cr2
121 #define CR3 cr3
122 /* Debug Registers */
123 #define DR0 dr0
124 #define DR1 dr1
125 #define DR2 dr2
126 #define DR3 dr3
127 #define DR4 dr4
128 #define DR5 dr5
129 #define DR6 dr6
130 #define DR7 dr7
131 /* Floating-point Stack */
132 #define ST st
133
134 #define AS_BEGIN .sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text
135
136
137 #define _WTOG o16 /* word toggle for _W instructions */
138 #define _LTOG /* long toggle for _L instructions */
139 #define ADDR_TOGGLE a16
140 #define OPSZ_TOGGLE o16
141 #define USE16 .use16
142 #define USE32 .use32
143
144 #define CHOICE(a,b,c) c
145
146 #else /* AT&T or GAS */
147
148 /* Redefine register names for GAS & AT&T assemblers */
149 #define AL %al
150 #define AH %ah
151 #define AX %ax
152 #define EAX %eax
153 #define BL %bl
154 #define BH %bh
155 #define BX %bx
156 #define EBX %ebx
157 #define CL %cl
158 #define CH %ch
159 #define CX %cx
160 #define ECX %ecx
161 #define DL %dl
162 #define DH %dh
163 #define DX %dx
164 #define EDX %edx
165 #define BP %bp
166 #define EBP %ebp
167 #define SI %si
168 #define ESI %esi
169 #define DI %di
170 #define EDI %edi
171 #define SP %sp
172 #define ESP %esp
173 #define CS %cs
174 #define SS %ss
175 #define DS %ds
176 #define ES %es
177 #define FS %fs
178 #define GS %gs
179 /* Control Registers */
180 #define CR0 %cr0
181 #define CR1 %cr1
182 #define CR2 %cr2
183 #define CR3 %cr3
184 /* Debug Registers */
185 #define DR0 %db0
186 #define DR1 %db1
187 #define DR2 %db2
188 #define DR3 %db3
189 #define DR4 %db4
190 #define DR5 %db5
191 #define DR6 %db6
192 #define DR7 %db7
193 /* Floating-point Stack */
194 #define _STX0 %st(0)
195 #define _STX1 %st(1)
196 #define _STX2 %st(2)
197 #define _STX3 %st(3)
198 #define _STX4 %st(4)
199 #define _STX5 %st(5)
200 #define _STX6 %st(6)
201 #define _STX7 %st(7)
202 #define ST(x) CONCAT(_STX,x)
203 /* MMX Registers */
204 #define MM0 %mm0
205 #define MM1 %mm1
206 #define MM2 %mm2
207 #define MM3 %mm3
208 #define MM4 %mm4
209 #define MM5 %mm5
210 #define MM6 %mm6
211 #define MM7 %mm7
212 /* SSE Registers */
213 #define XMM0 %xmm0
214 #define XMM1 %xmm1
215 #define XMM2 %xmm2
216 #define XMM3 %xmm3
217 #define XMM4 %xmm4
218 #define XMM5 %xmm5
219 #define XMM6 %xmm6
220 #define XMM7 %xmm7
221
222 #define AS_BEGIN
223 #define USE16
224 #define USE32
225
226 #ifdef GNU_ASSEMBLER
227
228 #define ADDR_TOGGLE aword
229 #define OPSZ_TOGGLE word
230
231 #define CHOICE(a,b,c) b
232
233 #else
234 /*
235 * AT&T ASSEMBLER SYNTAX
236 * *********************
237 */
238 #define CHOICE(a,b,c) a
239
240 #define ADDR_TOGGLE addr16
241 #define OPSZ_TOGGLE data16
242
243 #endif /* GNU_ASSEMBLER */
244 #endif /* ACK_ASSEMBLER */
245
246
247 #if defined(__QNX__) || defined(Lynx) || (defined(SYSV) || defined(SVR4)) && !defined(ACK_ASSEMBLER) || defined(__ELF__) || defined(__GNU__)
248 #define GLNAME(a) a
249 #else
250 #define GLNAME(a) CONCAT(_,a)
251 #endif
252
253
254 /****************************************/
255 /* */
256 /* Select the various choices */
257 /* */
258 /****************************************/
259
260
261 /* Redefine assembler directives */
262 /*********************************/
263 #define GLOBL CHOICE(.globl, .globl, .extern)
264 #define GLOBAL GLOBL
265 #define EXTERN GLOBL
266 /*
267 #define ALIGNTEXT32 CHOICE(.align 32, .align ARG2(5,0x90), .align 32)
268 */
269 #define ALIGNTEXT32 CHOICE(.align 32, .balign 32, .align 32)
270 #define ALIGNTEXT16 CHOICE(.align 16, .balign 16, .align 16)
271 #define ALIGNTEXT8 CHOICE(.align 8, .balign 8, .align 8)
272 #define ALIGNTEXT4 CHOICE(.align 4, .balign 4, .align 4)
273 #define ALIGNTEXT2 CHOICE(.align 2, .balign 2, .align 2)
274 /* ALIGNTEXT4ifNOP is the same as ALIGNTEXT4, but only if the space is
275 * guaranteed to be filled with NOPs. Otherwise it does nothing.
276 */
277 #define ALIGNTEXT32ifNOP CHOICE(.align 32, .balign ARG2(32,0x90), /*can't do it*/)
278 #define ALIGNTEXT16ifNOP CHOICE(.align 16, .balign ARG2(16,0x90), /*can't do it*/)
279 #define ALIGNTEXT8ifNOP CHOICE(.align 8, .balign ARG2(8,0x90), /*can't do it*/)
280 #define ALIGNTEXT4ifNOP CHOICE(.align 4, .balign ARG2(4,0x90), /*can't do it*/)
281 #define ALIGNDATA32 CHOICE(.align 32, .balign ARG2(32,0x0), .align 32)
282 #define ALIGNDATA16 CHOICE(.align 16, .balign ARG2(16,0x0), .align 16)
283 #define ALIGNDATA8 CHOICE(.align 8, .balign ARG2(8,0x0), .align 8)
284 #define ALIGNDATA4 CHOICE(.align 4, .balign ARG2(4,0x0), .align 4)
285 #define ALIGNDATA2 CHOICE(.align 2, .balign ARG2(2,0x0), .align 2)
286 #define FILE(s) CHOICE(.file s, .file s, .file s)
287 #define STRING(s) CHOICE(.string s, .asciz s, .asciz s)
288 #define D_LONG CHOICE(.long, .long, .data4)
289 #define D_WORD CHOICE(.value, .short, .data2)
290 #define D_BYTE CHOICE(.byte, .byte, .data1)
291 #define SPACE CHOICE(.comm, .space, .space)
292 #define COMM CHOICE(.comm, .comm, .comm)
293 #define SEG_DATA CHOICE(.data, .data, .sect .data)
294 #define SEG_TEXT CHOICE(.text, .text, .sect .text)
295 #define SEG_BSS CHOICE(.bss, .bss, .sect .bss)
296
297 #ifdef GNU_ASSEMBLER
298 #define D_SPACE(n) . = . + n
299 #else
300 #define D_SPACE(n) .space n
301 #endif
302
303 /* Addressing Modes */
304 /* Immediate Mode */
305 #define ADDR(a) CHOICE(CONCAT($,a), CONCAT($,a), a)
306 #define CONST(a) CHOICE(CONCAT($,a), CONCAT($,a), a)
307
308 /* Indirect Mode */
309 #define CONTENT(a) CHOICE(a, a, (a)) /* take contents of variable */
310 #define REGIND(a) CHOICE((a), (a), (a)) /* Register a indirect */
311 /* Register b indirect plus displacement a */
312 #define REGOFF(a, b) CHOICE(a(b), a(b), a(b))
313 /* Reg indirect Base + Index + Displacement - this is mainly for 16-bit mode
314 * which has no scaling
315 */
316 #define REGBID(b,i,d) CHOICE(d(b,i), d(b,i), d(b)(i))
317 /* Reg indirect Base + (Index * Scale) */
318 #define REGBIS(b,i,s) CHOICE((b,i,s), (b,i,s), (b)(i*s))
319 /* Reg indirect Base + (Index * Scale) + Displacement */
320 #define REGBISD(b,i,s,d) CHOICE(d(b,i,s), d(b,i,s), d(b)(i*s))
321 /* Displaced Scaled Index: */
322 #define REGDIS(d,i,s) CHOICE(d(,i,s), d(,i,s), d(i * s))
323 /* Indexed Base: */
324 #define REGBI(b,i) CHOICE((b,i), (b,i), (b)(i))
325 /* Displaced Base: */
326 #define REGDB(d,b) CHOICE(d(b), d(b), d(b))
327 /* Variable indirect: */
328 #define VARINDIRECT(var) CHOICE(*var, *var, (var))
329 /* Use register contents as jump/call target: */
330 #define CODEPTR(reg) CHOICE(*reg, *reg, reg)
331
332 /* For expressions requiring bracketing
333 * eg. (CRT0_PM | CRT_EM)
334 */
335
336 #define EXPR(a) CHOICE([a], (a), [a])
337 #define ENOT(a) CHOICE(0!a, ~a, ~a)
338 #define EMUL(a,b) CHOICE(a\*b, a*b, a*b)
339 #define EDIV(a,b) CHOICE(a\/b, a/b, a/b)
340
341 /*
342 * We have to beat the problem of commas within arguments to choice.
343 * eg. choice (add a,b, add b,a) will get argument mismatch. Luckily ANSI
344 * and other known cpp definitions evaluate arguments before substitution
345 * so the following works.
346 */
347 #define ARG2(a, b) a,b
348 #define ARG3(a,b,c) a,b,c
349
350 /* Redefine assembler commands */
351 #define AAA CHOICE(aaa, aaa, aaa)
352 #define AAD CHOICE(aad, aad, aad)
353 #define AAM CHOICE(aam, aam, aam)
354 #define AAS CHOICE(aas, aas, aas)
355 #define ADC_L(a, b) CHOICE(adcl ARG2(a,b), adcl ARG2(a,b), _LTOG adc ARG2(b,a))
356 #define ADC_W(a, b) CHOICE(adcw ARG2(a,b), adcw ARG2(a,b), _WTOG adc ARG2(b,a))
357 #define ADC_B(a, b) CHOICE(adcb ARG2(a,b), adcb ARG2(a,b), adcb ARG2(b,a))
358 #define ADD_L(a, b) CHOICE(addl ARG2(a,b), addl ARG2(a,b), _LTOG add ARG2(b,a))
359 #define ADD_W(a, b) CHOICE(addw ARG2(a,b), addw ARG2(a,b), _WTOG add ARG2(b,a))
360 #define ADD_B(a, b) CHOICE(addb ARG2(a,b), addb ARG2(a,b), addb ARG2(b,a))
361 #define AND_L(a, b) CHOICE(andl ARG2(a,b), andl ARG2(a,b), _LTOG and ARG2(b,a))
362 #define AND_W(a, b) CHOICE(andw ARG2(a,b), andw ARG2(a,b), _WTOG and ARG2(b,a))
363 #define AND_B(a, b) CHOICE(andb ARG2(a,b), andb ARG2(a,b), andb ARG2(b,a))
364 #define ARPL(a,b) CHOICE(arpl ARG2(a,b), arpl ARG2(a,b), arpl ARG2(b,a))
365 #define BOUND_L(a, b) CHOICE(boundl ARG2(a,b), boundl ARG2(b,a), _LTOG bound ARG2(b,a))
366 #define BOUND_W(a, b) CHOICE(boundw ARG2(a,b), boundw ARG2(b,a), _WTOG bound ARG2(b,a))
367 #define BSF_L(a, b) CHOICE(bsfl ARG2(a,b), bsfl ARG2(a,b), _LTOG bsf ARG2(b,a))
368 #define BSF_W(a, b) CHOICE(bsfw ARG2(a,b), bsfw ARG2(a,b), _WTOG bsf ARG2(b,a))
369 #define BSR_L(a, b) CHOICE(bsrl ARG2(a,b), bsrl ARG2(a,b), _LTOG bsr ARG2(b,a))
370 #define BSR_W(a, b) CHOICE(bsrw ARG2(a,b), bsrw ARG2(a,b), _WTOG bsr ARG2(b,a))
371 #define BT_L(a, b) CHOICE(btl ARG2(a,b), btl ARG2(a,b), _LTOG bt ARG2(b,a))
372 #define BT_W(a, b) CHOICE(btw ARG2(a,b), btw ARG2(a,b), _WTOG bt ARG2(b,a))
373 #define BTC_L(a, b) CHOICE(btcl ARG2(a,b), btcl ARG2(a,b), _LTOG btc ARG2(b,a))
374 #define BTC_W(a, b) CHOICE(btcw ARG2(a,b), btcw ARG2(a,b), _WTOG btc ARG2(b,a))
375 #define BTR_L(a, b) CHOICE(btrl ARG2(a,b), btrl ARG2(a,b), _LTOG btr ARG2(b,a))
376 #define BTR_W(a, b) CHOICE(btrw ARG2(a,b), btrw ARG2(a,b), _WTOG btr ARG2(b,a))
377 #define BTS_L(a, b) CHOICE(btsl ARG2(a,b), btsl ARG2(a,b), _LTOG bts ARG2(b,a))
378 #define BTS_W(a, b) CHOICE(btsw ARG2(a,b), btsw ARG2(a,b), _WTOG bts ARG2(b,a))
379 #define CALL(a) CHOICE(call a, call a, call a)
380 #define CALLF(s,a) CHOICE(lcall ARG2(s,a), lcall ARG2(s,a), callf s:a)
381 #define CBW CHOICE(cbtw, cbw, cbw)
382 #define CWDE CHOICE(cwtd, cwde, cwde)
383 #define CLC CHOICE(clc, clc, clc)
384 #define CLD CHOICE(cld, cld, cld)
385 #define CLI CHOICE(cli, cli, cli)
386 #define CLTS CHOICE(clts, clts, clts)
387 #define CMC CHOICE(cmc, cmc, cmc)
388 #define CMP_L(a, b) CHOICE(cmpl ARG2(a,b), cmpl ARG2(a,b), _LTOG cmp ARG2(b,a))
389 #define CMP_W(a, b) CHOICE(cmpw ARG2(a,b), cmpw ARG2(a,b), _WTOG cmp ARG2(b,a))
390 #define CMP_B(a, b) CHOICE(cmpb ARG2(a,b), cmpb ARG2(a,b), cmpb ARG2(b,a))
391 #define CMPS_L CHOICE(cmpsl, cmpsl, _LTOG cmps)
392 #define CMPS_W CHOICE(cmpsw, cmpsw, _WTOG cmps)
393 #define CMPS_B CHOICE(cmpsb, cmpsb, cmpsb)
394 #define CWD CHOICE(cwtl, cwd, cwd)
395 #define CDQ CHOICE(cltd, cdq, cdq)
396 #define DAA CHOICE(daa, daa, daa)
397 #define DAS CHOICE(das, das, das)
398 #define DEC_L(a) CHOICE(decl a, decl a, _LTOG dec a)
399 #define DEC_W(a) CHOICE(decw a, decw a, _WTOG dec a)
400 #define DEC_B(a) CHOICE(decb a, decb a, decb a)
401 #define DIV_L(a) CHOICE(divl a, divl a, div a)
402 #define DIV_W(a) CHOICE(divw a, divw a, div a)
403 #define DIV_B(a) CHOICE(divb a, divb a, divb a)
404 #define ENTER(a,b) CHOICE(enter ARG2(a,b), enter ARG2(a,b), enter ARG2(b,a))
405 #define HLT CHOICE(hlt, hlt, hlt)
406 #define IDIV_L(a) CHOICE(idivl a, idivl a, _LTOG idiv a)
407 #define IDIV_W(a) CHOICE(idivw a, idivw a, _WTOG idiv a)
408 #define IDIV_B(a) CHOICE(idivb a, idivb a, idivb a)
409 /* More forms than this for imul!! */
410 #define IMUL_L(a, b) CHOICE(imull ARG2(a,b), imull ARG2(a,b), _LTOG imul ARG2(b,a))
411 #define IMUL_W(a, b) CHOICE(imulw ARG2(a,b), imulw ARG2(a,b), _WTOG imul ARG2(b,a))
412 #define IMUL_B(a) CHOICE(imulb a, imulb a, imulb a)
413 #define IN_L CHOICE(inl (DX), inl ARG2(DX,EAX), _LTOG in DX)
414 #define IN_W CHOICE(inw (DX), inw ARG2(DX,AX), _WTOG in DX)
415 #define IN_B CHOICE(inb (DX), inb ARG2(DX,AL), inb DX)
416 /* Please AS code writer: use the following ONLY, if you refer to ports<256
417 * directly, but not in IN1_W(DX), for instance, even if IN1_ looks nicer
418 */
419 #if defined (sun)
420 #define IN1_L(a) CHOICE(inl (a), inl ARG2(a,EAX), _LTOG in a)
421 #define IN1_W(a) CHOICE(inw (a), inw ARG2(a,AX), _WTOG in a)
422 #define IN1_B(a) CHOICE(inb (a), inb ARG2(a,AL), inb a)
423 #else
424 #define IN1_L(a) CHOICE(inl a, inl ARG2(a,EAX), _LTOG in a)
425 #define IN1_W(a) CHOICE(inw a, inw ARG2(a,AX), _WTOG in a)
426 #define IN1_B(a) CHOICE(inb a, inb ARG2(a,AL), inb a)
427 #endif
428 #define INC_L(a) CHOICE(incl a, incl a, _LTOG inc a)
429 #define INC_W(a) CHOICE(incw a, incw a, _WTOG inc a)
430 #define INC_B(a) CHOICE(incb a, incb a, incb a)
431 #define INS_L CHOICE(insl, insl, _LTOG ins)
432 #define INS_W CHOICE(insw, insw, _WTOG ins)
433 #define INS_B CHOICE(insb, insb, insb)
434 #define INT(a) CHOICE(int a, int a, int a)
435 #define INT3 CHOICE(int CONST(3), int3, int CONST(3))
436 #define INTO CHOICE(into, into, into)
437 #define IRET CHOICE(iret, iret, iret)
438 #define IRETD CHOICE(iret, iret, iretd)
439 #define JA(a) CHOICE(ja a, ja a, ja a)
440 #define JAE(a) CHOICE(jae a, jae a, jae a)
441 #define JB(a) CHOICE(jb a, jb a, jb a)
442 #define JBE(a) CHOICE(jbe a, jbe a, jbe a)
443 #define JC(a) CHOICE(jc a, jc a, jc a)
444 #define JE(a) CHOICE(je a, je a, je a)
445 #define JG(a) CHOICE(jg a, jg a, jg a)
446 #define JGE(a) CHOICE(jge a, jge a, jge a)
447 #define JL(a) CHOICE(jl a, jl a, jl a)
448 #define JLE(a) CHOICE(jle a, jle a, jle a)
449 #define JNA(a) CHOICE(jna a, jna a, jna a)
450 #define JNAE(a) CHOICE(jnae a, jnae a, jnae a)
451 #define JNB(a) CHOICE(jnb a, jnb a, jnb a)
452 #define JNBE(a) CHOICE(jnbe a, jnbe a, jnbe a)
453 #define JNC(a) CHOICE(jnc a, jnc a, jnc a)
454 #define JNE(a) CHOICE(jne a, jne a, jne a)
455 #define JNG(a) CHOICE(jng a, jng a, jng a)
456 #define JNGE(a) CHOICE(jnge a, jnge a, jnge a)
457 #define JNL(a) CHOICE(jnl a, jnl a, jnl a)
458 #define JNLE(a) CHOICE(jnle a, jnle a, jnle a)
459 #define JNO(a) CHOICE(jno a, jno a, jno a)
460 #define JNP(a) CHOICE(jnp a, jnp a, jnp a)
461 #define JNS(a) CHOICE(jns a, jns a, jns a)
462 #define JNZ(a) CHOICE(jnz a, jnz a, jnz a)
463 #define JO(a) CHOICE(jo a, jo a, jo a)
464 #define JP(a) CHOICE(jp a, jp a, jp a)
465 #define JPE(a) CHOICE(jpe a, jpe a, jpe a)
466 #define JPO(a) CHOICE(jpo a, jpo a, jpo a)
467 #define JS(a) CHOICE(js a, js a, js a)
468 #define JZ(a) CHOICE(jz a, jz a, jz a)
469 #define JMP(a) CHOICE(jmp a, jmp a, jmp a)
470 #define JMPF(s,a) CHOICE(ljmp ARG2(s,a), ljmp ARG2(s,a), jmpf s:a)
471 #define LAHF CHOICE(lahf, lahf, lahf)
472 #if !defined(_REAL_MODE) && !defined(_V86_MODE)
473 #define LAR(a, b) CHOICE(lar ARG2(a, b), lar ARG2(a, b), lar ARG2(b, a))
474 #endif
475 #define LEA_L(a, b) CHOICE(leal ARG2(a,b), leal ARG2(a,b), _LTOG lea ARG2(b,a))
476 #define LEA_W(a, b) CHOICE(leaw ARG2(a,b), leaw ARG2(a,b), _WTOG lea ARG2(b,a))
477 #define LEAVE CHOICE(leave, leave, leave)
478 #define LGDT(a) CHOICE(lgdt a, lgdt a, lgdt a)
479 #define LIDT(a) CHOICE(lidt a, lidt a, lidt a)
480 #define LDS(a, b) CHOICE(ldsl ARG2(a,b), lds ARG2(a,b), lds ARG2(b,a))
481 #define LES(a, b) CHOICE(lesl ARG2(a,b), les ARG2(a,b), les ARG2(b,a))
482 #define LFS(a, b) CHOICE(lfsl ARG2(a,b), lfs ARG2(a,b), lfs ARG2(b,a))
483 #define LGS(a, b) CHOICE(lgsl ARG2(a,b), lgs ARG2(a,b), lgs ARG2(b,a))
484 #define LSS(a, b) CHOICE(lssl ARG2(a,b), lss ARG2(a,b), lss ARG2(b,a))
485 #define LLDT(a) CHOICE(lldt a, lldt a, lldt a)
486 #define LMSW(a) CHOICE(lmsw a, lmsw a, lmsw a)
487 #define LOCK CHOICE(lock, lock, lock)
488 #define LODS_L CHOICE(lodsl, lodsl, _LTOG lods)
489 #define LODS_W CHOICE(lodsw, lodsw, _WTOG lods)
490 #define LODS_B CHOICE(lodsb, lodsb, lodsb)
491 #define LOOP(a) CHOICE(loop a, loop a, loop a)
492 #define LOOPE(a) CHOICE(loope a, loope a, loope a)
493 #define LOOPZ(a) CHOICE(loopz a, loopz a, loopz a)
494 #define LOOPNE(a) CHOICE(loopne a, loopne a, loopne a)
495 #define LOOPNZ(a) CHOICE(loopnz a, loopnz a, loopnz a)
496 #if !defined(_REAL_MODE) && !defined(_V86_MODE)
497 #define LSL(a, b) CHOICE(lsl ARG2(a,b), lsl ARG2(a,b), lsl ARG2(b,a))
498 #endif
499 #define LTR(a) CHOICE(ltr a, ltr a, ltr a)
500 #define MOV_SR(a, b) CHOICE(movw ARG2(a,b), mov ARG2(a,b), mov ARG2(b,a))
501 #define MOV_L(a, b) CHOICE(movl ARG2(a,b), movl ARG2(a,b), _LTOG mov ARG2(b,a))
502 #define MOV_W(a, b) CHOICE(movw ARG2(a,b), movw ARG2(a,b), _WTOG mov ARG2(b,a))
503 #define MOV_B(a, b) CHOICE(movb ARG2(a,b), movb ARG2(a,b), movb ARG2(b,a))
504 #define MOVS_L CHOICE(movsl, movsl, _LTOG movs)
505 #define MOVS_W CHOICE(movsw, movsw, _WTOG movs)
506 #define MOVS_B CHOICE(movsb, movsb, movsb)
507 #define MOVSX_BL(a, b) CHOICE(movsbl ARG2(a,b), movsbl ARG2(a,b), movsx ARG2(b,a))
508 #define MOVSX_BW(a, b) CHOICE(movsbw ARG2(a,b), movsbw ARG2(a,b), movsx ARG2(b,a))
509 #define MOVSX_WL(a, b) CHOICE(movswl ARG2(a,b), movswl ARG2(a,b), movsx ARG2(b,a))
510 #define MOVZX_BL(a, b) CHOICE(movzbl ARG2(a,b), movzbl ARG2(a,b), movzx ARG2(b,a))
511 #define MOVZX_BW(a, b) CHOICE(movzbw ARG2(a,b), movzbw ARG2(a,b), movzx ARG2(b,a))
512 #define MOVZX_WL(a, b) CHOICE(movzwl ARG2(a,b), movzwl ARG2(a,b), movzx ARG2(b,a))
513 #define MUL_L(a) CHOICE(mull a, mull a, _LTOG mul a)
514 #define MUL_W(a) CHOICE(mulw a, mulw a, _WTOG mul a)
515 #define MUL_B(a) CHOICE(mulb a, mulb a, mulb a)
516 #define NEG_L(a) CHOICE(negl a, negl a, _LTOG neg a)
517 #define NEG_W(a) CHOICE(negw a, negw a, _WTOG neg a)
518 #define NEG_B(a) CHOICE(negb a, negb a, negb a)
519 #define NOP CHOICE(nop, nop, nop)
520 #define NOT_L(a) CHOICE(notl a, notl a, _LTOG not a)
521 #define NOT_W(a) CHOICE(notw a, notw a, _WTOG not a)
522 #define NOT_B(a) CHOICE(notb a, notb a, notb a)
523 #define OR_L(a,b) CHOICE(orl ARG2(a,b), orl ARG2(a,b), _LTOG or ARG2(b,a))
524 #define OR_W(a,b) CHOICE(orw ARG2(a,b), orw ARG2(a,b), _WTOG or ARG2(b,a))
525 #define OR_B(a,b) CHOICE(orb ARG2(a,b), orb ARG2(a,b), orb ARG2(b,a))
526 #define OUT_L CHOICE(outl (DX), outl ARG2(EAX,DX), _LTOG out DX)
527 #define OUT_W CHOICE(outw (DX), outw ARG2(AX,DX), _WTOG out DX)
528 #define OUT_B CHOICE(outb (DX), outb ARG2(AL,DX), outb DX)
529 /* Please AS code writer: use the following ONLY, if you refer to ports<256
530 * directly, but not in OUT1_W(DX), for instance, even if OUT1_ looks nicer
531 */
532 #define OUT1_L(a) CHOICE(outl (a), outl ARG2(EAX,a), _LTOG out a)
533 #define OUT1_W(a) CHOICE(outw (a), outw ARG2(AX,a), _WTOG out a)
534 #define OUT1_B(a) CHOICE(outb (a), outb ARG2(AL,a), outb a)
535 #define OUTS_L CHOICE(outsl, outsl, _LTOG outs)
536 #define OUTS_W CHOICE(outsw, outsw, _WTOG outs)
537 #define OUTS_B CHOICE(outsb, outsb, outsb)
538 #define POP_SR(a) CHOICE(pop a, pop a, pop a)
539 #define POP_L(a) CHOICE(popl a, popl a, _LTOG pop a)
540 #define POP_W(a) CHOICE(popw a, popw a, _WTOG pop a)
541 #define POPA_L CHOICE(popal, popal, _LTOG popa)
542 #define POPA_W CHOICE(popaw, popaw, _WTOG popa)
543 #define POPF_L CHOICE(popfl, popfl, _LTOG popf)
544 #define POPF_W CHOICE(popfw, popfw, _WTOG popf)
545 #define PUSH_SR(a) CHOICE(push a, push a, push a)
546 #define PUSH_L(a) CHOICE(pushl a, pushl a, _LTOG push a)
547 #define PUSH_W(a) CHOICE(pushw a, pushw a, _WTOG push a)
548 #define PUSH_B(a) CHOICE(push a, pushb a, push a)
549 #define PUSHA_L CHOICE(pushal, pushal, _LTOG pusha)
550 #define PUSHA_W CHOICE(pushaw, pushaw, _WTOG pusha)
551 #define PUSHF_L CHOICE(pushfl, pushfl, _LTOG pushf)
552 #define PUSHF_W CHOICE(pushfw, pushfw, _WTOG pushf)
553 #define RCL_L(a, b) CHOICE(rcll ARG2(a,b), rcll ARG2(a,b), _LTOG rcl ARG2(b,a))
554 #define RCL_W(a, b) CHOICE(rclw ARG2(a,b), rclw ARG2(a,b), _WTOG rcl ARG2(b,a))
555 #define RCL_B(a, b) CHOICE(rclb ARG2(a,b), rclb ARG2(a,b), rclb ARG2(b,a))
556 #define RCR_L(a, b) CHOICE(rcrl ARG2(a,b), rcrl ARG2(a,b), _LTOG rcr ARG2(b,a))
557 #define RCR_W(a, b) CHOICE(rcrw ARG2(a,b), rcrw ARG2(a,b), _WTOG rcr ARG2(b,a))
558 #define RCR_B(a, b) CHOICE(rcrb ARG2(a,b), rcrb ARG2(a,b), rcrb ARG2(b,a))
559 #define ROL_L(a, b) CHOICE(roll ARG2(a,b), roll ARG2(a,b), _LTOG rol ARG2(b,a))
560 #define ROL_W(a, b) CHOICE(rolw ARG2(a,b), rolw ARG2(a,b), _WTOG rol ARG2(b,a))
561 #define ROL_B(a, b) CHOICE(rolb ARG2(a,b), rolb ARG2(a,b), rolb ARG2(b,a))
562 #define ROR_L(a, b) CHOICE(rorl ARG2(a,b), rorl ARG2(a,b), _LTOG ror ARG2(b,a))
563 #define ROR_W(a, b) CHOICE(rorw ARG2(a,b), rorw ARG2(a,b), _WTOG ror ARG2(b,a))
564 #define ROR_B(a, b) CHOICE(rorb ARG2(a,b), rorb ARG2(a,b), rorb ARG2(b,a))
565 #define REP CHOICE(rep ;, rep ;, repe)
566 #define REPE CHOICE(repz ;, repe ;, repe)
567 #define REPNE CHOICE(repnz ;, repne ;, repne)
568 #define REPNZ REPNE
569 #define REPZ REPE
570 #define RET CHOICE(ret, ret, ret)
571 #define SAHF CHOICE(sahf, sahf, sahf)
572 #define SAL_L(a, b) CHOICE(sall ARG2(a,b), sall ARG2(a,b), _LTOG sal ARG2(b,a))
573 #define SAL_W(a, b) CHOICE(salw ARG2(a,b), salw ARG2(a,b), _WTOG sal ARG2(b,a))
574 #define SAL_B(a, b) CHOICE(salb ARG2(a,b), salb ARG2(a,b), salb ARG2(b,a))
575 #define SAR_L(a, b) CHOICE(sarl ARG2(a,b), sarl ARG2(a,b), _LTOG sar ARG2(b,a))
576 #define SAR_W(a, b) CHOICE(sarw ARG2(a,b), sarw ARG2(a,b), _WTOG sar ARG2(b,a))
577 #define SAR_B(a, b) CHOICE(sarb ARG2(a,b), sarb ARG2(a,b), sarb ARG2(b,a))
578 #define SBB_L(a, b) CHOICE(sbbl ARG2(a,b), sbbl ARG2(a,b), _LTOG sbb ARG2(b,a))
579 #define SBB_W(a, b) CHOICE(sbbw ARG2(a,b), sbbw ARG2(a,b), _WTOG sbb ARG2(b,a))
580 #define SBB_B(a, b) CHOICE(sbbb ARG2(a,b), sbbb ARG2(a,b), sbbb ARG2(b,a))
581 #define SCAS_L CHOICE(scasl, scasl, _LTOG scas)
582 #define SCAS_W CHOICE(scasw, scasw, _WTOG scas)
583 #define SCAS_B CHOICE(scasb, scasb, scasb)
584 #define SETA(a) CHOICE(seta a, seta a, seta a)
585 #define SETAE(a) CHOICE(setae a, setae a, setae a)
586 #define SETB(a) CHOICE(setb a, setb a, setb a)
587 #define SETBE(a) CHOICE(setbe a, setbe a, setbe a)
588 #define SETC(a) CHOICE(setc a, setb a, setb a)
589 #define SETE(a) CHOICE(sete a, sete a, sete a)
590 #define SETG(a) CHOICE(setg a, setg a, setg a)
591 #define SETGE(a) CHOICE(setge a, setge a, setge a)
592 #define SETL(a) CHOICE(setl a, setl a, setl a)
593 #define SETLE(a) CHOICE(setle a, setle a, setle a)
594 #define SETNA(a) CHOICE(setna a, setna a, setna a)
595 #define SETNAE(a) CHOICE(setnae a, setnae a, setnae a)
596 #define SETNB(a) CHOICE(setnb a, setnb a, setnb a)
597 #define SETNBE(a) CHOICE(setnbe a, setnbe a, setnbe a)
598 #define SETNC(a) CHOICE(setnc a, setnb a, setnb a)
599 #define SETNE(a) CHOICE(setne a, setne a, setne a)
600 #define SETNG(a) CHOICE(setng a, setng a, setng a)
601 #define SETNGE(a) CHOICE(setnge a, setnge a, setnge a)
602 #define SETNL(a) CHOICE(setnl a, setnl a, setnl a)
603 #define SETNLE(a) CHOICE(setnle a, setnle a, setnle a)
604 #define SETNO(a) CHOICE(setno a, setno a, setno a)
605 #define SETNP(a) CHOICE(setnp a, setnp a, setnp a)
606 #define SETNS(a) CHOICE(setns a, setns a, setna a)
607 #define SETNZ(a) CHOICE(setnz a, setnz a, setnz a)
608 #define SETO(a) CHOICE(seto a, seto a, seto a)
609 #define SETP(a) CHOICE(setp a, setp a, setp a)
610 #define SETPE(a) CHOICE(setpe a, setpe a, setpe a)
611 #define SETPO(a) CHOICE(setpo a, setpo a, setpo a)
612 #define SETS(a) CHOICE(sets a, sets a, seta a)
613 #define SETZ(a) CHOICE(setz a, setz a, setz a)
614 #define SGDT(a) CHOICE(sgdt a, sgdt a, sgdt a)
615 #define SIDT(a) CHOICE(sidt a, sidt a, sidt a)
616 #define SHL_L(a, b) CHOICE(shll ARG2(a,b), shll ARG2(a,b), _LTOG shl ARG2(b,a))
617 #define SHL_W(a, b) CHOICE(shlw ARG2(a,b), shlw ARG2(a,b), _WTOG shl ARG2(b,a))
618 #define SHL_B(a, b) CHOICE(shlb ARG2(a,b), shlb ARG2(a,b), shlb ARG2(b,a))
619 #define SHLD_L(a,b,c) CHOICE(shldl ARG3(a,b,c), shldl ARG3(a,b,c), _LTOG shld ARG3(c,b,a))
620 #define SHLD2_L(a,b) CHOICE(shldl ARG2(a,b), shldl ARG3(CL,a,b), _LTOG shld ARG3(b,a,CL))
621 #define SHLD_W(a,b,c) CHOICE(shldw ARG3(a,b,c), shldw ARG3(a,b,c), _WTOG shld ARG3(c,b,a))
622 #define SHLD2_W(a,b) CHOICE(shldw ARG2(a,b), shldw ARG3(CL,a,b), _WTOG shld ARG3(b,a,CL))
623 #define SHR_L(a, b) CHOICE(shrl ARG2(a,b), shrl ARG2(a,b), _LTOG shr ARG2(b,a))
624 #define SHR_W(a, b) CHOICE(shrw ARG2(a,b), shrw ARG2(a,b), _WTOG shr ARG2(b,a))
625 #define SHR_B(a, b) CHOICE(shrb ARG2(a,b), shrb ARG2(a,b), shrb ARG2(b,a))
626 #define SHRD_L(a,b,c) CHOICE(shrdl ARG3(a,b,c), shrdl ARG3(a,b,c), _LTOG shrd ARG3(c,b,a))
627 #define SHRD2_L(a,b) CHOICE(shrdl ARG2(a,b), shrdl ARG3(CL,a,b), _LTOG shrd ARG3(b,a,CL))
628 #define SHRD_W(a,b,c) CHOICE(shrdw ARG3(a,b,c), shrdw ARG3(a,b,c), _WTOG shrd ARG3(c,b,a))
629 #define SHRD2_W(a,b) CHOICE(shrdw ARG2(a,b), shrdw ARG3(CL,a,b), _WTOG shrd ARG3(b,a,CL))
630 #define SLDT(a) CHOICE(sldt a, sldt a, sldt a)
631 #define SMSW(a) CHOICE(smsw a, smsw a, smsw a)
632 #define STC CHOICE(stc, stc, stc)
633 #define STD CHOICE(std, std, std)
634 #define STI CHOICE(sti, sti, sti)
635 #define STOS_L CHOICE(stosl, stosl, _LTOG stos)
636 #define STOS_W CHOICE(stosw, stosw, _WTOG stos)
637 #define STOS_B CHOICE(stosb, stosb, stosb)
638 #define STR(a) CHOICE(str a, str a, str a)
639 #define SUB_L(a, b) CHOICE(subl ARG2(a,b), subl ARG2(a,b), _LTOG sub ARG2(b,a))
640 #define SUB_W(a, b) CHOICE(subw ARG2(a,b), subw ARG2(a,b), _WTOG sub ARG2(b,a))
641 #define SUB_B(a, b) CHOICE(subb ARG2(a,b), subb ARG2(a,b), subb ARG2(b,a))
642 #define TEST_L(a, b) CHOICE(testl ARG2(a,b), testl ARG2(a,b), _LTOG test ARG2(b,a))
643 #define TEST_W(a, b) CHOICE(testw ARG2(a,b), testw ARG2(a,b), _WTOG test ARG2(b,a))
644 #define TEST_B(a, b) CHOICE(testb ARG2(a,b), testb ARG2(a,b), testb ARG2(b,a))
645 #define VERR(a) CHOICE(verr a, verr a, verr a)
646 #define VERW(a) CHOICE(verw a, verw a, verw a)
647 #define WAIT CHOICE(wait, wait, wait)
648 #define XCHG_L(a, b) CHOICE(xchgl ARG2(a,b), xchgl ARG2(a,b), _LTOG xchg ARG2(b,a))
649 #define XCHG_W(a, b) CHOICE(xchgw ARG2(a,b), xchgw ARG2(a,b), _WTOG xchg ARG2(b,a))
650 #define XCHG_B(a, b) CHOICE(xchgb ARG2(a,b), xchgb ARG2(a,b), xchgb ARG2(b,a))
651 #define XLAT CHOICE(xlat, xlat, xlat)
652 #define XOR_L(a, b) CHOICE(xorl ARG2(a,b), xorl ARG2(a,b), _LTOG xor ARG2(b,a))
653 #define XOR_W(a, b) CHOICE(xorw ARG2(a,b), xorw ARG2(a,b), _WTOG xor ARG2(b,a))
654 #define XOR_B(a, b) CHOICE(xorb ARG2(a,b), xorb ARG2(a,b), xorb ARG2(b,a))
655
656
657 /* Floating Point Instructions */
658 #define F2XM1 CHOICE(f2xm1, f2xm1, f2xm1)
659 #define FABS CHOICE(fabs, fabs, fabs)
660 #define FADD_D(a) CHOICE(faddl a, faddl a, faddd a)
661 #define FADD_S(a) CHOICE(fadds a, fadds a, fadds a)
662 #define FADD2(a, b) CHOICE(fadd ARG2(a,b), fadd ARG2(a,b), fadd ARG2(b,a))
663 #define FADDP(a, b) CHOICE(faddp ARG2(a,b), faddp ARG2(a,b), faddp ARG2(b,a))
664 #define FIADD_L(a) CHOICE(fiaddl a, fiaddl a, fiaddl a)
665 #define FIADD_W(a) CHOICE(fiadd a, fiadds a, fiadds a)
666 #define FBLD(a) CHOICE(fbld a, fbld a, fbld a)
667 #define FBSTP(a) CHOICE(fbstp a, fbstp a, fbstp a)
668 #define FCHS CHOICE(fchs, fchs, fchs)
669 #define FCLEX CHOICE(fclex, wait; fnclex, wait; fclex)
670 #define FNCLEX CHOICE(fnclex, fnclex, fclex)
671 #define FCOM(a) CHOICE(fcom a, fcom a, fcom a)
672 #define FCOM_D(a) CHOICE(fcoml a, fcoml a, fcomd a)
673 #define FCOM_S(a) CHOICE(fcoms a, fcoms a, fcoms a)
674 #define FCOMP(a) CHOICE(fcomp a, fcomp a, fcomp a)
675 #define FCOMP_D(a) CHOICE(fcompl a, fcompl a, fcompd a)
676 #define FCOMP_S(a) CHOICE(fcomps a, fcomps a, fcomps a)
677 #define FCOMPP CHOICE(fcompp, fcompp, fcompp)
678 #define FCOS CHOICE(fcos, fcos, fcos)
679 #define FDECSTP CHOICE(fdecstp, fdecstp, fdecstp)
680 #define FDIV_D(a) CHOICE(fdivl a, fdivl a, fdivd a)
681 #define FDIV_S(a) CHOICE(fdivs a, fdivs a, fdivs a)
682 #define FDIV2(a, b) CHOICE(fdiv ARG2(a,b), fdiv ARG2(a,b), fdiv ARG2(b,a))
683 #define FDIVP(a, b) CHOICE(fdivp ARG2(a,b), fdivp ARG2(a,b), fdivp ARG2(b,a))
684 #define FIDIV_L(a) CHOICE(fidivl a, fidivl a, fidivl a)
685 #define FIDIV_W(a) CHOICE(fidiv a, fidivs a, fidivs a)
686 #define FDIVR_D(a) CHOICE(fdivrl a, fdivrl a, fdivrd a)
687 #define FDIVR_S(a) CHOICE(fdivrs a, fdivrs a, fdivrs a)
688 #define FDIVR2(a, b) CHOICE(fdivr ARG2(a,b), fdivr ARG2(a,b), fdivr ARG2(b,a))
689 #define FDIVRP(a, b) CHOICE(fdivrp ARG2(a,b), fdivrp ARG2(a,b), fdivrp ARG2(b,a))
690 #define FIDIVR_L(a) CHOICE(fidivrl a, fidivrl a, fidivrl a)
691 #define FIDIVR_W(a) CHOICE(fidivr a, fidivrs a, fidivrs a)
692 #define FFREE(a) CHOICE(ffree a, ffree a, ffree a)
693 #define FICOM_L(a) CHOICE(ficoml a, ficoml a, ficoml a)
694 #define FICOM_W(a) CHOICE(ficom a, ficoms a, ficoms a)
695 #define FICOMP_L(a) CHOICE(ficompl a, ficompl a, ficompl a)
696 #define FICOMP_W(a) CHOICE(ficomp a, ficomps a, ficomps a)
697 #define FILD_Q(a) CHOICE(fildll a, fildq a, fildq a)
698 #define FILD_L(a) CHOICE(fildl a, fildl a, fildl a)
699 #define FILD_W(a) CHOICE(fild a, filds a, filds a)
700 #define FINCSTP CHOICE(fincstp, fincstp, fincstp)
701 #define FINIT CHOICE(finit, wait; fninit, wait; finit)
702 #define FNINIT CHOICE(fninit, fninit, finit)
703 #define FIST_L(a) CHOICE(fistl a, fistl a, fistl a)
704 #define FIST_W(a) CHOICE(fist a, fists a, fists a)
705 #define FISTP_Q(a) CHOICE(fistpll a, fistpq a, fistpq a)
706 #define FISTP_L(a) CHOICE(fistpl a, fistpl a, fistpl a)
707 #define FISTP_W(a) CHOICE(fistp a, fistps a, fistps a)
708 #define FLD_X(a) CHOICE(fldt a, fldt a, fldx a) /* 80 bit data type! */
709 #define FLD_D(a) CHOICE(fldl a, fldl a, fldd a)
710 #define FLD_S(a) CHOICE(flds a, flds a, flds a)
711 #define FLD1 CHOICE(fld1, fld1, fld1)
712 #define FLDL2T CHOICE(fldl2t, fldl2t, fldl2t)
713 #define FLDL2E CHOICE(fldl2e, fldl2e, fldl2e)
714 #define FLDPI CHOICE(fldpi, fldpi, fldpi)
715 #define FLDLG2 CHOICE(fldlg2, fldlg2, fldlg2)
716 #define FLDLN2 CHOICE(fldln2, fldln2, fldln2)
717 #define FLDZ CHOICE(fldz, fldz, fldz)
718 #define FLDCW(a) CHOICE(fldcw a, fldcw a, fldcw a)
719 #define FLDENV(a) CHOICE(fldenv a, fldenv a, fldenv a)
720 #define FMUL_S(a) CHOICE(fmuls a, fmuls a, fmuls a)
721 #define FMUL_D(a) CHOICE(fmull a, fmull a, fmuld a)
722 #define FMUL2(a, b) CHOICE(fmul ARG2(a,b), fmul ARG2(a,b), fmul ARG2(b,a))
723 #define FMULP(a, b) CHOICE(fmulp ARG2(a,b), fmulp ARG2(a,b), fmulp ARG2(b,a))
724 #define FIMUL_L(a) CHOICE(fimull a, fimull a, fimull a)
725 #define FIMUL_W(a) CHOICE(fimul a, fimuls a, fimuls a)
726 #define FNOP CHOICE(fnop, fnop, fnop)
727 #define FPATAN CHOICE(fpatan, fpatan, fpatan)
728 #define FPREM CHOICE(fprem, fprem, fprem)
729 #define FPREM1 CHOICE(fprem1, fprem1, fprem1)
730 #define FPTAN CHOICE(fptan, fptan, fptan)
731 #define FRNDINT CHOICE(frndint, frndint, frndint)
732 #define FRSTOR(a) CHOICE(frstor a, frstor a, frstor a)
733 #define FSAVE(a) CHOICE(fsave a, wait; fnsave a, wait; fsave a)
734 #define FNSAVE(a) CHOICE(fnsave a, fnsave a, fsave a)
735 #define FSCALE CHOICE(fscale, fscale, fscale)
736 #define FSIN CHOICE(fsin, fsin, fsin)
737 #define FSINCOS CHOICE(fsincos, fsincos, fsincos)
738 #define FSQRT CHOICE(fsqrt, fsqrt, fsqrt)
739 #define FST_D(a) CHOICE(fstl a, fstl a, fstd a)
740 #define FST_S(a) CHOICE(fsts a, fsts a, fsts a)
741 #define FSTP_X(a) CHOICE(fstpt a, fstpt a, fstpx a)
742 #define FSTP_D(a) CHOICE(fstpl a, fstpl a, fstpd a)
743 #define FSTP_S(a) CHOICE(fstps a, fstps a, fstps a)
744 #define FSTP(a) CHOICE(fstp a, fstp a, fstp a)
745 #define FSTCW(a) CHOICE(fstcw a, wait; fnstcw a, wait; fstcw a)
746 #define FNSTCW(a) CHOICE(fnstcw a, fnstcw a, fstcw a)
747 #define FSTENV(a) CHOICE(fstenv a, wait; fnstenv a, fstenv a)
748 #define FNSTENV(a) CHOICE(fnstenv a, fnstenv a, fstenv a)
749 #define FSTSW(a) CHOICE(fstsw a, wait; fnstsw a, wait; fstsw a)
750 #define FNSTSW(a) CHOICE(fnstsw a, fnstsw a, fstsw a)
751 #define FSUB_S(a) CHOICE(fsubs a, fsubs a, fsubs a)
752 #define FSUB_D(a) CHOICE(fsubl a, fsubl a, fsubd a)
753 #define FSUB2(a, b) CHOICE(fsub ARG2(a,b), fsub ARG2(a,b), fsub ARG2(b,a))
754 #define FSUBP(a, b) CHOICE(fsubp ARG2(a,b), fsubp ARG2(a,b), fsubp ARG2(b,a))
755 #define FISUB_L(a) CHOICE(fisubl a, fisubl a, fisubl a)
756 #define FISUB_W(a) CHOICE(fisub a, fisubs a, fisubs a)
757 #define FSUBR_S(a) CHOICE(fsubrs a, fsubrs a, fsubrs a)
758 #define FSUBR_D(a) CHOICE(fsubrl a, fsubrl a, fsubrd a)
759 #define FSUBR2(a, b) CHOICE(fsubr ARG2(a,b), fsubr ARG2(a,b), fsubr ARG2(b,a))
760 #define FSUBRP(a, b) CHOICE(fsubrp ARG2(a,b), fsubrp ARG2(a,b), fsubrp ARG2(b,a))
761 #define FISUBR_L(a) CHOICE(fisubrl a, fisubrl a, fisubrl a)
762 #define FISUBR_W(a) CHOICE(fisubr a, fisubrs a, fisubrs a)
763 #define FTST CHOICE(ftst, ftst, ftst)
764 #define FUCOM(a) CHOICE(fucom a, fucom a, fucom a)
765 #define FUCOMP(a) CHOICE(fucomp a, fucomp a, fucomp a)
766 #define FUCOMPP CHOICE(fucompp, fucompp, fucompp)
767 #define FWAIT CHOICE(wait, wait, wait)
768 #define FXAM CHOICE(fxam, fxam, fxam)
769 #define FXCH(a) CHOICE(fxch a, fxch a, fxch a)
770 #define FXTRACT CHOICE(fxtract, fxtract, fxtract)
771 #define FYL2X CHOICE(fyl2x, fyl2x, fyl2x)
772 #define FYL2XP1 CHOICE(fyl2xp1, fyl2xp1, fyl2xp1)
773
774 /* New instructions */
775 #define CPUID CHOICE(D_BYTE ARG2(15, 162), cpuid, D_BYTE ARG2(15, 162))
776 #define RDTSC CHOICE(D_BYTE ARG2(15, 49), rdtsc, D_BYTE ARG2(15, 49))
777
778 #else /* NASM_ASSEMBLER || MASM_ASSEMBLER is defined */
779
780 /****************************************/
781 /* */
782 /* Intel style assemblers. */
783 /* (NASM and MASM) */
784 /* */
785 /****************************************/
786
787 #define P_EAX EAX
788 #define L_EAX EAX
789 #define W_AX AX
790 #define B_AH AH
791 #define B_AL AL
792
793 #define P_EBX EBX
794 #define L_EBX EBX
795 #define W_BX BX
796 #define B_BH BH
797 #define B_BL BL
798
799 #define P_ECX ECX
800 #define L_ECX ECX
801 #define W_CX CX
802 #define B_CH CH
803 #define B_CL CL
804
805 #define P_EDX EDX
806 #define L_EDX EDX
807 #define W_DX DX
808 #define B_DH DH
809 #define B_DL DL
810
811 #define P_EBP EBP
812 #define L_EBP EBP
813 #define W_BP BP
814
815 #define P_ESI ESI
816 #define L_ESI ESI
817 #define W_SI SI
818
819 #define P_EDI EDI
820 #define L_EDI EDI
821 #define W_DI DI
822
823 #define P_ESP ESP
824 #define L_ESP ESP
825 #define W_SP SP
826
827 #define W_CS CS
828 #define W_SS SS
829 #define W_DS DS
830 #define W_ES ES
831 #define W_FS FS
832 #define W_GS GS
833
834 #define X_ST ST
835 #define D_ST ST
836 #define L_ST ST
837
838 #define P_MM0 mm0
839 #define P_MM1 mm1
840 #define P_MM2 mm2
841 #define P_MM3 mm3
842 #define P_MM4 mm4
843 #define P_MM5 mm5
844 #define P_MM6 mm6
845 #define P_MM7 mm7
846
847 #define P_XMM0 xmm0
848 #define P_XMM1 xmm1
849 #define P_XMM2 xmm2
850 #define P_XMM3 xmm3
851 #define P_XMM4 xmm4
852 #define P_XMM5 xmm5
853 #define P_XMM6 xmm6
854 #define P_XMM7 xmm7
855
856 #define CONCAT(x, y) x ## y
857
858 #if defined(NASM_ASSEMBLER)
859
860 #define ST(n) st ## n
861
862 #define TBYTE_PTR tword
863 #define QWORD_PTR qword
864 #define DWORD_PTR dword
865 #define WORD_PTR word
866 #define BYTE_PTR byte
867
868 #define OFFSET
869
870 #define GLOBL GLOBAL
871 #define ALIGNTEXT32 ALIGN 32
872 #define ALIGNTEXT16 ALIGN 16
873 #define ALIGNTEXT8 ALIGN 8
874 #define ALIGNTEXT4 ALIGN 4
875 #define ALIGNTEXT2 ALIGN 2
876 #define ALIGNTEXT32ifNOP ALIGN 32
877 #define ALIGNTEXT16ifNOP ALIGN 16
878 #define ALIGNTEXT8ifNOP ALIGN 8
879 #define ALIGNTEXT4ifNOP ALIGN 4
880 #define ALIGNDATA32 ALIGN 32
881 #define ALIGNDATA16 ALIGN 16
882 #define ALIGNDATA8 ALIGN 8
883 #define ALIGNDATA4 ALIGN 4
884 #define ALIGNDATA2 ALIGN 2
885 #define FILE(s)
886 #define STRING(s) db s
887 #define D_LONG dd
888 #define D_WORD dw
889 #define D_BYTE db
890 /* #define SPACE */
891 /* #define COMM */
892 #if defined(__WATCOMC__)
893 SECTION _TEXT public align=16 class=CODE use32 flat
894 SECTION _DATA public align=16 class=DATA use32 flat
895 #define SEG_TEXT SECTION _TEXT
896 #define SEG_DATA SECTION _DATA
897 #define SEG_BSS SECTION .bss
898 #else
899 #define SEG_DATA SECTION .data
900 #define SEG_TEXT SECTION .text
901 #define SEG_BSS SECTION .bss
902 #endif
903
904 #define D_SPACE(n) db n REP 0
905
906 #define AS_BEGIN
907
908 /* Jcc's should be handled better than this... */
909 #define NEAR near
910
911 #else /* MASM */
912
913 #define TBYTE_PTR tbyte ptr
914 #define QWORD_PTR qword ptr
915 #define DWORD_PTR dword ptr
916 #define WORD_PTR word ptr
917 #define BYTE_PTR byte ptr
918
919 #define OFFSET offset
920
921 #define GLOBL GLOBAL
922 #define ALIGNTEXT32 ALIGN 32
923 #define ALIGNTEXT16 ALIGN 16
924 #define ALIGNTEXT8 ALIGN 8
925 #define ALIGNTEXT4 ALIGN 4
926 #define ALIGNTEXT2 ALIGN 2
927 #define ALIGNTEXT32ifNOP ALIGN 32
928 #define ALIGNTEXT16ifNOP ALIGN 16
929 #define ALIGNTEXT8ifNOP ALIGN 8
930 #define ALIGNTEXT4ifNOP ALIGN 4
931 #define ALIGNDATA32 ALIGN 32
932 #define ALIGNDATA16 ALIGN 16
933 #define ALIGNDATA8 ALIGN 8
934 #define ALIGNDATA4 ALIGN 4
935 #define ALIGNDATA2 ALIGN 2
936 #define FILE(s)
937 #define STRING(s) db s
938 #define D_LONG dd
939 #define D_WORD dw
940 #define D_BYTE db
941 /* #define SPACE */
942 /* #define COMM */
943 #define SEG_DATA .DATA
944 #define SEG_TEXT .CODE
945 #define SEG_BSS .DATA
946
947 #define D_SPACE(n) db n REP 0
948
949 #define AS_BEGIN
950
951 #define NEAR
952
953 #endif
954
955 #if defined(Lynx) || (defined(SYSV) || defined(SVR4)) \
956 || (defined(linux) || defined(__OS2ELF__)) && defined(__ELF__) \
957 || defined(__FreeBSD__) && __FreeBSD__ >= 3
958 #define GLNAME(a) a
959 #else
960 #define GLNAME(a) _ ## a
961 #endif
962
963 /*
964 * Addressing Modes
965 */
966
967 /* Immediate Mode */
968 #define P_ADDR(a) OFFSET a
969 #define X_ADDR(a) OFFSET a
970 #define D_ADDR(a) OFFSET a
971 #define L_ADDR(a) OFFSET a
972 #define W_ADDR(a) OFFSET a
973 #define B_ADDR(a) OFFSET a
974
975 #define P_CONST(a) a
976 #define X_CONST(a) a
977 #define D_CONST(a) a
978 #define L_CONST(a) a
979 #define W_CONST(a) a
980 #define B_CONST(a) a
981
982 /* Indirect Mode */
983 #define P_CONTENT(a) a
984 #define X_CONTENT(a) TBYTE_PTR a
985 #define D_CONTENT(a) QWORD_PTR a
986 #define L_CONTENT(a) DWORD_PTR a
987 #define W_CONTENT(a) WORD_PTR a
988 #define B_CONTENT(a) BYTE_PTR a
989
990 /* Register a indirect */
991 #define P_REGIND(a) [a]
992 #define X_REGIND(a) TBYTE_PTR [a]
993 #define D_REGIND(a) QWORD_PTR [a]
994 #define L_REGIND(a) DWORD_PTR [a]
995 #define W_REGIND(a) WORD_PTR [a]
996 #define B_REGIND(a) BYTE_PTR [a]
997
998 /* Register b indirect plus displacement a */
999 #define P_REGOFF(a, b) [b + a]
1000 #define X_REGOFF(a, b) TBYTE_PTR [b + a]
1001 #define D_REGOFF(a, b) QWORD_PTR [b + a]
1002 #define L_REGOFF(a, b) DWORD_PTR [b + a]
1003 #define W_REGOFF(a, b) WORD_PTR [b + a]
1004 #define B_REGOFF(a, b) BYTE_PTR [b + a]
1005
1006 /* Reg indirect Base + Index + Displacement - this is mainly for 16-bit mode
1007 * which has no scaling
1008 */
1009 #define P_REGBID(b, i, d) [b + i + d]
1010 #define X_REGBID(b, i, d) TBYTE_PTR [b + i + d]
1011 #define D_REGBID(b, i, d) QWORD_PTR [b + i + d]
1012 #define L_REGBID(b, i, d) DWORD_PTR [b + i + d]
1013 #define W_REGBID(b, i, d) WORD_PTR [b + i + d]
1014 #define B_REGBID(b, i, d) BYTE_PTR [b + i + d]
1015
1016 /* Reg indirect Base + (Index * Scale) */
1017 #define P_REGBIS(b, i, s) [b + i * s]
1018 #define X_REGBIS(b, i, s) TBYTE_PTR [b + i * s]
1019 #define D_REGBIS(b, i, s) QWORD_PTR [b + i * s]
1020 #define L_REGBIS(b, i, s) DWORD_PTR [b + i * s]
1021 #define W_REGBIS(b, i, s) WORD_PTR [b + i * s]
1022 #define B_REGBIS(b, i, s) BYTE_PTR [b + i * s]
1023
1024 /* Reg indirect Base + (Index * Scale) + Displacement */
1025 #define P_REGBISD(b, i, s, d) [b + i * s + d]
1026 #define X_REGBISD(b, i, s, d) TBYTE_PTR [b + i * s + d]
1027 #define D_REGBISD(b, i, s, d) QWORD_PTR [b + i * s + d]
1028 #define L_REGBISD(b, i, s, d) DWORD_PTR [b + i * s + d]
1029 #define W_REGBISD(b, i, s, d) WORD_PTR [b + i * s + d]
1030 #define B_REGBISD(b, i, s, d) BYTE_PTR [b + i * s + d]
1031
1032 /* Displaced Scaled Index: */
1033 #define P_REGDIS(d, i, s) [i * s + d]
1034 #define X_REGDIS(d, i, s) TBYTE_PTR [i * s + d]
1035 #define D_REGDIS(d, i, s) QWORD_PTR [i * s + d]
1036 #define L_REGDIS(d, i, s) DWORD_PTR [i * s + d]
1037 #define W_REGDIS(d, i, s) WORD_PTR [i * s + d]
1038 #define B_REGDIS(d, i, s) BYTE_PTR [i * s + d]
1039
1040 /* Indexed Base: */
1041 #define P_REGBI(b, i) [b + i]
1042 #define X_REGBI(b, i) TBYTE_PTR [b + i]
1043 #define D_REGBI(b, i) QWORD_PTR [b + i]
1044 #define L_REGBI(b, i) DWORD_PTR [b + i]
1045 #define W_REGBI(b, i) WORD_PTR [b + i]
1046 #define B_REGBI(b, i) BYTE_PTR [b + i]
1047
1048 /* Displaced Base: */
1049 #define P_REGDB(d, b) [b + d]
1050 #define X_REGDB(d, b) TBYTE_PTR [b + d]
1051 #define D_REGDB(d, b) QWORD_PTR [b + d]
1052 #define L_REGDB(d, b) DWORD_PTR [b + d]
1053 #define W_REGDB(d, b) WORD_PTR [b + d]
1054 #define B_REGDB(d, b) BYTE_PTR [b + d]
1055
1056 /* Variable indirect: */
1057 #define VARINDIRECT(var) var
1058
1059 /* Use register contents as jump/call target: */
1060 #define CODEPTR(reg) reg
1061
1062 /*
1063 * Redefine assembler commands
1064 */
1065
1066 #define P_(a) P_ ## a
1067 #define X_(a) X_ ## a
1068 #define D_(a) D_ ## a
1069 #define S_(a) L_ ## a
1070 #define L_(a) L_ ## a
1071 #define W_(a) W_ ## a
1072 #define B_(a) B_ ## a
1073
1074 #define AAA aaa
1075 #define AAD aad
1076 #define AAM aam
1077 #define AAS aas
1078 #define ADC_L(a, b) adc L_(b), L_(a)
1079 #define ADC_W(a, b) adc W_(b), W_(a)
1080 #define ADC_B(a, b) adc B_(b), B_(a)
1081 #define ADD_L(a, b) add L_(b), L_(a)
1082 #define ADD_W(a, b) add W_(b), W_(a)
1083 #define ADD_B(a, b) add B_(b), B_(a)
1084 #define AND_L(a, b) and L_(b), L_(a)
1085 #define AND_W(a, b) and W_(b), W_(a)
1086 #define AND_B(a, b) and B_(b), B_(a)
1087 #define ARPL(a,b) arpl W_(b), a
1088 #define BOUND_L(a, b) bound L_(b), L_(a)
1089 #define BOUND_W(a, b) bound W_(b), W_(a)
1090 #define BSF_L(a, b) bsf L_(b), L_(a)
1091 #define BSF_W(a, b) bsf W_(b), W_(a)
1092 #define BSR_L(a, b) bsr L_(b), L_(a)
1093 #define BSR_W(a, b) bsr W_(b), W_(a)
1094 #define BT_L(a, b) bt L_(b), L_(a)
1095 #define BT_W(a, b) bt W_(b), W_(a)
1096 #define BTC_L(a, b) btc L_(b), L_(a)
1097 #define BTC_W(a, b) btc W_(b), W_(a)
1098 #define BTR_L(a, b) btr L_(b), L_(a)
1099 #define BTR_W(a, b) btr W_(b), W_(a)
1100 #define BTS_L(a, b) bts L_(b), L_(a)
1101 #define BTS_W(a, b) bts W_(b), W_(a)
1102 #define CALL(a) call a
1103 #define CALLF(s,a) call far s:a
1104 #define CBW cbw
1105 #define CWDE cwde
1106 #define CLC clc
1107 #define CLD cld
1108 #define CLI cli
1109 #define CLTS clts
1110 #define CMC cmc
1111 #define CMP_L(a, b) cmp L_(b), L_(a)
1112 #define CMP_W(a, b) cmp W_(b), W_(a)
1113 #define CMP_B(a, b) cmp B_(b), B_(a)
1114 #define CMPS_L cmpsd
1115 #define CMPS_W cmpsw
1116 #define CMPS_B cmpsb
1117 #define CPUID cpuid
1118 #define CWD cwd
1119 #define CDQ cdq
1120 #define DAA daa
1121 #define DAS das
1122 #define DEC_L(a) dec L_(a)
1123 #define DEC_W(a) dec W_(a)
1124 #define DEC_B(a) dec B_(a)
1125 #define DIV_L(a) div L_(a)
1126 #define DIV_W(a) div W_(a)
1127 #define DIV_B(a) div B_(a)
1128 #define ENTER(a,b) enter b, a
1129 #define HLT hlt
1130 #define IDIV_L(a) idiv L_(a)
1131 #define IDIV_W(a) idiv W_(a)
1132 #define IDIV_B(a) idiv B_(a)
1133 #define IMUL_L(a, b) imul L_(b), L_(a)
1134 #define IMUL_W(a, b) imul W_(b), W_(a)
1135 #define IMUL_B(a) imul B_(a)
1136 #define IN_L in EAX, DX
1137 #define IN_W in AX, DX
1138 #define IN_B in AL, DX
1139 #define IN1_L(a) in1 L_(a)
1140 #define IN1_W(a) in1 W_(a)
1141 #define IN1_B(a) in1 B_(a)
1142 #define INC_L(a) inc L_(a)
1143 #define INC_W(a) inc W_(a)
1144 #define INC_B(a) inc B_(a)
1145 #define INS_L ins
1146 #define INS_W ins
1147 #define INS_B ins
1148 #define INT(a) int B_(a)
1149 #define INT3 int3
1150 #define INTO into
1151 #define IRET iret
1152 #define IRETD iretd
1153 #define JA(a) ja NEAR a
1154 #define JAE(a) jae NEAR a
1155 #define JB(a) jb NEAR a
1156 #define JBE(a) jbe NEAR a
1157 #define JC(a) jc NEAR a
1158 #define JE(a) je NEAR a
1159 #define JG(a) jg NEAR a
1160 #define JGE(a) jge NEAR a
1161 #define JL(a) jl NEAR a
1162 #define JLE(a) jle NEAR a
1163 #define JNA(a) jna NEAR a
1164 #define JNAE(a) jnae NEAR a
1165 #define JNB(a) jnb NEAR a
1166 #define JNBE(a) jnbe NEAR a
1167 #define JNC(a) jnc NEAR a
1168 #define JNE(a) jne NEAR a
1169 #define JNG(a) jng NEAR a
1170 #define JNGE(a) jnge NEAR a
1171 #define JNL(a) jnl NEAR a
1172 #define JNLE(a) jnle NEAR a
1173 #define JNO(a) jno NEAR a
1174 #define JNP(a) jnp NEAR a
1175 #define JNS(a) jns NEAR a
1176 #define JNZ(a) jnz NEAR a
1177 #define JO(a) jo NEAR a
1178 #define JP(a) jp NEAR a
1179 #define JPE(a) jpe NEAR a
1180 #define JPO(a) jpo NEAR a
1181 #define JS(a) js NEAR a
1182 #define JZ(a) jz NEAR a
1183 #define JMP(a) jmp a
1184 #define JMPF(s,a) jmpf
1185 #define LAHF lahf
1186 #define LAR(a, b) lar b, a
1187 #define LEA_L(a, b) lea P_(b), P_(a)
1188 #define LEA_W(a, b) lea P_(b), P_(a)
1189 #define LEAVE leave
1190 #define LGDT(a) lgdt a
1191 #define LIDT(a) lidt a
1192 #define LDS(a, b) lds b, a
1193 #define LES(a, b) les b, a
1194 #define LFS(a, b) lfs b, a
1195 #define LGS(a, b) lgs b, a
1196 #define LSS(a, b) lss b, a
1197 #define LLDT(a) lldt a
1198 #define LMSW(a) lmsw a
1199 #define LOCK lock
1200 #define LODS_L lodsd
1201 #define LODS_W lodsw
1202 #define LODS_B lodsb
1203 #define LOOP(a) loop a
1204 #define LOOPE(a) loope a
1205 #define LOOPZ(a) loopz a
1206 #define LOOPNE(a) loopne a
1207 #define LOOPNZ(a) loopnz a
1208 #define LSL(a, b) lsl b, a
1209 #define LTR(a) ltr a
1210 #define MOV_SR(a, b) mov S_(b), S_(a)
1211 #define MOV_L(a, b) mov L_(b), L_(a)
1212 #define MOV_W(a, b) mov W_(b), W_(a)
1213 #define MOV_B(a, b) mov B_(b), B_(a)
1214 #define MOVS_L movsd
1215 #define MOVS_W movsw
1216 #define MOVS_B movsb
1217 #define MOVSX_BL(a, b) movsx B_(b), B_(a)
1218 #define MOVSX_BW(a, b) movsx B_(b), B_(a)
1219 #define MOVSX_WL(a, b) movsx W_(b), W_(a)
1220 #define MOVZX_BL(a, b) movzx B_(b), B_(a)
1221 #define MOVZX_BW(a, b) movzx B_(b), B_(a)
1222 #define MOVZX_WL(a, b) movzx W_(b), W_(a)
1223 #define MUL_L(a) mul L_(a)
1224 #define MUL_W(a) mul W_(a)
1225 #define MUL_B(a) mul B_(a)
1226 #define NEG_L(a) neg L_(a)
1227 #define NEG_W(a) neg W_(a)
1228 #define NEG_B(a) neg B_(a)
1229 #define NOP nop
1230 #define NOT_L(a) not L_(a)
1231 #define NOT_W(a) not W_(a)
1232 #define NOT_B(a) not B_(a)
1233 #define OR_L(a,b) or L_(b), L_(a)
1234 #define OR_W(a,b) or W_(b), W_(a)
1235 #define OR_B(a,b) or B_(b), B_(a)
1236 #define OUT_L out DX, EAX
1237 #define OUT_W out DX, AX
1238 #define OUT_B out DX, AL
1239 #define OUT1_L(a) out1 L_(a)
1240 #define OUT1_W(a) out1 W_(a)
1241 #define OUT1_B(a) out1 B_(a)
1242 #define OUTS_L outsd
1243 #define OUTS_W outsw
1244 #define OUTS_B outsb
1245 #define POP_SR(a) pop S_(a)
1246 #define POP_L(a) pop L_(a)
1247 #define POP_W(a) pop W_(a)
1248 #define POPA_L popad
1249 #define POPA_W popa
1250 #define POPF_L popfd
1251 #define POPF_W popf
1252 #define PUSH_SR(a) push S_(a)
1253 #define PUSH_L(a) push L_(a)
1254 #define PUSH_W(a) push W_(a)
1255 #define PUSH_B(a) push B_(a)
1256 #define PUSHA_L pushad
1257 #define PUSHA_W pusha
1258 #define PUSHF_L pushfd
1259 #define PUSHF_W pushf
1260 #define RCL_L(a, b) rcl L_(b), L_(a)
1261 #define RCL_W(a, b) rcl W_(b), W_(a)
1262 #define RCL_B(a, b) rcl B_(b), B_(a)
1263 #define RCR_L(a, b) rcr L_(b), L_(a)
1264 #define RCR_W(a, b) rcr W_(b), W_(a)
1265 #define RCR_B(a, b) rcr B_(b), B_(a)
1266 #define RDTSC rdtsc
1267 #define ROL_L(a, b) rol L_(b), L_(a)
1268 #define ROL_W(a, b) rol W_(b), W_(a)
1269 #define ROL_B(a, b) rol B_(b), B_(a)
1270 #define ROR_L(a, b) ror L_(b), L_(a)
1271 #define ROR_W(a, b) ror W_(b), W_(a)
1272 #define ROR_B(a, b) ror B_(b), B_(a)
1273 #define REP rep
1274 #define REPE repe
1275 #define REPNE repne
1276 #define REPNZ REPNE
1277 #define REPZ REPE
1278 #define RET ret
1279 #define SAHF sahf
1280 #define SAL_L(a, b) sal L_(b), L_(a)
1281 #define SAL_W(a, b) sal W_(b), W_(a)
1282 #define SAL_B(a, b) sal B_(b), B_(a)
1283 #define SAR_L(a, b) sar L_(b), L_(a)
1284 #define SAR_W(a, b) sar W_(b), W_(a)
1285 #define SAR_B(a, b) sar B_(b), B_(a)
1286 #define SBB_L(a, b) sbb L_(b), L_(a)
1287 #define SBB_W(a, b) sbb W_(b), W_(a)
1288 #define SBB_B(a, b) sbb B_(b), B_(a)
1289 #define SCAS_L scas
1290 #define SCAS_W scas
1291 #define SCAS_B scas
1292 #define SETA(a) seta a
1293 #define SETAE(a) setae a
1294 #define SETB(a) setb a
1295 #define SETBE(a) setbe a
1296 #define SETC(a) setc a
1297 #define SETE(a) sete a
1298 #define SETG(a) setg a
1299 #define SETGE(a) setge a
1300 #define SETL(a) setl a
1301 #define SETLE(a) setle a
1302 #define SETNA(a) setna a
1303 #define SETNAE(a) setnae a
1304 #define SETNB(a) setnb a
1305 #define SETNBE(a) setnbe a
1306 #define SETNC(a) setnc a
1307 #define SETNE(a) setne a
1308 #define SETNG(a) setng a
1309 #define SETNGE(a) setnge a
1310 #define SETNL(a) setnl a
1311 #define SETNLE(a) setnle a
1312 #define SETNO(a) setno a
1313 #define SETNP(a) setnp a
1314 #define SETNS(a) setns a
1315 #define SETNZ(a) setnz a
1316 #define SETO(a) seto a
1317 #define SETP(a) setp a
1318 #define SETPE(a) setpe a
1319 #define SETPO(a) setpo a
1320 #define SETS(a) sets a
1321 #define SETZ(a) setz a
1322 #define SGDT(a) sgdt a
1323 #define SIDT(a) sidt a
1324 #define SHL_L(a, b) shl L_(b), L_(a)
1325 #define SHL_W(a, b) shl W_(b), W_(a)
1326 #define SHL_B(a, b) shl B_(b), B_(a)
1327 #define SHLD_L(a,b,c) shld
1328 #define SHLD2_L(a,b) shld L_(b), L_(a)
1329 #define SHLD_W(a,b,c) shld
1330 #define SHLD2_W(a,b) shld W_(b), W_(a)
1331 #define SHR_L(a, b) shr L_(b), L_(a)
1332 #define SHR_W(a, b) shr W_(b), W_(a)
1333 #define SHR_B(a, b) shr B_(b), B_(a)
1334 #define SHRD_L(a,b,c) shrd
1335 #define SHRD2_L(a,b) shrd L_(b), L_(a)
1336 #define SHRD_W(a,b,c) shrd
1337 #define SHRD2_W(a,b) shrd W_(b), W_(a)
1338 #define SLDT(a) sldt a
1339 #define SMSW(a) smsw a
1340 #define STC stc
1341 #define STD std
1342 #define STI sti
1343 #define STOS_L stos
1344 #define STOS_W stos
1345 #define STOS_B stos
1346 #define STR(a) str a
1347 #define SUB_L(a, b) sub L_(b), L_(a)
1348 #define SUB_W(a, b) sub W_(b), W_(a)
1349 #define SUB_B(a, b) sub B_(b), B_(a)
1350 #define TEST_L(a, b) test L_(b), L_(a)
1351 #define TEST_W(a, b) test W_(b), W_(a)
1352 #define TEST_B(a, b) test B_(b), B_(a)
1353 #define VERR(a) verr a
1354 #define VERW(a) verw a
1355 #define WAIT wait
1356 #define XCHG_L(a, b) xchg L_(b), L_(a)
1357 #define XCHG_W(a, b) xchg W_(b), W_(a)
1358 #define XCHG_B(a, b) xchg B_(b), B_(a)
1359 #define XLAT xlat
1360 #define XOR_L(a, b) xor L_(b), L_(a)
1361 #define XOR_W(a, b) xor W_(b), W_(a)
1362 #define XOR_B(a, b) xor B_(b), B_(a)
1363
1364
1365 /* Floating Point Instructions */
1366 #define F2XM1 f2xm1
1367 #define FABS fabs
1368 #define FADD_D(a) fadd D_(a)
1369 #define FADD_S(a) fadd S_(a)
1370 #define FADD2(a, b) fadd b, a
1371 #define FADDP(a, b) faddp b, a
1372 #define FIADD_L(a) fiadd L_(a)
1373 #define FIADD_W(a) fiadd W_(a)
1374 #define FBLD(a) fbld a
1375 #define FBSTP(a) fbstp a
1376 #define FCHS fchs
1377 #define FCLEX fclex
1378 #define FNCLEX fnclex
1379 #define FCOM(a) fcom a
1380 #define FCOM_D(a) fcom D_(a)
1381 #define FCOM_S(a) fcom S_(a)
1382 #define FCOMP(a) fcomp a
1383 #define FCOMP_D(a) fcomp D_(a)
1384 #define FCOMP_S(a) fcomp S_(a)
1385 #define FCOMPP fcompp
1386 #define FCOS fcos
1387 #define FDECSTP fdecstp
1388 #define FDIV_D(a) fdiv D_(a)
1389 #define FDIV_S(a) fdiv S_(a)
1390 #define FDIV2(a, b) fdiv b, a
1391 #define FDIVP(a, b) fdivp b, a
1392 #define FIDIV_L(a) fidiv L_(a)
1393 #define FIDIV_W(a) fidiv W_(a)
1394 #define FDIVR_D(a) fdivr D_(a)
1395 #define FDIVR_S(a) fdivr S_(a)
1396 #define FDIVR2(a, b) fdivr b, a
1397 #define FDIVRP(a, b) fdivrp b, a
1398 #define FIDIVR_L(a) fidivr L_(a)
1399 #define FIDIVR_W(a) fidivr W_(a)
1400 #define FFREE(a) ffree a
1401 #define FICOM_L(a) ficom L_(a)
1402 #define FICOM_W(a) ficom W_(a)
1403 #define FICOMP_L(a) ficomp L_(a)
1404 #define FICOMP_W(a) ficomp W_(a)
1405 #define FILD_Q(a) fild D_(a)
1406 #define FILD_L(a) fild L_(a)
1407 #define FILD_W(a) fild W_(a)
1408 #define FINCSTP fincstp
1409 #define FINIT finit
1410 #define FNINIT fninit
1411 #define FIST_L(a) fist L_(a)
1412 #define FIST_W(a) fist W_(a)
1413 #define FISTP_Q(a) fistp D_(a)
1414 #define FISTP_L(a) fistp L_(a)
1415 #define FISTP_W(a) fistp W_(a)
1416 #define FLD_X(a) fld X_(a)
1417 #define FLD_D(a) fld D_(a)
1418 #define FLD_S(a) fld S_(a)
1419 #define FLD1 fld1
1420 #define FLDL2T fldl2t
1421 #define FLDL2E fldl2e
1422 #define FLDPI fldpi
1423 #define FLDLG2 fldlg2
1424 #define FLDLN2 fldln2
1425 #define FLDZ fldz
1426 #define FLDCW(a) fldcw a
1427 #define FLDENV(a) fldenv a
1428 #define FMUL_S(a) fmul S_(a)
1429 #define FMUL_D(a) fmul D_(a)
1430 #define FMUL2(a, b) fmul b, a
1431 #define FMULP(a, b) fmulp b, a
1432 #define FIMUL_L(a) fimul L_(a)
1433 #define FIMUL_W(a) fimul W_(a)
1434 #define FNOP fnop
1435 #define FPATAN fpatan
1436 #define FPREM fprem
1437 #define FPREM1 fprem1
1438 #define FPTAN fptan
1439 #define FRNDINT frndint
1440 #define FRSTOR(a) frstor a
1441 #define FSAVE(a) fsave a
1442 #define FNSAVE(a) fnsave a
1443 #define FSCALE fscale
1444 #define FSIN fsin
1445 #define FSINCOS fsincos
1446 #define FSQRT fsqrt
1447 #define FST_D(a) fst D_(a)
1448 #define FST_S(a) fst S_(a)
1449 #define FSTP_X(a) fstp X_(a)
1450 #define FSTP_D(a) fstp D_(a)
1451 #define FSTP_S(a) fstp S_(a)
1452 #define FSTP(a) fstp a
1453 #define FSTCW(a) fstcw a
1454 #define FNSTCW(a) fnstcw a
1455 #define FSTENV(a) fstenv a
1456 #define FNSTENV(a) fnstenv a
1457 #define FSTSW(a) fstsw a
1458 #define FNSTSW(a) fnstsw a
1459 #define FSUB_S(a) fsub S_(a)
1460 #define FSUB_D(a) fsub D_(a)
1461 #define FSUB2(a, b) fsub b, a
1462 #define FSUBP(a, b) fsubp b, a
1463 #define FISUB_L(a) fisub L_(a)
1464 #define FISUB_W(a) fisub W_(a)
1465 #define FSUBR_S(a) fsubr S_(a)
1466 #define FSUBR_D(a) fsubr D_(a)
1467 #define FSUBR2(a, b) fsubr b, a
1468 #define FSUBRP(a, b) fsubrp b, a
1469 #define FISUBR_L(a) fisubr L_(a)
1470 #define FISUBR_W(a) fisubr W_(a)
1471 #define FTST ftst
1472 #define FUCOM(a) fucom a
1473 #define FUCOMP(a) fucomp a
1474 #define FUCOMPP fucompp
1475 #define FWAIT fwait
1476 #define FXAM fxam
1477 #define FXCH(a) fxch a
1478 #define FXTRACT fxtract
1479 #define FYL2X fyl2x
1480 #define FYL2XP1 fyl2xp1
1481
1482 #endif /* NASM_ASSEMBLER, MASM_ASSEMBLER */
1483
1484 /****************************************/
1485 /* */
1486 /* Extensions to x86 insn set - */
1487 /* MMX, 3DNow! */
1488 /* */
1489 /****************************************/
1490
1491 #if defined(NASM_ASSEMBLER) || defined(MASM_ASSEMBLER)
1492 #define P_ARG1(a) P_ ## a
1493 #define P_ARG2(a, b) P_ ## b, P_ ## a
1494 #define P_ARG3(a, b, c) P_ ## c, P_ ## b, P_ ## a
1495 #else
1496 #define P_ARG1(a) a
1497 #define P_ARG2(a, b) a, b
1498 #define P_ARG3(a, b, c) a, b, c
1499 #endif
1500
1501 /* MMX */
1502 #define MOVD(a, b) movd P_ARG2(a, b)
1503 #define MOVQ(a, b) movq P_ARG2(a, b)
1504
1505 #define PADDB(a, b) paddb P_ARG2(a, b)
1506 #define PADDW(a, b) paddw P_ARG2(a, b)
1507 #define PADDD(a, b) paddd P_ARG2(a, b)
1508
1509 #define PADDSB(a, b) paddsb P_ARG2(a, b)
1510 #define PADDSW(a, b) paddsw P_ARG2(a, b)
1511
1512 #define PADDUSB(a, b) paddusb P_ARG2(a, b)
1513 #define PADDUSW(a, b) paddusw P_ARG2(a, b)
1514
1515 #define PSUBB(a, b) psubb P_ARG2(a, b)
1516 #define PSUBW(a, b) psubw P_ARG2(a, b)
1517 #define PSUBD(a, b) psubd P_ARG2(a, b)
1518
1519 #define PSUBSB(a, b) psubsb P_ARG2(a, b)
1520 #define PSUBSW(a, b) psubsw P_ARG2(a, b)
1521
1522 #define PSUBUSB(a, b) psubusb P_ARG2(a, b)
1523 #define PSUBUSW(a, b) psubusw P_ARG2(a, b)
1524
1525 #define PCMPEQB(a, b) pcmpeqb P_ARG2(a, b)
1526 #define PCMPEQW(a, b) pcmpeqw P_ARG2(a, b)
1527 #define PCMPEQD(a, b) pcmpeqd P_ARG2(a, b)
1528
1529 #define PCMPGTB(a, b) pcmpgtb P_ARG2(a, b)
1530 #define PCMPGTW(a, b) pcmpgtw P_ARG2(a, b)
1531 #define PCMPGTD(a, b) pcmpgtd P_ARG2(a, b)
1532
1533 #define PMULHW(a, b) pmulhw P_ARG2(a, b)
1534 #define PMULLW(a, b) pmullw P_ARG2(a, b)
1535
1536 #define PMADDWD(a, b) pmaddwd P_ARG2(a, b)
1537
1538 #define PAND(a, b) pand P_ARG2(a, b)
1539
1540 #define PANDN(a, b) pandn P_ARG2(a, b)
1541
1542 #define POR(a, b) por P_ARG2(a, b)
1543
1544 #define PXOR(a, b) pxor P_ARG2(a, b)
1545
1546 #define PSRAW(a, b) psraw P_ARG2(a, b)
1547 #define PSRAD(a, b) psrad P_ARG2(a, b)
1548
1549 #define PSRLW(a, b) psrlw P_ARG2(a, b)
1550 #define PSRLD(a, b) psrld P_ARG2(a, b)
1551 #define PSRLQ(a, b) psrlq P_ARG2(a, b)
1552
1553 #define PSLLW(a, b) psllw P_ARG2(a, b)
1554 #define PSLLD(a, b) pslld P_ARG2(a, b)
1555 #define PSLLQ(a, b) psllq P_ARG2(a, b)
1556
1557 #define PACKSSWB(a, b) packsswb P_ARG2(a, b)
1558 #define PACKSSDW(a, b) packssdw P_ARG2(a, b)
1559 #define PACKUSWB(a, b) packuswb P_ARG2(a, b)
1560
1561 #define PUNPCKHBW(a, b) punpckhbw P_ARG2(a, b)
1562 #define PUNPCKHWD(a, b) punpckhwd P_ARG2(a, b)
1563 #define PUNPCKHDQ(a, b) punpckhdq P_ARG2(a, b)
1564 #define PUNPCKLBW(a, b) punpcklbw P_ARG2(a, b)
1565 #define PUNPCKLWD(a, b) punpcklwd P_ARG2(a, b)
1566 #define PUNPCKLDQ(a, b) punpckldq P_ARG2(a, b)
1567
1568 #define EMMS emms
1569
1570 /* AMD 3DNow! */
1571 #define PAVGUSB(a, b) pavgusb P_ARG2(a, b)
1572 #define PFADD(a, b) pfadd P_ARG2(a, b)
1573 #define PFSUB(a, b) pfsub P_ARG2(a, b)
1574 #define PFSUBR(a, b) pfsubr P_ARG2(a, b)
1575 #define PFACC(a, b) pfacc P_ARG2(a, b)
1576 #define PFCMPGE(a, b) pfcmpge P_ARG2(a, b)
1577 #define PFCMPGT(a, b) pfcmpgt P_ARG2(a, b)
1578 #define PFCMPEQ(a, b) pfcmpeq P_ARG2(a, b)
1579 #define PFMIN(a, b) pfmin P_ARG2(a, b)
1580 #define PFMAX(a, b) pfmax P_ARG2(a, b)
1581 #define PI2FD(a, b) pi2fd P_ARG2(a, b)
1582 #define PF2ID(a, b) pf2id P_ARG2(a, b)
1583 #define PFRCP(a, b) pfrcp P_ARG2(a, b)
1584 #define PFRSQRT(a, b) pfrsqrt P_ARG2(a, b)
1585 #define PFMUL(a, b) pfmul P_ARG2(a, b)
1586 #define PFRCPIT1(a, b) pfrcpit1 P_ARG2(a, b)
1587 #define PFRSQIT1(a, b) pfrsqit1 P_ARG2(a, b)
1588 #define PFRCPIT2(a, b) pfrcpit2 P_ARG2(a, b)
1589 #define PMULHRW(a, b) pmulhrw P_ARG2(a, b)
1590
1591 #define FEMMS femms
1592 #define PREFETCH(a) prefetch P_ARG1(a)
1593 #define PREFETCHW(a) prefetchw P_ARG1(a)
1594
1595 /* Intel SSE */
1596 #define ADDPS(a, b) addps P_ARG2(a, b)
1597 #define ADDSS(a, b) addss P_ARG2(a, b)
1598 #define ANDNPS(a, b) andnps P_ARG2(a, b)
1599 #define ANDPS(a, b) andps P_ARG2(a, b)
1600 /* NASM only knows the pseudo ops for these.
1601 #define CMPPS(a, b, c) cmpps P_ARG3(a, b, c)
1602 #define CMPSS(a, b, c) cmpss P_ARG3(a, b, c)
1603 */
1604 #define CMPEQPS(a, b) cmpeqps P_ARG2(a, b)
1605 #define CMPLTPS(a, b) cmpltps P_ARG2(a, b)
1606 #define CMPLEPS(a, b) cmpleps P_ARG2(a, b)
1607 #define CMPUNORDPS(a, b) cmpunordps P_ARG2(a, b)
1608 #define CMPNEQPS(a, b) cmpneqps P_ARG2(a, b)
1609 #define CMPNLTPS(a, b) cmpnltps P_ARG2(a, b)
1610 #define CMPNLEPS(a, b) cmpnleps P_ARG2(a, b)
1611 #define CMPORDPS(a, b) cmpordps P_ARG2(a, b)
1612 #define CMPEQSS(a, b) cmpeqss P_ARG2(a, b)
1613 #define CMPLTSS(a, b) cmpltss P_ARG2(a, b)
1614 #define CMPLESS(a, b) cmpless P_ARG2(a, b)
1615 #define CMPUNORDSS(a, b) cmpunordss P_ARG2(a, b)
1616 #define CMPNEQSS(a, b) cmpneqss P_ARG2(a, b)
1617 #define CMPNLTSS(a, b) cmpnltss P_ARG2(a, b)
1618 #define CMPNLESS(a, b) cmpnless P_ARG2(a, b)
1619 #define CMPORDSS(a, b) cmpordss P_ARG2(a, b)
1620 #define COMISS(a, b) comiss P_ARG2(a, b)
1621 #define CVTPI2PS(a, b) cvtpi2ps P_ARG2(a, b)
1622 #define CVTPS2PI(a, b) cvtps2pi P_ARG2(a, b)
1623 #define CVTSI2SS(a, b) cvtsi2ss P_ARG2(a, b)
1624 #define CVTSS2SI(a, b) cvtss2si P_ARG2(a, b)
1625 #define CVTTPS2PI(a, b) cvttps2pi P_ARG2(a, b)
1626 #define CVTTSS2SI(a, b) cvttss2si P_ARG2(a, b)
1627 #define DIVPS(a, b) divps P_ARG2(a, b)
1628 #define DIVSS(a, b) divss P_ARG2(a, b)
1629 #define FXRSTOR(a) fxrstor P_ARG1(a)
1630 #define FXSAVE(a) fxsave P_ARG1(a)
1631 #define LDMXCSR(a) ldmxcsr P_ARG1(a)
1632 #define MAXPS(a, b) maxps P_ARG2(a, b)
1633 #define MAXSS(a, b) maxss P_ARG2(a, b)
1634 #define MINPS(a, b) minps P_ARG2(a, b)
1635 #define MINSS(a, b) minss P_ARG2(a, b)
1636 #define MOVAPS(a, b) movaps P_ARG2(a, b)
1637 #define MOVHLPS(a, b) movhlps P_ARG2(a, b)
1638 #define MOVHPS(a, b) movhps P_ARG2(a, b)
1639 #define MOVLHPS(a, b) movlhps P_ARG2(a, b)
1640 #define MOVLPS(a, b) movlps P_ARG2(a, b)
1641 #define MOVMSKPS(a, b) movmskps P_ARG2(a, b)
1642 #define MOVNTPS(a, b) movntps P_ARG2(a, b)
1643 #define MOVNTQ(a, b) movntq P_ARG2(a, b)
1644 #define MOVSS(a, b) movss P_ARG2(a, b)
1645 #define MOVUPS(a, b) movups P_ARG2(a, b)
1646 #define MULPS(a, b) mulps P_ARG2(a, b)
1647 #define MULSS(a, b) mulss P_ARG2(a, b)
1648 #define ORPS(a, b) orps P_ARG2(a, b)
1649 #define RCPPS(a, b) rcpps P_ARG2(a, b)
1650 #define RCPSS(a, b) rcpss P_ARG2(a, b)
1651 #define RSQRTPS(a, b) rsqrtps P_ARG2(a, b)
1652 #define RSQRTSS(a, b) rsqrtss P_ARG2(a, b)
1653 #define SHUFPS(a, b, c) shufps P_ARG3(a, b, c)
1654 #define SQRTPS(a, b) sqrtps P_ARG2(a, b)
1655 #define SQRTSS(a, b) sqrtss P_ARG2(a, b)
1656 #define STMXCSR(a) stmxcsr P_ARG1(a)
1657 #define SUBPS(a, b) subps P_ARG2(a, b)
1658 #define UCOMISS(a, b) ucomiss P_ARG2(a, b)
1659 #define UNPCKHPS(a, b) unpckhps P_ARG2(a, b)
1660 #define UNPCKLPS(a, b) unpcklps P_ARG2(a, b)
1661 #define XORPS(a, b) xorps P_ARG2(a, b)
1662
1663 #define PREFETCHNTA(a) prefetchnta P_ARG1(a)
1664 #define PREFETCHT0(a) prefetcht0 P_ARG1(a)
1665 #define PREFETCHT1(a) prefetcht1 P_ARG1(a)
1666 #define PREFETCHT2(a) prefetcht2 P_ARG1(a)
1667 #define SFENCE sfence
1668
1669 /* Added by BrianP for FreeBSD (per David Dawes) */
1670 #if !defined(NASM_ASSEMBLER) && !defined(MASM_ASSEMBLER) && !defined(__bsdi__)
1671 #define LLBL(a) CONCAT(.L,a)
1672 #else
1673 #define LLBL(a) a
1674 #endif
1675
1676
1677 #endif /* __ASSYNTAX_H__ */