#  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>'
-
