File: main.syntax

package info (click to toggle)
intel2gas 1.3.3-13
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 460 kB
  • ctags: 130
  • sloc: cpp: 1,286; makefile: 83
file content (458 lines) | stat: -rw-r--r-- 7,622 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
#  Try to put the more specialized forms before the
#  general ones
#
#  Look in file DATAFILES for more info about <tag>s.

General settings:
@src_comment0=\#
@dst_comment0=;
@src_comment1=//
@dst_comment1=;
-

# Single instructions that don't need converting or extending
<op:22>
<op>
-

# Unused: aad aam
<op:02> <@>$<mathnum>
<op> <@><mathnum>
-
arpl <@>%<reg> , <address>
arpl <@><address>,<reg>
-

# rep instructions
rep<text>
@rep=rep<text> 
SKIPLINE
-
# the objdump generated ones
rep<text1> <@><op:20>l <text2>
rep<text1> <@><op>w
-
rep<text1> <@><op:20><text2> <text3>
rep<text1> <@><op><text2>
-

# cmps,lods,movs,stos,iret...  size extended
<op:20>l
<rep><op>d
@rep=
-
<op:20><text>
<rep><op><text>
@rep=
-




#pushfd, popfd
p<text>fl
p<text>fd
-


# I had to move the label checks up here even though it slows
# the parser quite much (reason: the <address> tag has a <text>)
# (if you ask nicely i'll also explain it)
# Labels: convert local labels from lastbiglabel.locallabel
# The <more> allows an instruction be placed on the same line

# GAS local labels
<dec>: <@><more>
.l<dec>: <@><more>
-
# GCC created label 
# (remove dot because NASM uses it for local labels)
.L<dec>:
L<dec>:
-
<text1>.<text2>: <@><more>
@lbl=<?<text1>=<label>:,<text1>>
<lbl>.<text2>: <@><more>
-
<text>: <@><more>
@label=<text>
<label>: <@><more>
-



# movsx & movzx
movz<size><size> <@>%<reg1> , %<reg2>
movzx <@><reg2>,<reg1>
-
movs<size><size> <@>%<reg1> , %<reg2>
movsx <@><reg2>,<reg1>
-
movz<size1><size2> <@><mathnum>( <addr>) , %<reg>
movzx <@><reg>,<s-1> [<addr>+<mathnum>]
-
movs<size1><size2> <@><mathnum>( <addr>) , %<reg>
movsx <@><reg>,<s-1> [<addr>+<mathnum>]
-
movz<size1><size2> <@>( <addr>) , %<reg>
movzx <@><reg>,<s-1> [<addr>]
-
movs<size1><size2> <@>( <addr>) , %<reg> 
movsx <@><reg>,<s-1> [<addr>]       
-
movz<size1><size2> <@><address>, %<reg>
movzx <@><reg>,<s-1> <address>
-
movs<size1><size2> <@><address>, %<reg>
movsx <@><reg>,<s-1> <address>
-
movz<size1><size2> <@><text>( <addr>) , %<reg>
movzx <@><reg>,<s-1> [<text>+<addr>]
-
movs<size1><size2> <@><text>( <addr>) , %<reg> 
movsx <@><reg>,<s-1> [<text>+<addr>]       
-

#correct?
enter <@>$<mathnum2> , $<mathnum1>
enter <@><mathnum1>,<mathnum2>
-

# Some mmx (op:04) routines (and other that don't need the b/w/l extension)
# mmx registers are in reg:10
<op:04> <@>%<reg2> , %<reg1>
<op> <@><reg1>,<reg2>
-
<op:04> <@>$<mathnum>, %<reg>
<op> <@><reg>,<mathnum>
-
<op:04> <@><address>, %<reg>
<op> <@><reg>,<address>
-
<op:04> <@>%<reg> , <address>
<op> <@><address>,<reg>
-
<op:04> <@><text>+ <mathnum>, %<reg>
<op> <@><reg>,<text>+<mathnum>
-
<op:04> <@>%<reg>
<op> <@><reg>
-
<op:04> <@><address>
<op> <@><address>
-

# Some fpu (op:10) routines.
<op:10>s <@><address>
<op> <@>dword <address>
-
<op:10> <@>%<reg>
<op> <@><reg>
-
<op:10> <@>%<fpureg>
<op> <@><fpureg>
-
<op:10> <@>%<fpureg1>, %<fpureg2>
<op> <@><fpureg2>,<fpureg1>
-
<op:10><size> <@><address>
<op> <@><s> <address>
-
<op:10> <@><address>
<op> <@><address>
-
# gas seems to accept rather strange forms
f<text>stsw <@>%eax
f<text>stsw <@>ax
-

# three part opcode
<op><size> <@>$<mathnum>, %<reg1> , %<reg2>
<op> <@><reg2>,<reg1>,<mathnum>
-
<op><size> <@>%<reg1>, %<reg2>, %<reg3>
<op> <@><reg3>,<reg2>,<reg1>
-

# normal instructions
<op><size> <@>%<reg1> , %<reg2>
<op> <@><reg2>,<reg1>
-
<op><size> <@>%<reg> , <address>
<op> <@><address>,<reg>
-
<op><size> <@>$<mathnum>, %<reg>
<op> <@><reg>,<mathnum>
-
<op><size> <@>$<mathnum>, <address>
<op> <@><s> <address>,<mathnum>
-

