#  Try to put the more specialized forms befre the
#  gemeral ones
#
#  Look in i2g/main.syntax for more info about <tag>s.

General settings:
@src_comment=<cm>
@dst_comment=;
-
# Single instructions that don't need converting or extending
<op:22>
<op>
-

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

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

# movsx & movzx
movz<size><size> <@>%<reg1> , %<reg2>
movzx <@><reg2>,<reg1>
-
movs<size><size> <@>%<reg1> , %<reg2>
movsx <@><reg2>,<reg1>
-
movz<size1><size2> <@><address>, %<reg>
movzx <@><reg>,<s-1> <address>
-
movs<size1><size2> <@><address>, %<reg>
movsx <@><reg>,<s-1> <address>
-

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

# Some mmx routines (and other that don't need the b/w/l extension)
# can use either op:04 or 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>
-

# 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> <@><text>+ <mathnum>( <addr>) , %<reg>
<op> <@><reg>, [<text>+<addr>+<mathnum>]
-
<op><size> <@><text>( <addr>) , %<reg>
<op> <@><reg>, [<text>+<addr>]
-
<op><size> <@><address>, %<reg>
<op> <@><reg>, <address>
-

# Simple instructions
<op><size> <@>$<mathnum>
<op> <@><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>
-

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

# Jump instructions to local & general variables
j<text1> <@><text2>.<text3>
@lbl=<?<text2>=<label>:,<text2>>
j<text1> <@><lbl>.<text3>
-
jmp <@>* <address>
jmp <@><address>
-
j<text1> <@><text2>
j<text1> <@><text2>
-
loop <@><text2>.<text3>
@lbl=<?<text2>=<label>:,<text2>>
loop <@><lbl>.<text3>
-
loop <@><text>
loop <@><text>
-
call <@><address>
call <@><address>
-
call <@><text>
call <@><text>
-

# Some special directives
.<section>
SECTION .<section>
-
.globl <text>
<gcc>GLOBAL <text>
-
.size <text1>, <text2>- <text3>
GLOBAL <text1>:function (<text2>-<text3>)
-
.type <text1>, @<text2>
<gcc>GLOBAL <text1>:<text2>
-
.extern <text>
EXTERN <text>
-
.space <mathnum>*4
RESD <mathnum>
-
.space <mathnum>
RESB <mathnum>
-
.p2align <num1>, , <num2>
<gcc>ALIGN 1<lt><lt><num1> ; IF <lt> <num2>
#@num=<?<num1>=1:1,<?<num1>=2:4,<?<num1>=3:8,<?<num1>=4:16,xx>>>>
#ALIGN <num> ; IF <lt> <num2>
-
.<text>align <num1>, <num2>
ALIGN <num1>, db <num2>
-
.<text>align <num>
ALIGN <num>
-

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

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

# Labels: convert local labels from lastbiglabel.locallabel
# The <more> allows an instruction be placed on the same line
<text1>.<text2>: <@><more>
@lbl=<?<text1>=<label>:,<text1>>
<lbl>.<text2>: <@><more>
-
<text>: <@><more>
@label=<text>
<label>: <@><more>
-


# data initialization
<text>: .<data> <num>
<text> <dtype> <num>
-
<text>: .<data> <num>, <num>
<text> <dtype> <num>,<num>
-
.<data> <num>
<dtype> <num>
-

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