## ARRGGH!
# simple "<addr>, %<reg>" fails because it matches the first comma
# and in at&t address there could be more -> this is a quick hack
<op><size> <@>( <addr>), %<reg>
<op> <@><reg>, [<addr>]
-
<op><size> <@>-<mathnum>( <addr>) , %<reg>
<op> <@><reg>, [<addr>-<mathnum>]
-
<op><size> <@><mathnum>( <addr>) , %<reg>
<op> <@><reg>, [<addr>+<mathnum>]
-
<op><size> <@><text>+ <mathnum>( <addr>) , %<reg>
<op> <@><reg>, [<text>+<addr>+<mathnum>]
-
# GCC generated
<op><size> <@>.L<dec><text>( <addr>) , %<reg>
<op> <@><reg>, [L<dec><text>+<addr>]
-
<op><size> <@><text>( <addr>) , %<reg>
<op> <@><reg>, [<text>+<addr>]
-
<op><size> <@><address>, %<reg>
<op> <@><reg>, <address>
-

# Simple instructions
<op><size> <@>$<mathnum>
<op> <@><s> <mathnum>
-
#shl&shr , 1 
<op:08><size> <@>%<reg>
<op> <@><reg>,1
-
<op><size> <@>%<reg>
<op> <@><reg>
-
#shl&shr , 1 
<op:08><size> <@><address>
<op> <@><s> <address>,1
-

# addresses are lethal in gas->intel conversion (they match <text>)
<op><size> <@>$<mathnum>, <address>
<op> <@><s> <address>,<mathnum>
-
<op><size> <@>%<reg> , <address>
<op> <@><address>,<reg>
-
<op><size> <@><address>
<op> <@><s> <address>
-
<op><size> <@><text>, %<reg>
<op> <@><reg>,<text>
-
<op><size> <@>%<reg>, <text>
<op> <@><text>,<reg>
-

# set flag->register
set<text>b <@>%<reg>
set<text> <@><reg>
-
set<text> <@>%<reg>
set<text> <@><reg>
-
# set flag->memory
set<text>b <@><address>
set<text> <@><address>
-
set<text> <@><address>
set<text> <@><address>
-


# Jump instructions (gcc generated)
<jump> .L<dec>
<jump> L<dec>
-
<jump> <@><dec>f
<jump> <@>short .l<dec>
-
<jump> <@><dec>r
<jump> <@>short .l<dec>
-

# Normal jumps
<jump> <@><jumpaddr>
<jump> <@><jumpaddr>
-
l<jump> <@><jumpaddr>
<jump> <@>FAR <jumpaddr>
-
l<jump> <mathnum1>,<mathnum2>
<jump> <@>FAR <mathnum1>:<mathnum2>
-
<jump> <@><text1>.<text2>
@lbl=<?<text1>=<label>:,<text1>>
<jump> <@><lbl>.<text2>
-

# movs,cmps,ins... from objdump
# we discard all variables 'cause no sane person
# would use other than the default ones
<op:20>l <text>
<rep><op>d
@rep=
-
<op:20><text> <text2>
<rep><op><text>
@rep=
-

# some special cases
lret
retf
-
lret <@>$<mathnum>
retf <@><mathnum>
-
cbtw
cbw
-
cwtd
cwd
-
cltd
cdq
-
cwtl
cwde
-
f<text>stsw
f<text>stsw   ax
-
xlat
xlatb
-
fwait
wait
-


# Some special directives
.<section>
SECTION .<section>
-
.section <@>.<section>
SECTION <@>.<section>
-
.globl <@><text>
GLOBAL <@><text>
-
.size <@><text1>, <text2>- <text3>
GLOBAL <@><text1>:function (<text2>-<text3>)
-
.size <@><text>, <num>
;.size <@><text>, <num>
-
.comm <@><text>, <num>
COMMON <@><text> <num>
-
.comm <@><text>, <num1>, <num2>
COMMON <@><text> <num1>:<num2>
-
.type <text1>, @<text2>
GLOBAL <text1>:<text2>
-
.extern <@><text>
EXTERN <@><text>
-
.local <@><text>
;LOCAL <@><text>
-
.space <@><mathnum>*4
RESD <@><mathnum>
-
.space <@><mathnum>
RESB <@><mathnum>
-
.zero <@><mathnum>
RESB <@><mathnum>
-
# I could not get this to work
# 
.p2align <num1>, , <num2>
;ALIGN 1\<\<<num1> ; IF \< <num2>
#@num=<?<num1>=1:1,<?<num1>=2:4,<?<num1>=3:8,<?<num1>=4:16,xx>>>>
#ALIGN <num> ; IF \< <num2>
-
.<text>align <num1>, <num2>
ALIGN <num1>, db <num2>
-
.<text>align <num>
ALIGN <num>
-

# gcc extras
.version <text>
#;VERSION <text> 
-
.ident <string>
;IDENT <string>
-
.file <text>
;FILE <text>
-

# more directives
\#include "<text>"
%include '<text>'
-
.equ <text>, <mathnum>
<text> equ <mathnum>
-
.set <text>, <mathnum>
<text> equ <mathnum>
-
.equ <text1>, <text2>
<text1> equ <text2>
-
.set <text1>, <text2>
<text1> equ <text2>
-

# special prefixes
addr16 <@><more>
A16 <@><more>
-
lock <@><more>
LOCK <@><more>
-
<@>fwait ; <more>
wait\n<@><more>
-
rep<text> ; <@><more>
rep<text> <@><more>
-

# gcc generated jump tables
.long <@>.L<dec>
dd <@>L<dec>
-

# data initialization
.<data> <@><numlist>
<dtype> <@><numlist>
-
.value <@><num>
dw <@><num>
-
.<data> <@><text>
<dtype> <@><text>
-

# string constants
.string <@>"<strings>
db <@>'<strings>
-
#.string <@>"<string>"
#db <@>'<string>'
#-
.asciz <@>"<string>"
db <@>'<string>', 0
-
.ascii <@>"<string>"
db <@>'<string>'
-