Explorar o código

* merged nasm compiler
* old asm moved to oldasm/

peter %!s(int64=26) %!d(string=hai) anos
pai
achega
611da2d24e
Modificáronse 54 ficheiros con 15379 adicións e 1024 borrados
  1. 721 0
      compiler/ag386bin.pas
  2. 9 5
      compiler/ag386int.pas
  3. 9 5
      compiler/ag386nsm.pas
  4. 8 4
      compiler/assemble.pas
  5. 6 2
      compiler/cg386add.pas
  6. 6 2
      compiler/cg386cal.pas
  7. 6 2
      compiler/cg386cnv.pas
  8. 7 3
      compiler/cg386con.pas
  9. 6 2
      compiler/cg386flw.pas
  10. 6 2
      compiler/cg386inl.pas
  11. 9 5
      compiler/cg386ld.pas
  12. 6 2
      compiler/cg386mat.pas
  13. 6 2
      compiler/cg386mem.pas
  14. 6 2
      compiler/cg386set.pas
  15. 44 34
      compiler/csopt386.pas
  16. 7 3
      compiler/gdb.pas
  17. 6 2
      compiler/hcodegen.pas
  18. 1636 0
      compiler/i386asm.pas
  19. 979 0
      compiler/i386base.pas
  20. 7723 0
      compiler/i386tab.inc
  21. 279 0
      compiler/nasmconv.pas
  22. 272 0
      compiler/og386.pas
  23. 890 0
      compiler/og386cff.pas
  24. 217 0
      compiler/og386dbg.pas
  25. 887 0
      compiler/og386elf.pas
  26. 283 0
      compiler/owar.pas
  27. 146 0
      compiler/owbase.pas
  28. 6 2
      compiler/pass_1.pas
  29. 8 4
      compiler/pass_2.pas
  30. 6 2
      compiler/pdecl.pas
  31. 6 2
      compiler/pexpr.pas
  32. 6 2
      compiler/pmodules.pas
  33. 350 510
      compiler/popt386.pas
  34. 6 2
      compiler/pstatmnt.pas
  35. 6 2
      compiler/ptconst.pas
  36. 413 0
      compiler/ra386.pas
  37. 6 2
      compiler/ra386dir.pas
  38. 288 385
      compiler/rautils.pas
  39. 6 2
      compiler/symtable.pas
  40. 7 3
      compiler/systems.pas
  41. 6 2
      compiler/tcadd.pas
  42. 6 2
      compiler/tccal.pas
  43. 6 2
      compiler/tccnv.pas
  44. 6 2
      compiler/tccon.pas
  45. 6 2
      compiler/tcflw.pas
  46. 6 2
      compiler/tcinl.pas
  47. 6 2
      compiler/tcld.pas
  48. 6 2
      compiler/tcmat.pas
  49. 6 2
      compiler/tcmem.pas
  50. 7 3
      compiler/tcset.pas
  51. 6 2
      compiler/temp_gen.pas
  52. 6 2
      compiler/tgeni386.pas
  53. 6 2
      compiler/tree.pas
  54. 6 2
      compiler/win_targ.pas

+ 721 - 0
compiler/ag386bin.pas

@@ -0,0 +1,721 @@
+{
+    $Id$
+    Copyright (c) 1996-98 by the FPC development team
+
+    This unit implements an binary assembler output class
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+{$ifdef TP}
+  {$N+,E+}
+{$endif}
+unit ag386bin;
+
+{$define MULTIPASS}
+{$define EXTERNALBSS}
+
+  interface
+
+    uses
+       i386base,
+       cobjects,aasm,files,assemble;
+
+    type
+      togtype=(og_none,og_dbg,og_coff,og_pecoff);
+
+      pi386binasmlist=^ti386binasmlist;
+      ti386binasmlist=object
+        constructor init(t:togtype);
+        destructor  done;
+        procedure WriteBin;
+      private
+{$ifdef GDB}
+        n_line       : byte;     { different types of source lines }
+        linecount,
+        includecount : longint;
+        funcname     : pasmsymbol;
+        stabslastfileinfo : tfileposinfo;
+        procedure convertstabs(p:pchar);
+        procedure emitsymbolstabs(s : string;nidx,nother,line : longint;firstasm,secondasm : pasmsymbol);
+        procedure emitlineinfostabs(nidx,line : longint);
+        procedure emitstabs(s:string);
+        procedure WriteFileLineInfo(var fileinfo : tfileposinfo;pass : longint);
+        procedure StartFileLineInfo(pass:longint);
+{$endif}
+        function  TreePass1(hp:pai;optimize:boolean):pai;
+        function  TreePass2(hp:pai):pai;
+        procedure writetree(p:paasmoutput);
+      end;
+
+  implementation
+
+    uses
+       strings,verbose,
+       globtype,globals,
+       i386asm,systems,
+{$ifdef GDB}
+       gdb,
+{$endif}
+       og386,og386dbg,og386cff;
+
+{$ifdef GDB}
+
+    procedure ti386binasmlist.convertstabs(p:pchar);
+      var
+        ofs,
+        nidx,nother,i,line,j : longint;
+        code : word;
+        hp : pchar;
+        reloc : boolean;
+        sec : tsection;
+        ps : pasmsymbol;
+        s : string;
+      begin
+        ofs:=0;
+        reloc:=true;
+        sec:=sec_none;
+        if p[0]='"' then
+         begin
+           i:=1;
+           { we can have \" inside the string !! PM }
+           while not ((p[i]='"') and (p[i-1]<>'\')) do
+            inc(i);
+           p[i]:=#0;
+           hp:=@p[1];
+           s:=StrPas(@P[i+2]);
+         end
+        else
+         begin
+           hp:=nil;
+           s:=StrPas(P);
+         end;
+        if s='' then
+         internalerror(33000);
+        j:=pos(',',s);
+        if j=0 then
+         internalerror(33001);
+        Val(Copy(s,1,j-1),nidx,code);
+        if code<>0 then
+         internalerror(33002);
+        Delete(s,1,j);
+        j:=pos(',',s);
+        if (j=0) then
+         internalerror(33003);
+        Val(Copy(s,1,j-1),nother,code);
+        if code<>0 then
+         internalerror(33004);
+        Delete(s,1,j);
+        j:=pos(',',s);
+        if j=0 then
+         begin
+           j:=256;
+           ofs:=-1;
+         end;
+        Val(Copy(s,1,j-1),line,code);
+        if code<>0 then
+          internalerror(33005);
+        if ofs=0 then
+          Delete(s,1,j);
+        if ofs=0 then
+          begin
+            Val(s,ofs,code);
+            if code=0 then
+              reloc:=false
+            else
+              begin
+                ofs:=0;
+                { handle asmsymbol or
+                    asmsymbol - asmsymbol }
+                j:=pos(' ',s);
+                if j=0 then
+                  j:=pos('-',s);
+                { single asmsymbol }
+                if j=0 then
+                  j:=256;
+                ps:=getasmsymbol(copy(s,1,j-1));
+                if not assigned(ps) then
+                  internalerror(33006)
+                else
+                  begin
+                    sec:=ps^.section;
+                    ofs:=ps^.address;
+                    reloc:=true;
+                  end;
+                if j<256 then
+                  begin
+                    delete(s,1,j);
+                    while (s<>'') and (s[1]=' ') do
+                      delete(s,1,1);
+                    ps:=getasmsymbol(s);
+                    if not assigned(ps) then
+                      internalerror(33007)
+                    else
+                      begin
+                        if ps^.section<>sec then
+                          internalerror(33008);
+                        ofs:=ofs-ps^.address;
+                        reloc:=false;
+                      end;
+                  end;
+              end;
+          end;
+        objectoutput^.WriteStabs(sec,ofs,hp,nidx,nother,line,reloc);
+        if assigned(hp) then
+         p[i]:='"';
+      end;
+
+
+    procedure ti386binasmlist.emitsymbolstabs(s : string;nidx,nother,line : longint;
+                firstasm,secondasm : pasmsymbol);
+      var
+         hp : pchar;
+      begin
+        if s='' then
+          hp:=nil
+        else
+          begin
+            s:=s+#0;
+            hp:=@s[1];
+          end;
+        if not assigned(secondasm) then
+          begin
+            if not assigned(firstasm) then
+              internalerror(33009);
+            objectoutput^.WriteStabs(firstasm^.section,firstasm^.address,hp,nidx,nother,line,true);
+          end
+        else
+          begin
+            if firstasm^.section<>secondasm^.section then
+              internalerror(33010);
+            objectoutput^.WriteStabs(firstasm^.section,firstasm^.address-secondasm^.address,
+              hp,nidx,nother,line,false);
+          end;
+      end;
+
+
+    procedure ti386binasmlist.emitlineinfostabs(nidx,line : longint);
+      var
+         sec : tsection;
+      begin
+        if (nidx=n_textline) and assigned(funcname) and
+           (target_os.use_function_relative_addresses) then
+          objectoutput^.WriteStabs(sec_code,pgenericcoffoutput(objectoutput)^.sects[sec_code]^.len-funcname^.address,
+              nil,nidx,0,line,false)
+        else
+          begin
+            if nidx=n_textline then
+              sec:=sec_code
+            else if nidx=n_dataline then
+              sec:=sec_data
+            else
+              sec:=sec_bss;
+            objectoutput^.WriteStabs(sec,pgenericcoffoutput(objectoutput)^.sects[sec]^.len,
+              nil,nidx,0,line,true);
+          end;
+      end;
+
+    procedure ti386binasmlist.emitstabs(s:string);
+      begin
+        s:=s+#0;
+        ConvertStabs(@s[1]);
+      end;
+
+
+    procedure ti386binasmlist.WriteFileLineInfo(var fileinfo : tfileposinfo;pass : longint);
+      var
+        curr_n : byte;
+        hp : pasmsymbol;
+        infile : pinputfile;
+      begin
+        if not (cs_debuginfo in aktmoduleswitches) then
+         exit;
+      { file changed ? (must be before line info) }
+        if (fileinfo.fileindex<>0) and
+           (stabslastfileinfo.fileindex<>fileinfo.fileindex) then
+         begin
+           infile:=current_module^.sourcefiles^.get_file(fileinfo.fileindex);
+           if includecount=0 then
+            curr_n:=n_sourcefile
+           else
+            curr_n:=n_includefile;
+           hp:=newasmsymbol('Ltext'+ToStr(IncludeCount));
+           { allocation pass or output pass ? }
+           if pass=1 then
+             begin
+                hp^.typ:=AS_LOCAL;
+                hp^.setaddress(objectalloc^.currsec,objectalloc^.sectionsize,0);
+             end
+           else
+             begin
+               objectoutput^.writesymbol(hp);
+               if (infile^.path^<>'') then
+                EmitStabs('"'+lower(BsToSlash(FixPath(infile^.path^,false)))+'",'+tostr(curr_n)+
+                  ',0,0,Ltext'+ToStr(IncludeCount));
+               EmitStabs('"'+lower(FixFileName(infile^.name^))+'",'+tostr(curr_n)+
+                 ',0,0,Ltext'+ToStr(IncludeCount));
+             end;
+           inc(includecount);
+         end;
+      { line changed ? }
+        if (pass=2) and (stabslastfileinfo.line<>fileinfo.line) and (fileinfo.line<>0) then
+          emitlineinfostabs(n_line,fileinfo.line);
+        stabslastfileinfo:=fileinfo;
+      end;
+
+
+    procedure ti386binasmlist.StartFileLineInfo(pass:longint);
+      var
+        fileinfo : tfileposinfo;
+      begin
+        FillChar(stabslastfileinfo,sizeof(stabslastfileinfo),0);
+        n_line:=n_textline;
+        funcname:=nil;
+        linecount:=1;
+        includecount:=0;
+        fileinfo.fileindex:=1;
+        fileinfo.line:=1;
+        WriteFileLineInfo(fileinfo,pass);
+      end;
+{$endif GDB}
+
+    function ti386binasmlist.TreePass1(hp:pai;optimize:boolean):pai;
+      begin
+        while assigned(hp) do
+         begin
+{$ifdef GDB}
+           { write stabs }
+           if (not optimize) and
+              (cs_debuginfo in aktmoduleswitches) then
+            begin
+              if (objectalloc^.currsec<>sec_none) and
+                 not(hp^.typ in  [ait_external,ait_regalloc, ait_tempalloc,
+                     ait_stabn,ait_stabs,ait_section,
+                     ait_label,ait_cut,ait_marker,ait_align,ait_stab_function_name]) then
+               WriteFileLineInfo(hp^.fileinfo,1);
+            end;
+{$endif GDB}
+           case hp^.typ of
+             ait_align :
+               begin
+                 if objectalloc^.sectionsize mod pai_align(hp)^.aligntype<>0 then
+                   begin
+                     pai_align(hp)^.fillsize:=pai_align(hp)^.aligntype-
+                       (objectalloc^.sectionsize mod pai_align(hp)^.aligntype);
+                     objectalloc^.sectionalloc(pai_align(hp)^.fillsize);
+                   end
+                 else
+                   pai_align(hp)^.fillsize:=0;
+               end;
+             ait_datablock :
+               begin
+                 if objectalloc^.currsec<>sec_bss then
+                  writeln('allocating of data is only allowed in bss section');
+{$ifdef EXTERNALBSS}
+                 if pai_datablock(hp)^.is_global then
+                  begin
+                    pai_datablock(hp)^.sym^.typ:=AS_EXTERNAL;
+                    pai_datablock(hp)^.sym^.setaddress(sec_none,pai_datablock(hp)^.size,pai_datablock(hp)^.size);
+                  end
+                 else
+                  begin
+                    pai_datablock(hp)^.sym^.typ:=AS_LOCAL;
+                    pai_datablock(hp)^.sym^.setaddress(objectalloc^.currsec,objectalloc^.sectionsize,pai_datablock(hp)^.size);
+                  end;
+                 if not pai_datablock(hp)^.is_global then
+                  objectalloc^.sectionalloc(pai_datablock(hp)^.size);
+{$else}
+                 if pai_datablock(hp)^.is_global then
+                  pai_datablock(hp)^.sym^.typ:=AS_GLOBAL
+                 else
+                  pai_datablock(hp)^.sym^.typ:=AS_LOCAL;
+                 pai_datablock(hp)^.sym^.setaddress(objectalloc^.currsec,objectalloc^.sectionsize,pai_datablock(hp)^.size);
+                 objectalloc^.sectionalloc(pai_datablock(hp)^.size);
+{$endif}
+               end;
+             ait_const_32bit :
+               objectalloc^.sectionalloc(4);
+             ait_const_16bit :
+               objectalloc^.sectionalloc(2);
+             ait_const_8bit :
+               objectalloc^.sectionalloc(1);
+             ait_real_64bit :
+               objectalloc^.sectionalloc(8);
+             ait_real_32bit :
+               objectalloc^.sectionalloc(4);
+             ait_real_extended :
+               objectalloc^.sectionalloc(10);
+             ait_const_rva,
+             ait_const_symbol :
+               objectalloc^.sectionalloc(4);
+             ait_external :
+               pai_external(hp)^.sym^.typ:=AS_EXTERNAL;
+             ait_section:
+               begin
+                 objectalloc^.setsection(pai_section(hp)^.sec);
+{$ifdef GDB}
+                 stabslastfileinfo.line:=-1;
+{$endif}
+               end;
+             ait_symbol :
+               begin
+                 if pai_symbol(hp)^.is_global then
+                  pai_symbol(hp)^.sym^.typ:=AS_GLOBAL
+                 else
+                  pai_symbol(hp)^.sym^.typ:=AS_LOCAL;
+                 pai_symbol(hp)^.sym^.setaddress(objectalloc^.currsec,objectalloc^.sectionsize,0);
+               end;
+             ait_label :
+               begin
+                 pai_label(hp)^.setaddress(objectalloc^.sectionsize);
+                 if pai_label(hp)^.l^.is_symbol then
+                   begin
+                     pai_label(hp)^.sym:=newasmsymbol(lab2str(pai_label(hp)^.l));
+                     if (pai_label(hp)^.l^.is_data) and (cs_smartlink in aktmoduleswitches) then
+                       pai_label(hp)^.sym^.typ:=AS_GLOBAL
+                     else
+                       pai_label(hp)^.sym^.typ:=AS_LOCAL;
+                     pai_label(hp)^.sym^.setaddress(objectalloc^.currsec,pai_label(hp)^.l^.address,0);
+                   end;
+               end;
+             ait_string :
+               objectalloc^.sectionalloc(pai_string(hp)^.len);
+             ait_labeled_instruction,
+             ait_instruction :
+               objectalloc^.sectionalloc(pai386(hp)^.Pass1(objectalloc^.sectionsize));
+{$ifdef GDB}
+             ait_force_line :
+               stabslastfileinfo.line:=0;
+{$endif}
+             ait_cut :
+               begin
+                 if optimize then
+                  begin
+                    objectalloc^.resetsections;
+                    objectalloc^.setsection(sec_code);
+                  end
+                 else
+                  break;
+               end;
+             ait_direct :
+               Comment(V_Fatal,'direct asm not supported with binary writers');
+             ait_comp :
+               Comment(V_Fatal,'comp not supported');
+           end;
+           hp:=pai(hp^.next);
+         end;
+        TreePass1:=hp;
+      end;
+
+
+    function ti386binasmlist.TreePass2(hp:pai):pai;
+      const
+        alignarray:array[0..5] of string[8]=(
+          #$8D#$B4#$26#$00#$00#$00#$00,
+          #$8D#$B6#$00#$00#$00#$00,
+          #$8D#$74#$26#$00,
+          #$8D#$76#$00,
+          #$89#$F6,
+          #$90
+        );
+      var
+        l,j : longint;
+      begin
+        { main loop }
+        while assigned(hp) do
+         begin
+{$ifdef GDB}
+           { write stabs }
+           if cs_debuginfo in aktmoduleswitches then
+            begin
+              if (objectoutput^.currsec<>sec_none) and
+                 not(hp^.typ in  [ait_external,ait_regalloc, ait_tempalloc,
+                     ait_stabn,ait_stabs,ait_section,
+                     ait_label,ait_cut,ait_marker,ait_align,ait_stab_function_name]) then
+               WriteFileLineInfo(hp^.fileinfo,2);
+            end;
+{$endif GDB}
+           case hp^.typ of
+             ait_align :
+               begin
+                 l:=pai_align(hp)^.fillsize;
+                 while (l>0) do
+                  begin
+                    for j:=0to 5 do
+                     if (l>=length(alignarray[j])) then
+                      break;
+                    objectoutput^.writebytes(alignarray[j][1],length(alignarray[j]));
+                    dec(l,length(alignarray[j]));
+                  end;
+               end;
+             ait_section :
+               begin
+                 objectoutput^.defaultsection(pai_section(hp)^.sec);
+{$ifdef GDB}
+                 case pai_section(hp)^.sec of
+                  sec_code : n_line:=n_textline;
+                  sec_data : n_line:=n_dataline;
+                   sec_bss : n_line:=n_bssline;
+                 else
+                  n_line:=n_dataline;
+                 end;
+                 stabslastfileinfo.line:=-1;
+{$endif GDB}
+               end;
+             ait_external :
+               objectoutput^.writesymbol(pai_external(hp)^.sym);
+             ait_symbol :
+               objectoutput^.writesymbol(pai_symbol(hp)^.sym);
+             ait_datablock :
+               begin
+                 objectoutput^.writesymbol(pai_datablock(hp)^.sym);
+{$ifdef EXTERNALBSS}
+                 if not pai_datablock(hp)^.is_global then
+{$endif}
+                   objectoutput^.writealloc(pai_datablock(hp)^.size);
+               end;
+             ait_const_32bit :
+               objectoutput^.writebytes(pai_const(hp)^.value,4);
+             ait_const_16bit :
+               objectoutput^.writebytes(pai_const(hp)^.value,2);
+             ait_const_8bit :
+               objectoutput^.writebytes(pai_const(hp)^.value,1);
+             ait_real_64bit :
+               objectoutput^.writebytes(pai_double(hp)^.value,8);
+             ait_real_32bit :
+               objectoutput^.writebytes(pai_single(hp)^.value,4);
+             ait_real_extended :
+               objectoutput^.writebytes(pai_extended(hp)^.value,10);
+             ait_string :
+               objectoutput^.writebytes(pai_string(hp)^.str^,pai_string(hp)^.len);
+             ait_const_rva :
+               objectoutput^.writereloc(pai_const_symbol(hp)^.offset,4,
+                 pai_const_symbol(hp)^.sym,relative_rva);
+             ait_const_symbol :
+               objectoutput^.writereloc(pai_const_symbol(hp)^.offset,4,
+                 pai_const_symbol(hp)^.sym,relative_false);
+             ait_label :
+               begin
+                 if assigned(pai_label(hp)^.sym) then
+                  objectoutput^.writesymbol(pai_label(hp)^.sym);
+               end;
+             ait_labeled_instruction,
+             ait_instruction :
+               pai386(hp)^.Pass2;
+{$ifdef GDB}
+             ait_stabn :
+               convertstabs(pai_stabn(hp)^.str);
+             ait_stabs :
+               convertstabs(pai_stabs(hp)^.str);
+             ait_stab_function_name :
+               if assigned(pai_stab_function_name(hp)^.str) then
+                 funcname:=getasmsymbol(pai_stab_function_name(hp)^.str)
+               else
+                 funcname:=nil;
+             ait_force_line :
+               stabslastfileinfo.line:=0;
+{$endif}
+             ait_cut :
+               break;
+           end;
+           hp:=pai(hp^.next);
+         end;
+        TreePass2:=hp;
+      end;
+
+
+    procedure ti386binasmlist.writetree(p:paasmoutput);
+      var
+        hp : pai;
+      begin
+        if not assigned(p) then
+         exit;
+        hp:=pai(p^.first);
+        while assigned(hp) do
+         begin
+{$ifdef GDB}
+           StartFileLineInfo(1);
+{$endif GDB}
+           TreePass1(hp,false);
+{$ifdef GDB}
+           StartFileLineInfo(2);
+{$endif GDB}
+           hp:=TreePass2(hp);
+         { if assigned then we have a ait_cut }
+           if assigned(hp) then
+            begin
+              if hp^.typ<>ait_cut then
+               internalerror(3334443);
+              { write the current objectfile }
+              objectoutput^.donewriting;
+              { start the writing again }
+              objectoutput^.initwriting;
+              { we will start a new objectfile so reset everything }
+              ResetAsmsymbolList;
+              objectalloc^.resetsections;
+              { avoid empty files }
+              while assigned(hp^.next) and
+                    (pai(hp^.next)^.typ in [ait_marker,ait_comment,ait_section,ait_cut]) do
+               begin
+                 if pai(hp^.next)^.typ=ait_section then
+                   begin
+                     objectalloc^.setsection(pai_section(hp^.next)^.sec);
+                     objectoutput^.defaultsection(pai_section(hp^.next)^.sec);
+                   end;
+                 hp:=pai(hp^.next);
+               end;
+              hp:=pai(hp^.next);
+            end;
+         end;
+      end;
+
+
+    procedure ti386binasmlist.writebin;
+      var
+        mylist : paasmoutput;
+
+        procedure addlist(p:paasmoutput);
+        begin
+          mylist^.concat(new(pai_section,init(sec_code)));
+          mylist^.concatlist(p);
+        end;
+
+      begin
+{$ifdef MULTIPASS}
+        { Process the codesegment twice so the jmp instructions can
+          be optimized }
+        TreePass1(pai(codesegment^.first),true);
+        if assigned(importssection) then
+          TreePass1(pai(importssection^.first),true);
+{$endif}
+
+        objectalloc^.resetsections;
+        objectalloc^.setsection(sec_code);
+
+        objectoutput^.initwriting;
+        objectoutput^.defaultsection(sec_code);
+
+        new(mylist,init);
+
+        if not(cs_compilesystem in aktmoduleswitches) then
+          addlist(externals);
+        if cs_debuginfo in aktmoduleswitches then
+          addlist(debuglist);
+        addlist(codesegment);
+        addlist(datasegment);
+        addlist(consts);
+        addlist(rttilist);
+        addlist(bsssegment);
+        if assigned(importssection) then
+          addlist(importssection);
+        if assigned(exportssection) then
+          addlist(exportssection);
+        if assigned(resourcesection) then
+          addlist(resourcesection);
+
+        WriteTree(mylist);
+
+        dispose(mylist,done);
+
+        objectoutput^.donewriting;
+      end;
+
+
+    constructor ti386binasmlist.init(t:togtype);
+      begin
+        case t of
+          og_none :
+            begin
+              writeln('no binary writer selected');
+              exit;
+            end;
+          og_dbg :
+            objectoutput:=new(pdbgoutput,init);
+          og_coff :
+            objectoutput:=new(pdjgppcoffoutput,init);
+          og_pecoff :
+            objectoutput:=new(pwin32coffoutput,init);
+        end;
+        objectalloc:=new(pobjectalloc,init);
+      end;
+
+
+   destructor ti386binasmlist.done;
+      begin
+        dispose(objectoutput,done);
+        dispose(objectalloc,done);
+      end;
+
+end.
+{
+  $Log$
+  Revision 1.1  1999-05-01 13:23:57  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.14  1999/04/16 11:49:48  peter
+    + tempalloc
+    + -at to show temp alloc info in .s file
+
+  Revision 1.13  1999/03/12 00:20:03  pierre
+   + win32 output working !
+
+  Revision 1.12  1999/03/11 17:52:34  peter
+    * fixed wrong ot_signed generation in insns tab
+
+  Revision 1.11  1999/03/10 13:41:07  pierre
+   + partial implementation for win32 !
+     winhello works but pp still does not !
+
+  Revision 1.10  1999/03/08 14:51:05  peter
+    + smartlinking for ag386bin
+
+  Revision 1.9  1999/03/06 17:24:18  peter
+    * rewritten intel parser a lot, especially reference reading
+    * size checking added for asm parsers
+
+  Revision 1.8  1999/03/05 13:09:50  peter
+    * first things for tai_cut support for ag386bin
+
+  Revision 1.7  1999/03/03 11:41:53  pierre
+    + stabs info corrected to give results near to GAS output
+    * local labels (with .L are not stored in object anymore)
+      so we get the same number of symbols as from GAS !
+
+  Revision 1.6  1999/03/03 01:36:44  pierre
+    + stabs output working (though not really tested)
+      for a simple file the only difference to GAS output is due
+      to the VMA of the different sections
+
+  Revision 1.5  1999/03/02 02:56:18  peter
+    + stabs support for binary writers
+    * more fixes and missing updates from the previous commit :(
+
+  Revision 1.4  1999/03/01 15:46:20  peter
+    * ag386bin finally make cycles correct
+    * prefixes are now also normal opcodes
+
+  Revision 1.3  1999/02/25 21:03:01  peter
+    * ag386bin updates
+    + coff writer
+
+  Revision 1.2  1999/02/22 02:16:00  peter
+    * updates for ag386bin
+
+  Revision 1.1  1999/02/16 17:59:37  peter
+    + initial files
+
+}

+ 9 - 5
compiler/ag386int.pas

@@ -40,7 +40,7 @@ unit ag386int;
 
     uses
       dos,globals,systems,cobjects,
-{$ifdef AG386BIN}
+{$ifndef OLDASM}
       i386base,i386asm,
 {$else}
       i386,
@@ -158,7 +158,7 @@ unit ag386int;
        getreferencestring:=s;
      end;
 
-{$ifdef AG386BIN}
+{$ifndef OLDASM}
 
     function getopstr(const o:toper;s : topsize; opcode: tasmop;dest : boolean) : string;
     var
@@ -376,7 +376,7 @@ unit ag386int;
       consttyp : tait;
       found,
       quoted   : boolean;
-{$ifdef AG386Bin}
+{$ifndef OLDASM}
       sep      : char;
 {$endif}
     begin
@@ -554,7 +554,7 @@ ait_labeled_instruction : AsmWriteLn(#9#9+int_op2str[pai386_labeled(hp)^.opcode]
    ait_instruction : begin
                        suffix:='';
                        prefix:= '';
-{$ifdef AG386BIN}
+{$ifndef OLDASM}
                      { added prefix instructions, must be on same line as opcode }
                        if (pai386(hp)^.ops = 0) and
                           ((pai386(hp)^.opcode = A_REP) or
@@ -795,7 +795,11 @@ ait_stab_function_name : ;
 end.
 {
   $Log$
-  Revision 1.33  1999-04-17 22:17:05  pierre
+  Revision 1.34  1999-05-01 13:23:58  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.33  1999/04/17 22:17:05  pierre
     * ifdef USE_OP3 released (changed into ifndef NO_OP3)
     * SHRD and SHLD first operand (ATT syntax) can only be CL reg or immediate const
 

+ 9 - 5
compiler/ag386nsm.pas

@@ -41,7 +41,7 @@ unit ag386nsm;
 
     uses
       dos,globals,systems,cobjects,
-{$ifdef AG386BIN}
+{$ifndef OLDASM}
       i386base,i386asm,
 {$else}
       i386,
@@ -159,7 +159,7 @@ unit ag386nsm;
        getreferencestring:=s;
      end;
 
-{$ifdef AG386BIN}
+{$ifndef OLDASM}
 
     function getopstr(const o:toper;s : topsize; opcode: tasmop;dest : boolean) : string;
     var
@@ -387,7 +387,7 @@ unit ag386nsm;
       consttyp : tait;
       found,
       quoted   : boolean;
-{$ifdef AG386Bin}
+{$ifndef OLDASM}
       sep      : char;
 {$endif}
     begin
@@ -557,7 +557,7 @@ ait_labeled_instruction :
    ait_instruction : begin
                        suffix:='';
                        prefix:='';
-{$ifdef AG386BIN}
+{$ifndef OLDASM}
                        if pai386(hp)^.ops<>0 then
                         begin
                           if pai386(hp)^.opcode=A_CALL then
@@ -740,7 +740,11 @@ ait_stab_function_name : ;
 end.
 {
   $Log$
-  Revision 1.28  1999-04-17 22:17:06  pierre
+  Revision 1.29  1999-05-01 13:23:59  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.28  1999/04/17 22:17:06  pierre
     * ifdef USE_OP3 released (changed into ifndef NO_OP3)
     * SHRD and SHLD first operand (ATT syntax) can only be CL reg or immediate const
 

+ 8 - 4
compiler/assemble.pas

@@ -85,7 +85,7 @@ uses
 {$endif}
   ,strings
 {$ifdef i386}
-  {$ifdef Ag386Bin}
+  {$ifndef OLDASM}
     ,ag386bin
   {$endif}
   {$ifndef NoAg386Att}
@@ -446,14 +446,14 @@ Procedure GenerateAsm;
 var
   a : PAsmList;
 {$ifdef i386}
-  {$ifdef Ag386Bin}
+  {$ifndef OLDASM}
     b : Pi386binasmlist;
   {$endif}
 {$endif}
 begin
   case aktoutputformat of
 {$ifdef i386}
-  {$ifdef Ag386Bin}
+  {$ifndef OLDASM}
      as_i386_dbg,
      as_i386_coff,
      as_i386_pecoff :
@@ -541,7 +541,11 @@ end;
 end.
 {
   $Log$
-  Revision 1.41  1999-03-24 23:16:42  peter
+  Revision 1.42  1999-05-01 13:24:00  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.41  1999/03/24 23:16:42  peter
     * fixed bugs 212,222,225,227,229,231,233
 
   Revision 1.40  1999/03/18 20:30:44  peter

+ 6 - 2
compiler/cg386add.pas

@@ -37,7 +37,7 @@ implementation
       cobjects,verbose,globals,
       symtable,aasm,types,
       hcodegen,temp_gen,pass_2,
-{$ifdef ag386bin}
+{$ifndef OLDASM}
       i386base,i386asm,
 {$else}
       i386,
@@ -2034,7 +2034,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.52  1999-04-19 09:39:01  pierre
+  Revision 1.53  1999-05-01 13:24:01  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.52  1999/04/19 09:39:01  pierre
    * fixes for tempansi
 
   Revision 1.51  1999/04/16 20:44:34  florian

+ 6 - 2
compiler/cg386cal.pas

@@ -44,7 +44,7 @@ implementation
       gdb,
 {$endif GDB}
       hcodegen,temp_gen,pass_2,
-{$ifdef ag386bin}
+{$ifndef OLDASM}
       i386base,i386asm,
 {$else}
       i386,
@@ -1215,7 +1215,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.77  1999-04-29 22:12:21  pierre
+  Revision 1.78  1999-05-01 13:24:02  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.77  1999/04/29 22:12:21  pierre
    * fix for ID 388 removing real from stack was wrong
 
   Revision 1.76  1999/04/25 22:33:19  pierre

+ 6 - 2
compiler/cg386cnv.pas

@@ -43,7 +43,7 @@ implementation
       cobjects,verbose,globals,systems,
       symtable,aasm,types,
       hcodegen,temp_gen,pass_2,pass_1,
-{$ifdef ag386bin}
+{$ifndef OLDASM}
       i386base,i386asm,
 {$else}
       i386,
@@ -1289,7 +1289,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.68  1999-04-28 06:01:54  florian
+  Revision 1.69  1999-05-01 13:24:04  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.68  1999/04/28 06:01:54  florian
     * changes of Bruessel:
        + message handler can now take an explicit self
        * typinfo fixed: sometimes the type names weren't written

+ 7 - 3
compiler/cg386con.pas

@@ -44,7 +44,7 @@ implementation
       cobjects,verbose,globals,
       symtable,aasm,types,
       hcodegen,temp_gen,pass_2,
-{$ifdef ag386bin}
+{$ifndef OLDASM}
       i386base,i386asm,
 {$else}
       i386,
@@ -257,7 +257,7 @@ implementation
                       st_shortstring:
                         begin
                            { empty strings }
-                           
+
                            (* if p^.length=0 then
                            { consts^.concat(new(pai_const,init_16bit(0)))}
                            { this was not very good because several occurence
@@ -410,7 +410,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.31  1999-04-07 15:16:43  pierre
+  Revision 1.32  1999-05-01 13:24:06  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.31  1999/04/07 15:16:43  pierre
    * zero length string were generated multiple times
 
   Revision 1.30  1999/03/31 13:51:49  peter

+ 6 - 2
compiler/cg386flw.pas

@@ -47,7 +47,7 @@ implementation
       cobjects,verbose,globals,systems,
       symtable,aasm,types,
       hcodegen,temp_gen,pass_2,
-{$ifdef ag386bin}
+{$ifndef OLDASM}
       i386base,i386asm,
 {$else}
       i386,
@@ -802,7 +802,11 @@ do_jmp:
 end.
 {
   $Log$
-  Revision 1.34  1999-04-26 13:31:25  peter
+  Revision 1.35  1999-05-01 13:24:07  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.34  1999/04/26 13:31:25  peter
     * release storenumber,double_checksum
 
   Revision 1.33  1999/04/21 09:43:29  peter

+ 6 - 2
compiler/cg386inl.pas

@@ -36,7 +36,7 @@ implementation
       cobjects,verbose,globals,files,
       symtable,aasm,types,
       hcodegen,temp_gen,pass_2,
-{$ifdef ag386bin}
+{$ifndef OLDASM}
       i386base,i386asm,
 {$else}
       i386,
@@ -1290,7 +1290,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.44  1999-04-26 18:28:13  peter
+  Revision 1.45  1999-05-01 13:24:08  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.44  1999/04/26 18:28:13  peter
     * better read/write array
 
   Revision 1.43  1999/04/19 09:45:48  pierre

+ 9 - 5
compiler/cg386ld.pas

@@ -39,7 +39,7 @@ implementation
       cobjects,verbose,globals,
       symtable,aasm,types,
       hcodegen,temp_gen,pass_2,
-{$ifdef ag386bin}
+{$ifndef OLDASM}
       i386base,i386asm,
 {$else}
       i386,
@@ -109,7 +109,7 @@ implementation
                          if popeax then
                            exprasmlist^.concat(new(pai386,op_reg(A_PUSH,S_L,R_EAX)));
                          p^.location.reference.symbol:=newasmsymbol(p^.symtableentry^.mangledname);
-                         if symtabletype=unitsymtable then
+                         if p^.symtable^.symtabletype=unitsymtable then
                            concat_external(p^.symtableentry^.mangledname,EXT_NEAR);
                          exprasmlist^.concat(new(pai386,op_ref(A_PUSH,S_L,newreference(p^.location.reference))));
                          { the called procedure isn't allowed to change }
@@ -357,7 +357,7 @@ implementation
          loc : tloc;
          r : preference;
          oldrl : plinkedlist;
-{$ifdef Ag386Bin}
+{$ifndef OLDASM}
          ai : pai386;
 {$endif}
       begin
@@ -670,7 +670,7 @@ implementation
                               if loc=LOC_CREGISTER then
                                 emit_flag2reg(p^.right^.location.resflags,p^.left^.location.register)
                               else
-{$ifdef Ag386Bin}
+{$ifndef OLDASM}
                                 begin
                                   ai:=new(pai386,op_ref(A_Setcc,S_B,newreference(p^.left^.location.reference)));
                                   ai^.SetCondition(flag_2_cond[p^.right^.location.resflags]);
@@ -864,7 +864,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.51  1999-04-28 06:01:55  florian
+  Revision 1.52  1999-05-01 13:24:10  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.51  1999/04/28 06:01:55  florian
     * changes of Bruessel:
        + message handler can now take an explicit self
        * typinfo fixed: sometimes the type names weren't written

+ 6 - 2
compiler/cg386mat.pas

@@ -39,7 +39,7 @@ implementation
       cobjects,verbose,globals,
       symtable,aasm,types,
       hcodegen,temp_gen,pass_2,
-{$ifdef ag386bin}
+{$ifndef OLDASM}
       i386base,i386asm,
 {$else}
       i386,
@@ -768,7 +768,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.21  1999-04-16 13:42:27  jonas
+  Revision 1.22  1999-05-01 13:24:11  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.21  1999/04/16 13:42:27  jonas
     * more regalloc fixes (still not complete)
 
   Revision 1.20  1999/02/22 02:15:13  peter

+ 6 - 2
compiler/cg386mem.pas

@@ -47,7 +47,7 @@ implementation
       cobjects,verbose,globals,
       symtable,aasm,types,
       hcodegen,temp_gen,pass_2,pass_1,
-{$ifdef ag386bin}
+{$ifndef OLDASM}
       i386base,i386asm,
 {$else}
       i386,
@@ -882,7 +882,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.34  1999-04-26 18:29:54  peter
+  Revision 1.35  1999-05-01 13:24:13  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.34  1999/04/26 18:29:54  peter
     * farpointerdef moved into pointerdef.is_far
 
   Revision 1.33  1999/03/26 11:43:26  pierre

+ 6 - 2
compiler/cg386set.pas

@@ -38,7 +38,7 @@ implementation
       cobjects,verbose,globals,
       symtable,aasm,types,
       hcodegen,temp_gen,pass_2,
-{$ifdef ag386bin}
+{$ifndef OLDASM}
       i386base,i386asm,
 {$else}
       i386,
@@ -824,7 +824,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.27  1999-04-16 13:42:30  jonas
+  Revision 1.28  1999-05-01 13:24:15  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.27  1999/04/16 13:42:30  jonas
     * more regalloc fixes (still not complete)
 
   Revision 1.26  1999/04/09 08:36:36  peter

+ 44 - 34
compiler/csopt386.pas

@@ -31,11 +31,11 @@ Procedure CSE(AsmL: PAasmOutput; First, Last: Pai);
 
 Implementation
 
-Uses CObjects, verbose, hcodegen, globals
-   {$ifdef i386}
-     ,i386, DAOpt386
-   {$endif i386}
-     ;
+Uses
+  CObjects, verbose, hcodegen, globals
+  ,i386base,i386asm
+  ,DAOpt386;
+
 {
 Function PaiInSequence(P: Pai; Const Seq: TContent): Boolean;
 Var P1: Pai;
@@ -110,16 +110,16 @@ Begin {CheckSequence}
               (Pai(hp2)^.typ = ait_instruction) And
               ((Pai386(hp2)^.opcode = A_MOV) or
                (Pai386(p1)^.opcode = A_MOVZX)) And
-              (Pai386(hp2)^.op1t = top_ref) And
-              (Pai386(hp2)^.op2t = top_reg) And
+              (Pai386(hp2)^.oper[0].typ = top_ref) And
+              (Pai386(hp2)^.optype[1] = top_reg) And
               Assigned(hp3) And
               (Pai(hp3)^.typ = ait_instruction) And
               ((Pai386(hp3)^.opcode = A_MOV) or
                (Pai386(hp3)^.opcode = A_MOVZX)) And
-              (Pai386(hp3)^.op1t = top_ref) And
-              (Pai386(hp3)^.op2t = top_reg) And
+              (Pai386(hp3)^.oper[0].typ = top_ref) And
+              (Pai386(hp3)^.optype[1] = top_reg) And
                (Pai386(hp2)^.opcode <> Pai386(hp3)^.opcode) And
-              RefsEquivalent(TReference(Pai386(hp2)^.op1^),TReference(Pai386(hp3)^.op1^), RegInfo)
+              RefsEquivalent(TReference(Pai386(hp2)^.oper[1]^),TReference(Pai386(hp3)^.oper[1]^), RegInfo)
              Then
 
 {hack to be able to optimize
@@ -136,13 +136,13 @@ Begin {CheckSequence}
                  Then
                    Begin
                     If (Pai386(hp2)^.opsize = S_B) And
-                       RegsEquivalent(Reg8toReg32(TRegister(Pai386(hp2)^.op2)),
-                                      TRegister(Pai386(hp3)^.op2), RegInfo)
+                       RegsEquivalent(Reg8toReg32(TRegister(Pai386(hp2)^.oper[1])),
+                                      TRegister(Pai386(hp3)^.oper[1]), RegInfo)
                        Then
                          Begin
                            Pai386(hp2)^.opcode := A_MOVZX;
-                           Pai386(hp2)^.op2 := Pai386(hp3)^.op2;
                            Pai386(hp2)^.opsize := S_BL;
+                           Pai386(hp2)^.loadoper(1,Pai386(hp3)^.oper[1]);
                            Inc(Found);
                            TmpResult := True;
                          End
@@ -156,8 +156,8 @@ Begin {CheckSequence}
                  Else
                    Begin
                      If (Pai386(hp3)^.opsize = S_B) And
-                       RegsEquivalent(TRegister(Pai386(hp2)^.op2),
-                                      Reg8toReg32(TRegister(Pai386(hp3)^.op2)),
+                       RegsEquivalent(TRegister(Pai386(hp2)^.oper[1]),
+                                      Reg8toReg32(TRegister(Pai386(hp3)^.oper[1])),
                                       RegInfo)
                        Then
                          Begin
@@ -253,20 +253,20 @@ Begin
                        PPaiProp(Pai(p)^.fileinfo.line)^.CanBeRemoved := True;
               A_MOV, A_MOVZX, A_MOVSX:
                 Begin
-                  Case Pai386(p)^.op1t Of
+                  Case Pai386(p)^.oper[0].typ Of
 {                    Top_Reg:
-                      Case Pai386(p)^.op2t Of
+                      Case Pai386(p)^.optype[1] Of
                         Top_Reg:;
                         Top_Ref:;
                       End;}
                     Top_Ref:
                       Begin {destination is always a register in this case}
-                        With PPaiProp(p^.fileinfo.line)^.Regs[Reg32(Tregister(Pai386(p)^.op2))] Do
+                        With PPaiProp(p^.fileinfo.line)^.Regs[Reg32(Pai386(p)^.oper[1].reg)] Do
                           Begin
                             If GetLastInstruction (p, hp1) And
                               (hp1^.typ <> ait_marker) Then
 {so we don't try to check a sequence when p is the first instruction of the block}
-                               If CheckSequence(p, TRegister(Pai386(p)^.op2), Cnt, RegInfo) And
+                               If CheckSequence(p, Pai386(p)^.oper[1].reg, Cnt, RegInfo) And
                                   (Cnt > 0)
                                  Then
                                    Begin
@@ -291,8 +291,8 @@ Begin
                                      While Cnt2 <= Cnt Do
                                        Begin
                                          If (hp1 = nil) And
-                                            Not(RegInInstruction(Tregister(Pai386(hp2)^.op2), p) Or
-                                                RegInInstruction(Reg32(Tregister(Pai386(hp2)^.op2)), p))
+                                            Not(RegInInstruction(Pai386(hp2)^.oper[1].reg, p) Or
+                                                RegInInstruction(Reg32(Pai386(hp2)^.oper[1].reg), p))
                                            Then hp1 := p;
 {$ifndef noremove}
                                          PPaiProp(p^.fileinfo.line)^.CanBeRemoved := True;
@@ -443,16 +443,16 @@ Begin
                                  Else
                                    If (Cnt > 0) And
                                       (PPaiProp(p^.fileinfo.line)^.
-                                        Regs[Reg32(TRegister(Pai386(p)^.op2))].Typ = Con_Ref) And
+                                        Regs[Reg32(Pai386(p)^.oper[1].reg)].Typ = Con_Ref) And
                                       (PPaiProp(p^.fileinfo.line)^.CanBeRemoved) Then
                                      Begin
                                        hp2 := p;
                                        Cnt2 := 1;
                                        While Cnt2 <= Cnt Do
                                          Begin
-                                           If RegInInstruction(Tregister(Pai386(hp2)^.op2), p) Or
-                                              RegInInstruction(Reg32(Tregister(Pai386(hp2)^.op2)), p)
-                                             Then PPaiProp(p^.fileinfo.line)^.CanBeRemoved := False;
+                                           If RegInInstruction(Pai386(hp2)^.oper[1].reg, p) Or
+                                              RegInInstruction(Reg32(Pai386(hp2)^.oper[1].reg), p) Then
+                                             PPaiProp(p^.fileinfo.line)^.CanBeRemoved := False;
                                            Inc(Cnt2);
                                            GetNextInstruction(p, p);
                                          End;
@@ -462,13 +462,13 @@ Begin
                       End;
                     Top_Const:
                       Begin
-                        Case Pai386(p)^.op2t Of
+                        Case Pai386(p)^.oper[1].typ Of
                           Top_Reg:
                             Begin
                               If GetLastInstruction(p, hp1) Then
-                                With PPaiProp(hp1^.fileinfo.line)^.Regs[Reg32(TRegister(Pai386(p)^.op2))] Do
+                                With PPaiProp(hp1^.fileinfo.line)^.Regs[Reg32(Pai386(p)^.oper[1].reg)] Do
                                   If (Typ = Con_Const) And
-                                     (StartMod = Pai386(p)^.op1) Then
+                                     (StartMod = p) Then
                                     PPaiProp(p^.fileinfo.line)^.CanBeRemoved := True;
                             End;
 {                          Top_Ref:;}
@@ -481,12 +481,12 @@ Begin
                         PPaiProp(Pai(p)^.fileinfo.line)^.CanBeRemoved := True;
               A_XOR:
                 Begin
-                  If (Pai386(p)^.op1t = top_reg) And
-                     (Pai386(p)^.op2t = top_reg) And
-                     (Pai386(p)^.op1 = Pai386(p)^.op2) And
+                  If (Pai386(p)^.oper[0].typ = top_reg) And
+                     (Pai386(p)^.oper[0].typ = top_reg) And
+                     (Pai386(p)^.oper[1].reg = Pai386(p)^.oper[1].reg) And
                      GetLastInstruction(p, hp1) And
-                     (PPaiProp(hp1^.fileinfo.line)^.Regs[Reg32(Tregister(Pai386(p)^.op1))].typ = con_const) And
-                     (PPaiProp(hp1^.fileinfo.line)^.Regs[Reg32(Tregister(Pai386(p)^.op1))].StartMod = Pointer(0))
+                     (PPaiProp(hp1^.fileinfo.line)^.Regs[Reg32(Pai386(p)^.oper[1].reg)].typ = con_const) And
+                     (PPaiProp(hp1^.fileinfo.line)^.Regs[Reg32(Pai386(p)^.oper[1].reg)].StartMod = nil)
                     Then PPaiProp(p^.fileinfo.line)^.CanBeRemoved := True
                 End
             End
@@ -552,7 +552,17 @@ End.
 
 {
  $Log$
- Revision 1.19  1999-02-26 00:48:17  peter
+ Revision 1.20  1999-05-01 13:24:19  peter
+   * merged nasm compiler
+   * old asm moved to oldasm/
+
+ Revision 1.2  1999/03/29 16:05:45  peter
+   * optimizer working for ag386bin
+
+ Revision 1.1  1999/03/26 00:01:09  peter
+   * first things for optimizer (compiles but cycle crashes)
+
+ Revision 1.19  1999/02/26 00:48:17  peter
    * assembler writers fixed for ag386bin
 
  Revision 1.18  1998/12/29 18:48:22  jonas

+ 7 - 3
compiler/gdb.pas

@@ -27,7 +27,7 @@ unit gdb;
     uses
       globtype,
 {$ifdef i386}
-   {$ifdef AG386BIN}
+   {$ifndef OLDASM}
        i386base,
    {$else}
        i386,
@@ -96,7 +96,7 @@ Const
           0,1,2,3,4,5,6,7,0,1,2,3,4,5,7,0,1,2,3,0,1,2,3,
           -1,10,12,13,14,15,11,
           -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-{$ifdef AG386BIN}
+{$ifndef OLDASM}
           -1,-1,-1,-1,-1,-1,
           -1,-1,-1,-1,
           -1,-1,-1,-1,-1,
@@ -263,7 +263,11 @@ end.
 
 {
   $Log$
-  Revision 1.8  1999-03-17 10:52:38  peter
+  Revision 1.9  1999-05-01 13:24:20  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.8  1999/03/17 10:52:38  peter
     * fixed comment in directive
 
   Revision 1.7  1999/03/02 02:56:12  peter

+ 6 - 2
compiler/hcodegen.pas

@@ -29,7 +29,7 @@ unit hcodegen;
       tokens,verbose,
       aasm,symtable
 {$ifdef i386}
-{$ifdef ag386bin}
+{$ifndef OLDASM}
       ,i386base
 {$else}
       ,i386
@@ -321,7 +321,11 @@ end.
 
 {
   $Log$
-  Revision 1.29  1999-04-21 09:43:38  peter
+  Revision 1.30  1999-05-01 13:24:22  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.29  1999/04/21 09:43:38  peter
     * storenumber works
     * fixed some typos in double_checksum
     + incompatible types type1 and type2 message (with storenumber)

+ 1636 - 0
compiler/i386asm.pas

@@ -0,0 +1,1636 @@
+{
+    $Id$
+    Copyright (c) 1999 by Florian Klaempfl
+
+    Contains the assembler object for the i386
+
+    * This code was inspired by the NASM sources
+      The Netwide Assembler is copyright (C) 1996 Simon Tatham and
+      Julian Hall. All rights reserved.
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+unit i386asm;
+interface
+
+uses
+  cobjects,
+  aasm,globals,verbose,
+  i386base;
+
+{$ifndef NASMDEBUG}
+  {$define OPTEA}
+  {$define PASS2FLAG}
+{$endif ndef NASMDEBUG}
+
+{$ifndef TP}
+  {$define ASMDEBUG}
+{$endif}
+
+const
+  MaxPrefixes=4;
+
+type
+  { this is for quicker determination of the operand type instead of
+    using opertype and OT ... etc. }
+  toptype=(top_none,top_reg,top_ref,top_const,top_symbol);
+
+  toper=record
+    ot  : longint;
+    case typ : toptype of
+     top_none   : ();
+     top_reg    : (reg:tregister);
+     top_ref    : (ref:preference);
+     top_const  : (val:longint);
+     top_symbol : (sym:pasmsymbol;symofs:longint);
+  end;
+
+  pairegalloc = ^tairegalloc;
+  tairegalloc = object(tai)
+     allocation : boolean;
+     reg        : tregister;
+     constructor alloc(r : tregister);
+     constructor dealloc(r : tregister);
+  end;
+
+  paitempalloc = ^taitempalloc;
+  taitempalloc = object(tai)
+     allocation : boolean;
+     temppos,
+     tempsize   : longint;
+     constructor alloc(pos,size:longint);
+     constructor dealloc(pos,size:longint);
+  end;
+
+  pai386 = ^tai386;
+  tai386 = object(tai)
+     opcode    : tasmop;
+     opsize    : topsize;
+     condition : TAsmCond;
+     ops       : longint;
+     oper      : array[0..2] of toper;
+     constructor op_none(op : tasmop;_size : topsize);
+
+     constructor op_reg(op : tasmop;_size : topsize;_op1 : tregister);
+     constructor op_const(op : tasmop;_size : topsize;_op1 : longint);
+     constructor op_ref(op : tasmop;_size : topsize;_op1 : preference);
+
+     constructor op_reg_reg(op : tasmop;_size : topsize;_op1,_op2 : tregister);
+     constructor op_reg_ref(op : tasmop;_size : topsize;_op1 : tregister;_op2 : preference);
+     constructor op_reg_const(op:tasmop; _size: topsize; _op1: tregister; _op2: longint);
+
+     constructor op_const_reg(op : tasmop;_size : topsize;_op1 : longint;_op2 : tregister);
+     constructor op_const_const(op : tasmop;_size : topsize;_op1,_op2 : longint);
+     constructor op_const_ref(op : tasmop;_size : topsize;_op1 : longint;_op2 : preference);
+
+     constructor op_ref_reg(op : tasmop;_size : topsize;_op1 : preference;_op2 : tregister);
+     { this is only allowed if _op1 is an int value (_op1^.isintvalue=true) }
+     constructor op_ref_ref(op : tasmop;_size : topsize;_op1,_op2 : preference);
+
+     constructor op_reg_reg_reg(op : tasmop;_size : topsize;_op1,_op2,_op3 : tregister);
+     constructor op_const_reg_reg(op : tasmop;_size : topsize;_op1 : longint;_op2 : tregister;_op3 : tregister);
+     constructor op_const_ref_reg(op : tasmop;_size : topsize;_op1 : longint;_op2 : preference;_op3 : tregister);
+     constructor op_reg_reg_ref(op : tasmop;_size : topsize;_op1,_op2 : tregister; _op3 : preference);
+     constructor op_const_reg_ref(op : tasmop;_size : topsize;_op1 : longint;_op2 : tregister;_op3 : preference);
+
+     constructor op_sym(op : tasmop;_size : topsize;_op1 : pasmsymbol);
+     constructor op_sym_ofs(op : tasmop;_size : topsize;_op1 : pasmsymbol;_op1ofs:longint);
+     constructor op_sym_ofs_reg(op : tasmop;_size : topsize;_op1 : pasmsymbol;_op1ofs:longint;_op2 : tregister);
+     constructor op_sym_ofs_ref(op : tasmop;_size : topsize;_op1 : pasmsymbol;_op1ofs:longint;_op2 : preference);
+
+     procedure loadconst(opidx:longint;l:longint);
+     procedure loadsymbol(opidx:longint;s:pasmsymbol;sofs:longint);
+     procedure loadref(opidx:longint;p:preference);
+     procedure loadreg(opidx:longint;r:tregister);
+     procedure loadoper(opidx:longint;o:toper);
+     procedure changeopsize(siz:topsize);
+
+     destructor  done;virtual;
+     function  getcopy:plinkedlist_item;virtual;
+  public
+     procedure SetCondition(c:TAsmCond);
+     function  Pass1(offset:longint):longint;virtual;
+     procedure Pass2;virtual;
+     function  GetString:string;
+  private
+     segprefix : tregister;
+     { next fields are filled in pass1, so pass2 is faster }
+     insentry  : PInsEntry;
+     LastInsOffset,
+     insoffset,
+     inssize   : longint;
+     procedure init(op : tasmop;_size : topsize); { this need to be called by all constructor }
+     function  InsEnd:longint;
+     procedure create_ot;
+     function  Matches(p:PInsEntry):longint;
+     function  calcsize(p:PInsEntry):longint;
+     procedure gencode;
+     function  NeedAddrPrefix(opidx:byte):boolean;
+  end;
+
+  pai386_labeled = ^tai386_labeled;
+  tai386_labeled = object(tai386)
+     lab : plabel;
+     constructor op_lab(op : tasmop; l : plabel);
+     constructor op_cond_lab(op : tasmop; cond:tasmcond;l : plabel);
+     destructor  done;virtual;
+     function  Pass1(offset:longint):longint;virtual;
+     procedure Pass2;virtual;
+  end;
+
+
+implementation
+uses
+  og386;
+
+{*****************************************************************************
+                                 TaiRegAlloc
+*****************************************************************************}
+
+    constructor tairegalloc.alloc(r : tregister);
+      begin
+        inherited init;
+        typ:=ait_regalloc;
+        allocation:=true;
+        reg:=r;
+      end;
+
+
+    constructor tairegalloc.dealloc(r : tregister);
+      begin
+        inherited init;
+        typ:=ait_regalloc;
+        allocation:=false;
+        reg:=r;
+      end;
+
+
+{*****************************************************************************
+                                TaiTempAlloc
+*****************************************************************************}
+
+    constructor taitempalloc.alloc(pos,size:longint);
+      begin
+        inherited init;
+        typ:=ait_tempalloc;
+        allocation:=true;
+        temppos:=pos;
+        tempsize:=size;
+      end;
+
+
+    constructor taitempalloc.dealloc(pos,size:longint);
+      begin
+        inherited init;
+        typ:=ait_tempalloc;
+        allocation:=false;
+        temppos:=pos;
+        tempsize:=size;
+      end;
+
+
+{*****************************************************************************
+                                 Tai386 Constructors
+*****************************************************************************}
+
+    procedure tai386.loadconst(opidx:longint;l:longint);
+      begin
+        with oper[opidx] do
+         begin
+           if typ=top_ref then
+            disposereference(ref);
+           val:=l;
+           typ:=top_const;
+         end;
+      end;
+
+    procedure tai386.loadsymbol(opidx:longint;s:pasmsymbol;sofs:longint);
+      begin
+        with oper[opidx] do
+         begin
+           if typ=top_ref then
+            disposereference(ref);
+           sym:=s;
+           symofs:=sofs;
+           typ:=top_symbol;
+         end;
+      end;
+
+    procedure tai386.loadref(opidx:longint;p:preference);
+      begin
+        with oper[opidx] do
+         begin
+           if typ=top_ref then
+            disposereference(ref);
+           if p^.is_immediate then
+             begin
+{$ifdef ASMDEBUG1}
+               Comment(V_Warning,'Reference immediate');
+{$endif}
+               val:=p^.offset;
+               disposereference(p);
+               typ:=top_const;
+             end
+           else
+             begin
+               ref:=p;
+               if not(ref^.segment in [R_DS,R_NO,R_DEFAULT_SEG]) then
+                 segprefix:=ref^.segment;
+               typ:=top_ref;
+             end;
+         end;
+      end;
+
+    procedure tai386.loadreg(opidx:longint;r:tregister);
+      begin
+        with oper[opidx] do
+         begin
+           if typ=top_ref then
+            disposereference(ref);
+           reg:=r;
+           typ:=top_reg;
+         end;
+      end;
+
+    procedure tai386.loadoper(opidx:longint;o:toper);
+      begin
+        if oper[opidx].typ=top_ref then
+          disposereference(oper[opidx].ref);
+        oper[opidx]:=o;
+        { copy also the reference }
+        if oper[opidx].typ=top_ref then
+         oper[opidx].ref:=newreference(o.ref^);
+      end;
+
+
+    procedure tai386.changeopsize(siz:topsize);
+      begin
+        opsize:=siz;
+      end;
+
+
+    procedure tai386.init(op : tasmop;_size : topsize);
+      begin
+         typ:=ait_instruction;
+         insentry:=nil;
+         LastInsOffset:=-1;
+         InsOffset:=0;
+         segprefix:=R_NO;
+         opcode:=op;
+         opsize:=_size;
+         ops:=0;
+         fillchar(oper,sizeof(oper),0);
+      end;
+
+    constructor tai386.op_none(op : tasmop;_size : topsize);
+      begin
+         inherited init;
+         init(op,_size);
+      end;
+
+
+    constructor tai386.op_reg(op : tasmop;_size : topsize;_op1 : tregister);
+      begin
+         inherited init;
+         init(op,_size);
+         ops:=1;
+         loadreg(0,_op1);
+      end;
+
+
+    constructor tai386.op_const(op : tasmop;_size : topsize;_op1 : longint);
+      begin
+         inherited init;
+         init(op,_size);
+         ops:=1;
+         loadconst(0,_op1);
+      end;
+
+
+    constructor tai386.op_ref(op : tasmop;_size : topsize;_op1 : preference);
+      begin
+         inherited init;
+         init(op,_size);
+         ops:=1;
+         loadref(0,_op1);
+      end;
+
+
+    constructor tai386.op_reg_reg(op : tasmop;_size : topsize;_op1,_op2 : tregister);
+      begin
+         inherited init;
+         init(op,_size);
+         ops:=2;
+         loadreg(0,_op1);
+         loadreg(1,_op2);
+      end;
+
+
+    constructor tai386.op_reg_const(op:tasmop; _size: topsize; _op1: tregister; _op2: longint);
+      begin
+         inherited init;
+         init(op,_size);
+         ops:=2;
+         loadreg(0,_op1);
+         loadconst(1,_op2);
+      end;
+
+
+    constructor tai386.op_reg_ref(op : tasmop;_size : topsize;_op1 : tregister;_op2 : preference);
+      begin
+         inherited init;
+         init(op,_size);
+         ops:=2;
+         loadreg(0,_op1);
+         loadref(1,_op2);
+      end;
+
+
+    constructor tai386.op_const_reg(op : tasmop;_size : topsize;_op1 : longint;_op2 : tregister);
+      begin
+         inherited init;
+         init(op,_size);
+         ops:=2;
+         loadconst(0,_op1);
+         loadreg(1,_op2);
+      end;
+
+
+    constructor tai386.op_const_const(op : tasmop;_size : topsize;_op1,_op2 : longint);
+      begin
+         inherited init;
+         init(op,_size);
+         ops:=2;
+         loadconst(0,_op1);
+         loadconst(1,_op2);
+      end;
+
+
+    constructor tai386.op_const_ref(op : tasmop;_size : topsize;_op1 : longint;_op2 : preference);
+      begin
+         inherited init;
+         init(op,_size);
+         ops:=2;
+         loadconst(0,_op1);
+         loadref(1,_op2);
+      end;
+
+    constructor tai386.op_ref_reg(op : tasmop;_size : topsize;_op1 : preference;_op2 : tregister);
+      begin
+         inherited init;
+         init(op,_size);
+         ops:=2;
+         loadref(0,_op1);
+         loadreg(1,_op2);
+      end;
+
+
+    constructor tai386.op_ref_ref(op : tasmop;_size : topsize;_op1,_op2 : preference);
+      begin
+         inherited init;
+         init(op,_size);
+         ops:=2;
+         loadref(0,_op1);
+         loadref(1,_op2);
+      end;
+
+
+    constructor tai386.op_reg_reg_reg(op : tasmop;_size : topsize;_op1,_op2,_op3 : tregister);
+      begin
+         inherited init;
+         init(op,_size);
+         ops:=3;
+         loadreg(0,_op1);
+         loadreg(1,_op2);
+         loadreg(2,_op3);
+      end;
+
+    constructor tai386.op_const_reg_reg(op : tasmop;_size : topsize;_op1 : longint;_op2 : tregister;_op3 : tregister);
+      begin
+         inherited init;
+         init(op,_size);
+         ops:=3;
+         loadconst(0,_op1);
+         loadreg(1,_op2);
+         loadreg(2,_op3);
+      end;
+
+     constructor tai386.op_reg_reg_ref(op : tasmop;_size : topsize;_op1,_op2 : tregister;_op3 : preference);
+      begin
+         inherited init;
+         init(op,_size);
+         ops:=3;
+         loadreg(0,_op1);
+         loadreg(1,_op2);
+         loadref(2,_op3);
+      end;
+
+     constructor tai386.op_const_ref_reg(op : tasmop;_size : topsize;_op1 : longint;_op2 : preference;_op3 : tregister);
+      begin
+         inherited init;
+         init(op,_size);
+         ops:=3;
+         loadconst(0,_op1);
+         loadref(1,_op2);
+         loadreg(2,_op3);
+      end;
+
+     constructor tai386.op_const_reg_ref(op : tasmop;_size : topsize;_op1 : longint;_op2 : tregister;_op3 : preference);
+      begin
+         inherited init;
+         init(op,_size);
+         ops:=3;
+         loadconst(0,_op1);
+         loadreg(1,_op2);
+         loadref(2,_op3);
+      end;
+
+
+    constructor tai386.op_sym(op : tasmop;_size : topsize;_op1 : pasmsymbol);
+      begin
+         inherited init;
+         init(op,_size);
+         ops:=1;
+         loadsymbol(0,_op1,0);
+      end;
+
+
+    constructor tai386.op_sym_ofs(op : tasmop;_size : topsize;_op1 : pasmsymbol;_op1ofs:longint);
+      begin
+         inherited init;
+         init(op,_size);
+         ops:=1;
+         loadsymbol(0,_op1,_op1ofs);
+      end;
+
+
+    constructor tai386.op_sym_ofs_reg(op : tasmop;_size : topsize;_op1 : pasmsymbol;_op1ofs:longint;_op2 : tregister);
+      begin
+         inherited init;
+         init(op,_size);
+         ops:=2;
+         loadsymbol(0,_op1,_op1ofs);
+         loadreg(1,_op2);
+      end;
+
+
+    constructor tai386.op_sym_ofs_ref(op : tasmop;_size : topsize;_op1 : pasmsymbol;_op1ofs:longint;_op2 : preference);
+      begin
+         inherited init;
+         init(op,_size);
+         ops:=2;
+         loadsymbol(0,_op1,_op1ofs);
+         loadref(0,_op2);
+      end;
+
+
+    destructor tai386.done;
+      var
+        i : longint;
+      begin
+        for i:=1 to ops do
+         if (oper[i-1].typ=top_ref) then
+          dispose(oper[i-1].ref);
+        inherited done;
+      end;
+
+
+    function tai386.getcopy:plinkedlist_item;
+      var
+        i : longint;
+        p : plinkedlist_item;
+      begin
+        p:=inherited getcopy;
+        { make a copy of the references }
+        for i:=1 to ops do
+         if (pai386(p)^.oper[i-1].typ=top_ref) then
+          begin
+            new(pai386(p)^.oper[i-1].ref);
+            pai386(p)^.oper[i-1].ref^:=oper[i-1].ref^;
+          end;
+        getcopy:=p;
+      end;
+
+
+    procedure tai386.SetCondition(c:TAsmCond);
+      begin
+         condition:=c;
+      end;
+
+
+    function tai386.GetString:string;
+{$ifdef ASMDEBUG}
+      var
+        i : longint;
+        s : string;
+{$endif}
+      begin
+{$ifdef ASMDEBUG}
+        s:='['+int_op2str[opcode];
+        for i:=1to ops do
+         begin
+           if i=1 then
+            s:=s+' '
+           else
+            s:=s+',';
+           { type }
+           if (oper[i-1].ot and OT_REGISTER)<>0 then
+             s:=s+'reg'
+           else
+            if (oper[i-1].ot and OT_IMMEDIATE)<>0 then
+             s:=s+'imm'
+           else
+            if (oper[i-1].ot and OT_MEMORY)<>0 then
+             s:=s+'mem'
+           else
+             s:=s+'???';
+           { size }
+           if (oper[i-1].ot and OT_BITS8)<>0 then
+             s:=s+'8'
+           else
+            if (oper[i-1].ot and OT_BITS16)<>0 then
+             s:=s+'16'
+           else
+            if (oper[i-1].ot and OT_BITS32)<>0 then
+             s:=s+'32'
+           else
+             s:=s+'??';
+           { signed }
+           if (oper[i-1].ot and OT_SIGNED)<>0 then
+             s:=s+'s';
+         end;
+        GetString:=s+']';
+{$else}
+        GetString:='';
+{$endif ASMDEBUG}
+      end;
+
+
+{*****************************************************************************
+                                Assembler
+*****************************************************************************}
+
+type
+  ea=packed record
+    sib_present : boolean;
+    bytes : byte;
+    size  : byte;
+    modrm : byte;
+    sib   : byte;
+  end;
+
+procedure tai386.create_ot;
+{
+  this function will also fix some other fields which only needs to be once
+}
+var
+  i,l,relsize : longint;
+begin
+  if ops=0 then
+   exit;
+  { update oper[].ot field }
+  for i:=0 to ops-1 do
+   with oper[i] do
+    begin
+      case typ of
+        top_reg :
+          ot:=reg_2_type[reg];
+        top_ref :
+          begin
+          { create ot field }
+            ot:=OT_MEMORY or opsize_2_type[i,opsize];
+            if (ref^.base=R_NO) and (ref^.index=R_NO) then
+              ot:=ot or OT_MEM_OFFS;
+          { handle also the offsetfixup }
+            inc(ref^.offset,ref^.offsetfixup);
+            ref^.offsetfixup:=0;
+          { fix scalefactor }
+            if (ref^.index=R_NO) then
+             ref^.scalefactor:=0
+            else
+             if (ref^.scalefactor=0) then
+              ref^.scalefactor:=1;
+          end;
+        top_const :
+          begin
+            if (opsize<>S_W) and (val>=-128) and (val<=127) then
+              ot:=OT_IMM8 or OT_SIGNED
+            else
+              ot:=OT_IMMEDIATE or opsize_2_type[i,opsize];
+          end;
+        top_symbol :
+          begin
+            if LastInsOffset=-1 then
+             l:=0
+            else
+             l:=InsOffset-LastInsOffset;
+            inc(l,symofs);
+            if assigned(sym) then
+             inc(l,sym^.address);
+            { instruction size will then always become 2 (PFV) }
+            relsize:=InsOffset+2-l;
+            if (l<>-1) and
+               (not assigned(sym) or (sym^.typ<>AS_EXTERNAL)) and
+               (relsize>=-128) and (relsize<=127) then
+             ot:=OT_IMM32 or OT_SHORT
+            else
+             ot:=OT_IMM32 or OT_NEAR;
+          end;
+      end;
+    end;
+end;
+
+
+function tai386.InsEnd:longint;
+begin
+  InsEnd:=InsOffset+InsSize;
+end;
+
+
+function tai386.Matches(p:PInsEntry):longint;
+{ * IF_SM stands for Size Match: any operand whose size is not
+ * explicitly specified by the template is `really' intended to be
+ * the same size as the first size-specified operand.
+ * Non-specification is tolerated in the input instruction, but
+ * _wrong_ specification is not.
+ *
+ * IF_SM2 invokes Size Match on only the first _two_ operands, for
+ * three-operand instructions such as SHLD: it implies that the
+ * first two operands must match in size, but that the third is
+ * required to be _unspecified_.
+ *
+ * IF_SB invokes Size Byte: operands with unspecified size in the
+ * template are really bytes, and so no non-byte specification in
+ * the input instruction will be tolerated. IF_SW similarly invokes
+ * Size Word, and IF_SD invokes Size Doubleword.
+ *
+ * (The default state if neither IF_SM nor IF_SM2 is specified is
+ * that any operand with unspecified size in the template is
+ * required to have unspecified size in the instruction too...)
+}
+var
+  i,siz,oprs : longint;
+begin
+  Matches:=100;
+
+  { Check the opcode and operands }
+  if (p^.opcode<>opcode) or (p^.ops<>ops) then
+   begin
+     Matches:=0;
+     exit;
+   end;
+
+  { Check that no spurious colons or TOs are present }
+  for i:=0 to p^.ops-1 do
+   if (oper[i].ot and (not p^.optypes[i]) and (OT_COLON or OT_TO))<>0 then
+    begin
+      Matches:=0;
+      exit;
+    end;
+
+  { Check that the operand flags all match up }
+  for i:=0 to p^.ops-1 do
+   begin
+     if (p^.optypes[i] and (not oper[i].ot) or
+         ((p^.optypes[i] and OT_SIZE_MASK) and
+          ((p^.optypes[i] xor oper[i].ot) and OT_SIZE_MASK)))<>0 then
+      begin
+        if ((p^.optypes[i] and (not oper[i].ot) and OT_NON_SIZE) or
+            (oper[i].ot and OT_SIZE_MASK))<>0 then
+         begin
+           Matches:=0;
+           exit;
+         end
+        else
+         Matches:=1;
+      end;
+   end;
+
+{ Check operand sizes }
+  { as default an untyped size can get all the sizes, this is different
+    from nasm, but else we need to do a lot checking which opcodes want
+    size or not with the automatic size generation }
+  siz:=$ffffffff;
+  if (p^.flags and IF_SB)<>0 then
+    siz:=OT_BITS8
+  else if (p^.flags and IF_SW)<>0 then
+    siz:=OT_BITS16
+  else if (p^.flags and IF_SD)<>0 then
+    siz:=OT_BITS32
+  else if (p^.flags and (IF_SM or IF_SM2))<>0 then
+   begin
+     if (p^.flags and IF_SM2)<>0 then
+      oprs:=2
+     else
+      oprs:=p^.ops;
+     for i:=0 to oprs-1 do
+      if ((p^.optypes[i] and OT_SIZE_MASK) <> 0) then
+       begin
+         siz:=p^.optypes[i] and OT_SIZE_MASK;
+         break;
+       end;
+    end;
+
+  { Check operand sizes }
+  for i:=0to p^.ops-1 do
+   begin
+     if ((p^.optypes[i] and OT_SIZE_MASK)=0) and
+        ((oper[i].ot and OT_SIZE_MASK and (not siz))<>0) and
+        { Immediates can always include smaller size }
+        ((oper[i].ot and OT_IMMEDIATE)=0) and
+         (((p^.optypes[i] and OT_SIZE_MASK) or siz)<(oper[i].ot and OT_SIZE_MASK)) then
+      Matches:=2;
+   end;
+end;
+
+
+function tai386.Pass1(offset:longint):longint;
+var
+  m,i,size_prob : longint;
+  p : toper;
+begin
+  Pass1:=0;
+{ Save the old offset and set the new offset }
+  InsOffset:=Offset;
+{ Things which may only be done once, not when a second pass is done to
+  optimize }
+  if not assigned(Insentry) then
+   begin
+     { Check if error last time then InsSize=-1 }
+     if InsSize=-1 then
+      exit;
+     { Fix the operands which are in AT&T style and we need them in Intel style }
+     case ops of
+       2 : begin
+             { 0,1 -> 1,0 }
+             p:=oper[0];
+             oper[0]:=oper[1];
+             oper[1]:=p;
+           end;
+       3 : begin
+             { 0,1,2 -> 2,1,0 }
+             p:=oper[0];
+             oper[0]:=oper[2];
+             oper[2]:=p;
+           end;
+     end;
+     { create the .ot fields }
+     create_ot;
+     { set the file postion }
+     aktfilepos:=fileinfo;
+   end
+  else
+   begin
+{$ifdef PASS2FLAG}
+     { we are here in a second pass, check if the instruction can be optimized }
+     if (InsEntry^.flags and IF_PASS2)=0 then
+      begin
+        Pass1:=InsSize;
+        exit;
+      end;
+     { update the .ot fields, some top_const can be updated }
+     create_ot;
+{$endif}
+   end;
+{ Lookup opcode in the table }
+  InsSize:=-1;
+  size_prob:=0;
+  i:=instabcache^[opcode];
+  if i=-1 then
+   begin
+     Comment(V_Warning,'opcode not in the table !');
+     exit;
+   end;
+  insentry:=@instab[i];
+  while (insentry^.opcode=opcode) do
+   begin
+     m:=matches(insentry);
+     if m=100 then
+      begin
+        InsSize:=calcsize(insentry);
+        if not(segprefix in [R_NO,R_DEFAULT_SEG]) then
+         inc(InsSize);
+        Pass1:=InsSize;
+        LastInsOffset:=InsOffset;
+        exit;
+      end;
+     inc(i);
+     insentry:=@instab[i];
+   end;
+  if insentry^.opcode<>opcode then
+   begin
+     case size_prob of
+      1 : Comment(V_Warning,GetString+' operation size not specified');
+      2 : Comment(V_Warning,GetString+' mismatch in operand sizes');
+     else
+      Comment(V_Warning,GetString+' invalid combination of opcode and operands');
+     end;
+   end;
+{ No instruction found, set insentry to nil and inssize to -1 }
+  insentry:=nil;
+  inssize:=-1;
+  LastInsOffset:=-1;
+end;
+
+
+procedure tai386.Pass2;
+var
+  c : longint;
+begin
+  { error in pass1 ? }
+  if not assigned(insentry) then
+   exit;
+  aktfilepos:=fileinfo;
+  { Segment override }
+  if not(segprefix in [R_NO,R_DEFAULT_SEG]) then
+   begin
+     case segprefix of
+       R_CS : c:=$2e;
+       R_DS : c:=$3e;
+       R_ES : c:=$26;
+       R_FS : c:=$64;
+       R_GS : c:=$65;
+       R_SS : c:=$36;
+     end;
+     objectoutput^.writebytes(c,1);
+     { fix the offset for GenNode }
+     inc(InsOffset);
+   end;
+  { Generate the instruction }
+  GenCode;
+end;
+
+
+function tai386.NeedAddrPrefix(opidx:byte):boolean;
+var
+  i,b : tregister;
+begin
+  if (OT_MEMORY and (not oper[opidx].ot))=0 then
+   begin
+     i:=oper[opidx].ref^.index;
+     b:=oper[opidx].ref^.base;
+     if not(i in [R_NO,R_EAX,R_EBX,R_ECX,R_EDX,R_EBP,R_ESP,R_ESI,R_EDI]) or
+        not(b in [R_NO,R_EAX,R_EBX,R_ECX,R_EDX,R_EBP,R_ESP,R_ESI,R_EDI]) then
+      begin
+        NeedAddrPrefix:=true;
+        exit;
+      end;
+   end;
+  NeedAddrPrefix:=false;
+end;
+
+
+function regval(r:tregister):byte;
+begin
+  case r of
+    R_EAX,R_AX,R_AL,R_ES,R_CR0,R_DR0,R_ST0,R_MM0 :
+      regval:=0;
+    R_ECX,R_CX,R_CL,R_CS,R_DR1,R_ST1,R_MM1 :
+      regval:=1;
+    R_EDX,R_DX,R_DL,R_SS,R_CR2,R_DR2,R_ST2,R_MM2 :
+      regval:=2;
+    R_EBX,R_BX,R_BL,R_DS,R_CR3,R_DR3,R_TR3,R_ST3,R_MM3 :
+      regval:=3;
+    R_ESP,R_SP,R_AH,R_FS,R_CR4,R_TR4,R_ST4,R_MM4 :
+      regval:=4;
+    R_EBP,R_BP,R_CH,R_GS,R_TR5,R_ST5,R_MM5 :
+      regval:=5;
+    R_ESI,R_SI,R_DH,R_DR6,R_TR6,R_ST6,R_MM6 :
+      regval:=6;
+    R_EDI,R_DI,R_BH,R_DR7,R_TR7,R_ST7,R_MM7 :
+      regval:=7;
+    else
+      begin
+        Comment(V_Warning,'invalid register operand given to regval()');
+        regval:=0;
+      end;
+  end;
+end;
+
+
+function process_ea(const input:toper;var output:ea;rfield:longint):boolean;
+const
+  regs : array[0..31] of tregister=(
+    R_MM0, R_EAX, R_AX, R_AL, R_MM1, R_ECX, R_CX, R_CL,
+    R_MM2, R_EDX, R_DX, R_DL, R_MM3, R_EBX, R_BX, R_BL,
+    R_MM4, R_ESP, R_SP, R_AH, R_MM5, R_EBP, R_BP, R_CH,
+    R_MM6, R_ESI, R_SI, R_DH, R_MM7, R_EDI, R_DI, R_BH
+  );
+var
+  j     : longint;
+  i,b   : tregister;
+  sym   : pasmsymbol;
+  md,s  : byte;
+  base,index,scalefactor,
+  o     : longint;
+begin
+  process_ea:=false;
+{ register ? }
+  if (input.typ=top_reg) then
+   begin
+     j:=0;
+     while (j<=high(regs)) do
+      begin
+        if input.reg=regs[j] then
+         break;
+        inc(j);
+      end;
+     if j<=high(regs) then
+      begin
+        output.sib_present:=false;
+        output.bytes:=0;
+        output.modrm:=$c0 or (rfield shl 3) or (j shr 2);
+        output.size:=1;
+        process_ea:=true;
+      end;
+     exit;
+   end;
+{ memory reference }
+  i:=input.ref^.index;
+  b:=input.ref^.base;
+  s:=input.ref^.scalefactor;
+  o:=input.ref^.offset;
+  sym:=input.ref^.symbol;
+{ it's direct address }
+  if (b=R_NO) and (i=R_NO) then
+   begin
+     { it's a pure offset }
+     output.sib_present:=false;
+     output.bytes:=4;
+     output.modrm:=5 or (rfield shl 3);
+   end
+  else
+  { it's an indirection }
+   begin
+     { 16 bit address? }
+     if not((i in [R_NO,R_EAX,R_EBX,R_ECX,R_EDX,R_EBP,R_ESP,R_ESI,R_EDI]) and
+            (b in [R_NO,R_EAX,R_EBX,R_ECX,R_EDX,R_EBP,R_ESP,R_ESI,R_EDI])) then
+      Comment(V_Warning,'16 bit ea not supported');
+{$ifdef OPTEA}
+     { make single reg base }
+     if (b=R_NO) and (s=1) then
+      begin
+        b:=i;
+        i:=R_NO;
+      end;
+     { convert [3,5,9]*EAX to EAX+[2,4,8]*EAX }
+     if (b=R_NO) and
+        (((s=2) and (i<>R_ESP)) or
+          (s=3) or (s=5) or (s=9)) then
+      begin
+        b:=i;
+        dec(s);
+      end;
+     { swap ESP into base if scalefactor is 1 }
+     if (s=1) and (i=R_ESP) then
+      begin
+        i:=b;
+        b:=R_ESP;
+      end;
+{$endif}
+     { wrong, for various reasons }
+     if (i=R_ESP) or ((s<>1) and (s<>2) and (s<>4) and (s<>8) and (i<>R_NO)) then
+      exit;
+     { base }
+     case b of
+       R_EAX : base:=0;
+       R_ECX : base:=1;
+       R_EDX : base:=2;
+       R_EBX : base:=3;
+       R_ESP : base:=4;
+       R_NO,
+       R_EBP : base:=5;
+       R_ESI : base:=6;
+       R_EDI : base:=7;
+     else
+       exit;
+     end;
+     { index }
+     case i of
+       R_EAX : index:=0;
+       R_ECX : index:=1;
+       R_EDX : index:=2;
+       R_EBX : index:=3;
+       R_NO  : index:=4;
+       R_EBP : index:=5;
+       R_ESI : index:=6;
+       R_EDI : index:=7;
+     else
+       exit;
+     end;
+     case s of
+      0,
+      1 : scalefactor:=0;
+      2 : scalefactor:=1;
+      4 : scalefactor:=2;
+      8 : scalefactor:=3;
+     else
+      exit;
+     end;
+     if (b=R_NO) or
+        ((b<>R_EBP) and (o=0) and (sym=nil)) then
+      md:=0
+     else
+      if ((o>=-128) and (o<=127) and (sym=nil)) then
+       md:=1
+      else
+       md:=2;
+     if (b=R_NO) or (md=2) then
+      output.bytes:=4
+     else
+      output.bytes:=md;
+     { SIB needed ? }
+     if (i=R_NO) and (b<>R_ESP) then
+      begin
+        output.sib_present:=false;
+        output.modrm:=(md shl 6) or (rfield shl 3) or base;
+      end
+     else
+      begin
+        output.sib_present:=true;
+        output.modrm:=(md shl 6) or (rfield shl 3) or 4;
+        output.sib:=(scalefactor shl 6) or (index shl 3) or base;
+      end;
+   end;
+  if output.sib_present then
+   output.size:=2+output.bytes
+  else
+   output.size:=1+output.bytes;
+  process_ea:=true;
+end;
+
+
+function tai386.calcsize(p:PInsEntry):longint;
+var
+  codes : pchar;
+  c     : byte;
+  len     : longint;
+  ea_data : ea;
+begin
+  len:=0;
+  codes:=@p^.code;
+  repeat
+    c:=ord(codes^);
+    inc(codes);
+    case c of
+      0 :
+        break;
+      1,2,3 :
+        begin
+          inc(codes,c);
+          inc(len,c);
+        end;
+      8,9,10 :
+        begin
+          inc(codes);
+          inc(len);
+        end;
+      4,5,6,7,
+      15,
+      12,13,14,
+      16,17,18,
+      20,21,22,
+      40,41,42 :
+        inc(len);
+      24,25,26,
+      31,
+      48,49,50 :
+        inc(len,2);
+      28,29,30, { we don't have 16 bit immediates code }
+      32,33,34,
+      52,53,54,
+      56,57,58 :
+        inc(len,4);
+      192,193,194 :
+        if NeedAddrPrefix(c-192) then
+         inc(len);
+      208 :
+        inc(len);
+      200,
+      201,
+      202,
+      209,
+      210 : ;
+      216 :
+        begin
+          inc(codes);
+          inc(len);
+        end;
+      224,225,226 :
+        begin
+          Comment(V_Warning,'not supported');
+        end;
+      else
+        begin
+          if (c>=64) and (c<=191) then
+           begin
+             if not process_ea(oper[(c shr 3) and 7], ea_data, 0) then
+              Comment(V_Warning,'invalid effective address')
+             else
+              inc(len,ea_data.size);
+           end
+          else
+           begin
+             Comment(V_Warning,'internal instruction table corrupt: instruction code '+tostr(c)+' given');
+           end;
+        end;
+    end;
+  until false;
+  calcsize:=len;
+end;
+
+
+procedure tai386.GenCode;
+{
+ * the actual codes (C syntax, i.e. octal):
+ * \0            - terminates the code. (Unless it's a literal of course.)
+ * \1, \2, \3    - that many literal bytes follow in the code stream
+ * \4, \6        - the POP/PUSH (respectively) codes for CS, DS, ES, SS
+ *                 (POP is never used for CS) depending on operand 0
+ * \5, \7        - the second byte of POP/PUSH codes for FS, GS, depending
+ *                 on operand 0
+ * \10, \11, \12 - a literal byte follows in the code stream, to be added
+ *                 to the register value of operand 0, 1 or 2
+ * \17           - encodes the literal byte 0. (Some compilers don't take
+ *                 kindly to a zero byte in the _middle_ of a compile time
+ *                 string constant, so I had to put this hack in.)
+ * \14, \15, \16 - a signed byte immediate operand, from operand 0, 1 or 2
+ * \20, \21, \22 - a byte immediate operand, from operand 0, 1 or 2
+ * \24, \25, \26 - an unsigned byte immediate operand, from operand 0, 1 or 2
+ * \30, \31, \32 - a word immediate operand, from operand 0, 1 or 2
+ * \34, \35, \36 - select between \3[012] and \4[012] depending on 16/32 bit
+ *                 assembly mode or the address-size override on the operand
+ * \37           - a word constant, from the _segment_ part of operand 0
+ * \40, \41, \42 - a long immediate operand, from operand 0, 1 or 2
+ * \50, \51, \52 - a byte relative operand, from operand 0, 1 or 2
+ * \60, \61, \62 - a word relative operand, from operand 0, 1 or 2
+ * \64, \65, \66 - select between \6[012] and \7[012] depending on 16/32 bit
+ *                 assembly mode or the address-size override on the operand
+ * \70, \71, \72 - a long relative operand, from operand 0, 1 or 2
+ * \1ab          - a ModRM, calculated on EA in operand a, with the spare
+ *                 field the register value of operand b.
+ * \2ab          - a ModRM, calculated on EA in operand a, with the spare
+ *                 field equal to digit b.
+ * \30x          - might be an 0x67 byte, depending on the address size of
+ *                 the memory reference in operand x.
+ * \310          - indicates fixed 16-bit address size, i.e. optional 0x67.
+ * \311          - indicates fixed 32-bit address size, i.e. optional 0x67.
+ * \320          - indicates fixed 16-bit operand size, i.e. optional 0x66.
+ * \321          - indicates fixed 32-bit operand size, i.e. optional 0x66.
+ * \322          - indicates that this instruction is only valid when the
+ *                 operand size is the default (instruction to disassembler,
+ *                 generates no code in the assembler)
+ * \330          - a literal byte follows in the code stream, to be added
+ *                 to the condition code value of the instruction.
+ * \340          - reserve <operand 0> bytes of uninitialised storage.
+ *                 Operand 0 had better be a segmentless constant.
+}
+
+var
+  currval : longint;
+  currsym : pasmsymbol;
+
+  procedure getvalsym(opidx:longint);
+  begin
+    case oper[opidx].typ of
+      top_ref :
+        begin
+          currval:=oper[opidx].ref^.offset;
+          currsym:=oper[opidx].ref^.symbol;
+        end;
+      top_const :
+        begin
+          currval:=oper[opidx].val;
+          currsym:=nil;
+        end;
+      top_symbol :
+        begin
+          currval:=oper[opidx].symofs;
+          currsym:=oper[opidx].sym;
+        end;
+      else
+        Comment(V_Error,'immediate or reference expected');
+    end;
+  end;
+
+const
+  CondVal:array[TAsmCond] of byte=($0,
+   $7, $3, $2, $6, $2, $4, $F, $D, $C, $E, $6, $2,
+   $3, $7, $3, $5, $E, $C, $D, $F, $1, $B, $9, $5,
+   $0, $A, $A, $B, $8, $4);
+var
+  c : byte;
+  pb,
+  codes : pchar;
+  bytes : array[0..3] of byte;
+  rfield,
+  data,s,opidx : longint;
+  ea_data : ea;
+begin
+  codes:=insentry^.code;
+  repeat
+    c:=ord(codes^);
+    inc(codes);
+    case c of
+      0 :
+        break;
+      1,2,3 :
+        begin
+          objectoutput^.writebytes(codes^,c);
+          inc(codes,c);
+        end;
+      4,6 :
+        begin
+          case oper[0].reg of
+            R_CS :
+              begin
+                if c=4 then
+                 bytes[0]:=$f
+                else
+                 bytes[0]:=$e;
+              end;
+            R_DEFAULT_SEG,
+            R_DS :
+              begin
+                if c=4 then
+                 bytes[0]:=$1f
+                else
+                 bytes[0]:=$1e;
+              end;
+            R_ES :
+              begin
+                if c=4 then
+                 bytes[0]:=$7
+                else
+                 bytes[0]:=$6;
+              end;
+            R_SS :
+              begin
+                if c=4 then
+                 bytes[0]:=$17
+                else
+                 bytes[0]:=$16;
+              end;
+            else
+              Comment(V_Warning,'bizarre 8086 segment register received');
+          end;
+          objectoutput^.writebytes(bytes,1);
+        end;
+      5,7 :
+        begin
+          case oper[0].reg of
+            R_FS :
+              begin
+                if c=5 then
+                 bytes[0]:=$a1
+                else
+                 bytes[0]:=$a0;
+              end;
+            R_GS :
+              begin
+                if c=5 then
+                 bytes[0]:=$a9
+                else
+                 bytes[0]:=$a8;
+              end;
+            else
+              Comment(V_Warning,'bizarre 386 segment register received');
+          end;
+          objectoutput^.writebytes(bytes,1);
+        end;
+      8,9,10 :
+        begin
+          bytes[0]:=ord(codes^)+regval(oper[c-8].reg);
+          inc(codes);
+          objectoutput^.writebytes(bytes,1);
+        end;
+      15 :
+        begin
+          bytes[0]:=0;
+          objectoutput^.writebytes(bytes,1);
+        end;
+      12,13,14 :
+        begin
+          getvalsym(c-12);
+          if (currval<-128) or (currval>127) then
+           Comment(V_Warning,'signed byte value exceeds bounds '+tostr(currval));
+          if assigned(currsym) then
+            objectoutput^.writereloc(currval,1,currsym,relative_false)
+          else
+            objectoutput^.writebytes(currval,1);
+        end;
+      16,17,18 :
+        begin
+          getvalsym(c-16);
+          if (currval<-256) or (currval>255) then
+            Comment(V_Warning,'byte value exceeds bounds '+tostr(currval));
+          if assigned(currsym) then
+           objectoutput^.writereloc(currval,1,currsym,relative_false)
+          else
+           objectoutput^.writebytes(currval,1);
+        end;
+      20,21,22 :
+        begin
+          getvalsym(c-20);
+          if (currval<0) or (currval>255) then
+            Comment(V_Warning,'unsigned byte value exceeds bounds '+tostr(currval));
+          if assigned(currsym) then
+           objectoutput^.writereloc(currval,1,currsym,relative_false)
+          else
+           objectoutput^.writebytes(currval,1);
+        end;
+      24,25,26 :
+        begin
+          getvalsym(c-24);
+          if (currval<-65536) or (currval>65535) then
+            Comment(V_Warning,'word value exceeds bounds '+tostr(currval));
+          if assigned(currsym) then
+           objectoutput^.writereloc(currval,2,currsym,relative_false)
+          else
+           objectoutput^.writebytes(currval,2);
+        end;
+      31 :
+        begin
+          Comment(V_Warning,'not supported');
+        end;
+      28,29,30 :
+        begin
+          getvalsym(c-28);
+          if assigned(currsym) then
+           objectoutput^.writereloc(currval,4,currsym,relative_false)
+          else
+           objectoutput^.writebytes(currval,4);
+        end;
+      32,33,34 :
+        begin
+          getvalsym(c-32);
+          if assigned(currsym) then
+           objectoutput^.writereloc(currval,4,currsym,relative_false)
+          else
+           objectoutput^.writebytes(currval,4);
+        end;
+      40,41,42 :
+        begin
+          getvalsym(c-40);
+          data:=currval-insend;
+          if assigned(currsym) then
+           inc(data,currsym^.address);
+          if (data>127) or (data<-128) then
+           Comment(V_Warning,'short jump is out of range '+tostr(data));
+          objectoutput^.writebytes(data,1);
+        end;
+      48,49,50 :
+        begin
+          Comment(V_Warning,'rel2adr not supported');
+        end;
+      52,53,54 :
+        begin
+          getvalsym(c-52);
+          if assigned(currsym) then
+           objectoutput^.writereloc(currval,4,currsym,relative_true)
+          else
+           objectoutput^.writereloc(currval-insend,4,nil,relative_false)
+        end;
+      56,57,58 :
+        begin
+          getvalsym(c-56);
+          if assigned(currsym) then
+           objectoutput^.writereloc(currval,4,currsym,relative_true)
+          else
+           objectoutput^.writereloc(currval-insend,4,nil,relative_false)
+        end;
+      192,193,194 :
+        begin
+          if NeedAddrPrefix(c-192) then
+           begin
+             bytes[0]:=$67;
+             objectoutput^.writebytes(bytes,1);
+           end;
+        end;
+      200 :
+        begin
+          bytes[0]:=$67;
+          objectoutput^.writebytes(bytes,1);
+        end;
+      201 :
+        begin
+        end;
+      202 :
+        begin
+        end;
+      208 :
+        begin
+          bytes[0]:=$66;
+          objectoutput^.writebytes(bytes,1);
+        end;
+      209 :
+        begin
+        end;
+      210 :
+        begin
+        end;
+      216 :
+        begin
+          bytes[0]:=ord(codes^)+condval[condition];
+          inc(codes);
+          objectoutput^.writebytes(bytes,1);
+        end;
+      224,225,226 :
+        begin
+          Comment(V_Warning,'not supported');
+        end
+      else
+        begin
+          if (c>=64) and (c<=191) then
+           begin
+             if (c<127) then
+              begin
+                if (oper[c and 7].typ=top_reg) then
+                  rfield:=regval(oper[c and 7].reg)
+                else
+                  rfield:=regval(oper[c and 7].ref^.base);
+              end
+             else
+              rfield:=c and 7;
+             opidx:=(c shr 3) and 7;
+             if not process_ea(oper[opidx], ea_data, rfield) then
+              Comment(V_Warning,'invalid effective address');
+
+             pb:=@bytes;
+             pb^:=chr(ea_data.modrm);
+             inc(pb);
+             if ea_data.sib_present then
+              begin
+                pb^:=chr(ea_data.sib);
+                inc(pb);
+              end;
+
+             s:=pb-pchar(@bytes);
+             objectoutput^.writebytes(bytes,s);
+
+             case ea_data.bytes of
+               0 : ;
+               1 :
+                 begin
+                   if (oper[opidx].ot and OT_MEMORY)=OT_MEMORY then
+                    objectoutput^.writereloc(oper[opidx].ref^.offset,1,oper[opidx].ref^.symbol,relative_false)
+                   else
+                    begin
+                      bytes[0]:=oper[opidx].ref^.offset;
+                      objectoutput^.writebytes(bytes,1);
+                    end;
+                   inc(s);
+                 end;
+               2,4 :
+                 begin
+                   objectoutput^.writereloc(oper[opidx].ref^.offset,ea_data.bytes,
+                     oper[opidx].ref^.symbol,relative_false);
+                   inc(s,ea_data.bytes);
+                 end;
+             end;
+           end
+          else
+           begin
+             Comment(V_Warning,'internal instruction table corrupt: instruction code '+tostr(c)+' given');
+           end;
+        end;
+    end;
+  until false;
+end;
+
+{*****************************************************************************
+                               Tai_Labeled
+*****************************************************************************}
+
+    constructor tai386_labeled.op_lab(op : tasmop; l : plabel);
+      begin
+         inherited op_none(op,S_NO);
+         typ:=ait_labeled_instruction;
+         lab:=l;
+         lab^.is_used:=true;
+         inc(lab^.refcount);
+      end;
+
+    constructor tai386_labeled.op_cond_lab(op : tasmop; cond:tasmcond;l : plabel);
+      begin
+         inherited op_none(op,S_NO);
+         condition:=cond;
+         typ:=ait_labeled_instruction;
+         lab:=l;
+         lab^.is_used:=true;
+         inc(lab^.refcount);
+      end;
+
+
+    destructor tai386_labeled.done;
+      begin
+         dec(lab^.refcount);
+         if lab^.refcount=0 then
+           Begin
+             lab^.is_used := False;
+             If Not(lab^.is_set) Then
+               Dispose(lab);
+           End;
+        inherited done;
+      end;
+
+
+   function tai386_labeled.Pass1(offset:longint):longint;
+      begin
+         { Only create the Operand if it's not set yet }
+         ops:=1;
+         loadsymbol(0,nil,lab^.address);
+         Pass1:=inherited Pass1(offset);
+      end;
+
+
+   procedure tai386_labeled.Pass2;
+      begin
+         { update the address which can be changed if it was
+           a forward reference }
+         oper[0].symofs:=lab^.address;
+         inherited Pass2;
+      end;
+
+end.
+{
+  $Log$
+  Revision 1.1  1999-05-01 13:24:23  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.18  1999/04/16 11:49:51  peter
+    + tempalloc
+    + -at to show temp alloc info in .s file
+
+  Revision 1.17  1999/04/16 09:35:11  pierre
+   + tai constructors needed for SHRD and IMUL added
+
+  Revision 1.16  1999/04/01 21:58:21  peter
+    * small fixes for proces_ea
+
+  Revision 1.15  1999/03/31 13:55:32  peter
+    * assembler inlining working for ag386bin
+
+  Revision 1.14  1999/03/29 16:05:49  peter
+    * optimizer working for ag386bin
+
+  Revision 1.13  1999/03/26 00:01:11  peter
+    * first things for optimizer (compiles but cycle crashes)
+
+  Revision 1.12  1999/03/12 00:20:04  pierre
+   + win32 output working !
+
+  Revision 1.11  1999/03/10 13:41:08  pierre
+   + partial implementation for win32 !
+     winhello works but pp still does not !
+
+  Revision 1.10  1999/03/09 19:25:24  peter
+    * only pass jmp's a second time in pass1
+
+  Revision 1.9  1999/03/08 14:51:06  peter
+    + smartlinking for ag386bin
+
+  Revision 1.8  1999/03/06 17:24:19  peter
+    * rewritten intel parser a lot, especially reference reading
+    * size checking added for asm parsers
+
+  Revision 1.7  1999/03/02 02:56:19  peter
+    + stabs support for binary writers
+    * more fixes and missing updates from the previous commit :(
+
+  Revision 1.6  1999/03/01 15:46:21  peter
+    * ag386bin finally make cycles correct
+    * prefixes are now also normal opcodes
+
+  Revision 1.5  1999/02/26 00:48:28  peter
+    * assembler writers fixed for ag386bin
+
+  Revision 1.4  1999/02/25 21:03:02  peter
+    * ag386bin updates
+    + coff writer
+
+  Revision 1.3  1999/02/22 02:44:17  peter
+    * ag386bin doesn't use i386.pas anymore
+
+  Revision 1.2  1999/02/22 02:16:02  peter
+    * updates for ag386bin
+
+  Revision 1.1  1999/02/16 17:59:37  peter
+    + initial files
+
+}

+ 979 - 0
compiler/i386base.pas

@@ -0,0 +1,979 @@
+{
+    $Id$
+    Copyright (c) 1999 by Florian Klaempfl
+
+    Contains the base types for the i386
+
+    * This code was inspired by the NASM sources
+      The Netwide Assembler is copyright (C) 1996 Simon Tatham and
+      Julian Hall. All rights reserved.
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+unit i386base;
+interface
+{$ifdef TP}
+  {$L-,Y-}
+{$endif}
+
+uses
+  strings,cobjects,aasm;
+
+const
+{ Size of the instruction table converted by nasmconv.pas }
+  instabentries = 1103;
+  maxinfolen    = 7;
+
+{ By default we want everything }
+{$define ATTOP}
+{$define ATTREG}
+{$define INTELOP}
+{$define ITTABLE}
+
+{ For TP we can't use asmdebug due the table sizes }
+{$ifndef TP}
+  {$define ASMDEBUG}
+{$endif}
+
+{ We Don't need the intel style opcodes if we don't have a intel
+  reader or generator }
+{$ifndef ASMDEBUG}
+{$ifdef NORA386INT}
+  {$ifdef NOAG386NSM}
+    {$ifdef NOAG386INT}
+      {$undef INTELOP}
+    {$endif}
+  {$endif}
+{$endif}
+{$endif}
+
+{ We Don't need the AT&T style opcodes if we don't have a AT&T
+  reader or generator }
+{$ifdef NORA386ATT}
+  {$ifdef NOAG386ATT}
+    {$undef ATTOP}
+    {$ifdef NOAG386DIR}
+       {$undef ATTREG}
+    {$endif}
+  {$endif}
+{$endif}
+
+const
+{ Operand types }
+  OT_NONE      = $00000000;
+
+  OT_BITS8     = $00000001;  { size, and other attributes, of the operand  }
+  OT_BITS16    = $00000002;
+  OT_BITS32    = $00000004;
+  OT_BITS64    = $00000008;  { FPU only  }
+  OT_BITS80    = $00000010;
+  OT_FAR       = $00000020;  { this means 16:16 or 16:32, like in CALL/JMP }
+  OT_NEAR      = $00000040;
+  OT_SHORT     = $00000080;
+
+  OT_SIZE_MASK = $000000FF;  { all the size attributes  }
+  OT_NON_SIZE  = not OT_SIZE_MASK;
+
+  OT_SIGNED    = $00000100;  { the operand need to be signed -128-127 }
+
+  OT_TO        = $00000200;  { operand is followed by a colon  }
+                             { reverse effect in FADD, FSUB &c  }
+  OT_COLON     = $00000400;
+
+  OT_REGISTER  = $00001000;
+  OT_IMMEDIATE = $00002000;
+  OT_IMM8      = $00002001;
+  OT_IMM16     = $00002002;
+  OT_IMM32     = $00002004;
+  OT_IMM64     = $00002008;
+  OT_IMM80     = $00002010;
+  OT_REGMEM    = $00200000;  { for r/m, ie EA, operands  }
+  OT_REGNORM   = $00201000;  { 'normal' reg, qualifies as EA  }
+  OT_REG8      = $00201001;
+  OT_REG16     = $00201002;
+  OT_REG32     = $00201004;
+  OT_MMXREG    = $00201008;  { MMX registers  }
+  OT_MEMORY    = $00204000;  { register number in 'basereg'  }
+  OT_MEM8      = $00204001;
+  OT_MEM16     = $00204002;
+  OT_MEM32     = $00204004;
+  OT_MEM64     = $00204008;
+  OT_MEM80     = $00204010;
+  OT_FPUREG    = $01000000;  { floating point stack registers  }
+  OT_FPU0      = $01000800;  { FPU stack register zero  }
+  OT_REG_SMASK = $00070000;  { special register operands: these may be treated differently  }
+                             { a mask for the following  }
+  OT_REG_ACCUM = $00211000;  { accumulator: AL, AX or EAX  }
+  OT_REG_AL    = $00211001;    { REG_ACCUM | BITSxx  }
+  OT_REG_AX    = $00211002;    { ditto  }
+  OT_REG_EAX   = $00211004;    { and again  }
+  OT_REG_COUNT = $00221000;  { counter: CL, CX or ECX  }
+  OT_REG_CL    = $00221001;    { REG_COUNT | BITSxx  }
+  OT_REG_CX    = $00221002;    { ditto  }
+  OT_REG_ECX   = $00221004;    { another one  }
+  OT_REG_DX    = $00241002;
+
+  OT_REG_SREG  = $00081002;  { any segment register  }
+  OT_REG_CS    = $01081002;  { CS  }
+  OT_REG_DESS  = $02081002;  { DS, ES, SS (non-CS 86 registers)  }
+  OT_REG_FSGS  = $04081002;  { FS, GS (386 extended registers)  }
+
+  OT_REG_CDT   = $00101004;  { CRn, DRn and TRn  }
+  OT_REG_CREG  = $08101004;  { CRn  }
+  OT_REG_CR4   = $08101404;  { CR4 (Pentium only)  }
+  OT_REG_DREG  = $10101004;  { DRn  }
+  OT_REG_TREG  = $20101004;  { TRn  }
+
+  OT_MEM_OFFS  = $00604000;  { special type of EA  }
+                             { simple [address] offset  }
+  OT_ONENESS   = $00800000;  { special type of immediate operand  }
+                             { so UNITY == IMMEDIATE | ONENESS  }
+  OT_UNITY     = $00802000;  { for shift/rotate instructions  }
+
+{ Instruction flags }
+  IF_SM    = $0001;  { size match first operand  }
+  IF_SM2   = $0002;  { size match first two operands  }
+  IF_SB    = $0004;  { unsized operands can't be non-byte  }
+  IF_SW    = $0008;  { unsized operands can't be non-word  }
+  IF_SD    = $0010;  { unsized operands can't be nondword  }
+  IF_8086  = $0000;  { 8086 instruction  }
+  IF_186   = $0100;  { 186+ instruction  }
+  IF_286   = $0200;  { 286+ instruction  }
+  IF_386   = $0300;  { 386+ instruction  }
+  IF_486   = $0400;  { 486+ instruction  }
+  IF_PENT  = $0500;  { Pentium instruction  }
+  IF_P6    = $0600;  { P6 instruction  }
+  IF_CYRIX = $0800;  { Cyrix-specific instruction  }
+  IF_PMASK = $0F00;  { the mask for processor types  }
+  IF_PRIV  = $1000;  { it's a privileged instruction  }
+  IF_UNDOC = $2000;  { it's an undocumented instruction  }
+  IF_FPU   = $4000;  { it's an FPU instruction  }
+  IF_MMX   = $8000;  { it's an MMX instruction  }
+  { added flags }
+  IF_PRE   = $10000; { it's a prefix instruction }
+  IF_PASS2 = $20000; { if the instruction can change in a second pass }
+
+type
+  TAsmOp=(A_None,
+    { prefixes }
+    A_LOCK,A_REP,A_REPE,A_REPNE,A_REPNZ,A_REPZ,
+    A_CS,A_ES,A_DS,A_FS,A_GS,A_SS,
+    { normal }
+    A_AAA, A_AAD, A_AAM, A_AAS, A_ADC, A_ADD, A_AND, A_ARPL,
+    A_BOUND, A_BSF, A_BSR, A_BSWAP, A_BT, A_BTC, A_BTR, A_BTS,
+    A_CALL, A_CBW, A_CDQ, A_CLC, A_CLD, A_CLI, A_CLTS, A_CMC, A_CMP,
+    A_CMPSB, A_CMPSD, A_CMPSW, A_CMPXCHG, A_CMPXCHG486, A_CMPXCHG8B,
+    A_CPUID, A_CWD, A_CWDE, A_DAA, A_DAS, A_DEC, A_DIV,
+    A_EMMS, A_ENTER, A_EQU, A_F2XM1, A_FABS,
+    A_FADD, A_FADDP, A_FBLD, A_FBSTP, A_FCHS, A_FCLEX, A_FCMOVB,
+    A_FCMOVBE, A_FCMOVE, A_FCMOVNB, A_FCMOVNBE, A_FCMOVNE,
+    A_FCMOVNU, A_FCMOVU, A_FCOM, A_FCOMI, A_FCOMIP, A_FCOMP,
+    A_FCOMPP, A_FCOS, A_FDECSTP, A_FDISI, A_FDIV, A_FDIVP, A_FDIVR,
+    A_FDIVRP, A_FEMMS,
+    A_FENI, A_FFREE, A_FIADD, A_FICOM, A_FICOMP, A_FIDIV,
+    A_FIDIVR, A_FILD, A_FIMUL, A_FINCSTP, A_FINIT, A_FIST, A_FISTP,
+    A_FISUB, A_FISUBR, A_FLD, A_FLD1, A_FLDCW, A_FLDENV, A_FLDL2E,
+    A_FLDL2T, A_FLDLG2, A_FLDLN2, A_FLDPI, A_FLDZ, A_FMUL, A_FMULP,
+    A_FNCLEX, A_FNDISI, A_FNENI, A_FNINIT, A_FNOP, A_FNSAVE,
+    A_FNSTCW, A_FNSTENV, A_FNSTSW, A_FPATAN, A_FPREM, A_FPREM1,
+    A_FPTAN, A_FRNDINT, A_FRSTOR, A_FSAVE, A_FSCALE, A_FSETPM,
+    A_FSIN, A_FSINCOS, A_FSQRT, A_FST, A_FSTCW, A_FSTENV, A_FSTP,
+    A_FSTSW, A_FSUB, A_FSUBP, A_FSUBR, A_FSUBRP, A_FTST, A_FUCOM,
+    A_FUCOMI, A_FUCOMIP, A_FUCOMP, A_FUCOMPP, A_FWAIT,A_FXAM, A_FXCH,
+    A_FXTRACT, A_FYL2X, A_FYL2XP1, A_HLT, A_IBTS, A_ICEBP, A_IDIV,
+    A_IMUL, A_IN, A_INC, A_INSB, A_INSD, A_INSW, A_INT,
+    A_INT01, A_INT1, A_INT3, A_INTO, A_INVD, A_INVLPG, A_IRET,
+    A_IRETD, A_IRETW, A_JCXZ, A_JECXZ, A_JMP, A_LAHF, A_LAR, A_LDS,
+    A_LEA, A_LEAVE, A_LES, A_LFS, A_LGDT, A_LGS, A_LIDT, A_LLDT,
+    A_LMSW, A_LOADALL, A_LOADALL286, A_LODSB, A_LODSD, A_LODSW,
+    A_LOOP, A_LOOPE, A_LOOPNE, A_LOOPNZ, A_LOOPZ, A_LSL, A_LSS,
+    A_LTR, A_MOV, A_MOVD, A_MOVQ, A_MOVSB, A_MOVSD, A_MOVSW,
+    A_MOVSX, A_MOVZX, A_MUL, A_NEG, A_NOP, A_NOT, A_OR, A_OUT,
+    A_OUTSB, A_OUTSD, A_OUTSW, A_PACKSSDW, A_PACKSSWB, A_PACKUSWB,
+    A_PADDB, A_PADDD, A_PADDSB, A_PADDSIW, A_PADDSW, A_PADDUSB,
+    A_PADDUSW, A_PADDW, A_PAND, A_PANDN, A_PAVEB,
+    A_PAVGUSB, A_PCMPEQB, A_PCMPEQD, A_PCMPEQW, A_PCMPGTB, A_PCMPGTD,
+    A_PCMPGTW, A_PDISTIB,
+    A_PF2ID, A_PFACC, A_PFADD, A_PFCMPEQ, A_PFCMPGE, A_PFCMPGT,
+    A_PFMAX, A_PFMIN, A_PFMUL, A_PFRCP, A_PFRCPIT1, A_PFRCPIT2,
+    A_PFRSQIT1, A_PFRSQRT, A_PFSUB, A_PFSUBR, A_PI2FD,
+    A_PMACHRIW, A_PMADDWD, A_PMAGW,  A_PMULHRIW, A_PMULHRWA,
+    A_PMULHRWC, A_PMULHW, A_PMULLW, A_PMVGEZB, A_PMVLZB, A_PMVNZB,
+    A_PMVZB, A_POP, A_POPA, A_POPAD, A_POPAW, A_POPF, A_POPFD,
+    A_POPFW, A_POR, A_PREFETCH, A_PREFETCHW,
+    A_PSLLD, A_PSLLQ, A_PSLLW, A_PSRAD, A_PSRAW,
+    A_PSRLD, A_PSRLQ, A_PSRLW, A_PSUBB, A_PSUBD, A_PSUBSB,
+    A_PSUBSIW, A_PSUBSW, A_PSUBUSB, A_PSUBUSW, A_PSUBW, A_PUNPCKHBW,
+    A_PUNPCKHDQ, A_PUNPCKHWD, A_PUNPCKLBW, A_PUNPCKLDQ, A_PUNPCKLWD,
+    A_PUSH, A_PUSHA, A_PUSHAD, A_PUSHAW, A_PUSHF, A_PUSHFD,
+    A_PUSHFW, A_PXOR, A_RCL, A_RCR, A_RDMSR, A_RDPMC, A_RDTSC,
+    A_RESB, A_RET, A_RETF, A_RETN,
+    A_ROL, A_ROR, A_RSM, A_SAHF, A_SAL, A_SALC, A_SAR, A_SBB,
+    A_SCASB, A_SCASD, A_SCASW, A_SGDT, A_SHL, A_SHLD, A_SHR, A_SHRD,
+    A_SIDT, A_SLDT, A_SMI, A_SMSW, A_STC, A_STD, A_STI, A_STOSB,
+    A_STOSD, A_STOSW, A_STR, A_SUB, A_TEST, A_UMOV, A_VERR, A_VERW,
+    A_WAIT, A_WBINVD, A_WRMSR, A_XADD, A_XBTS, A_XCHG, A_XLAT, A_XLATB,
+    A_XOR, A_CMOVcc, A_Jcc, A_SETcc
+  );
+
+  op2strtable=array[tasmop] of string[10];
+
+const
+  firstop = low(tasmop);
+  lastop  = high(tasmop);
+
+  AsmPrefixes = 6;
+  AsmPrefix : array[0..AsmPrefixes-1] of TasmOP =(
+    A_LOCK,A_REP,A_REPE,A_REPNE,A_REPNZ,A_REPZ
+  );
+
+  AsmOverrides = 6;
+  AsmOverride : array[0..AsmOverrides-1] of TasmOP =(
+    A_CS,A_ES,A_DS,A_FS,A_GS,A_SS
+  );
+
+
+{$ifdef INTELOP}
+  int_op2str:op2strtable=('<none>',
+    { prefixes }
+    'lock','rep','repe','repne','repnz','repz',
+    'segcs','seges','segds','segfs','seggs','segss',
+    { normal }
+    'aaa', 'aad', 'aam', 'aas', 'adc', 'add', 'and', 'arpl',
+    'bound', 'bsf', 'bsr', 'bswap', 'bt', 'btc', 'btr', 'bts',
+    'call', 'cbw', 'cdq', 'clc', 'cld', 'cli', 'clts', 'cmc', 'cmp',
+    'cmpsb', 'cmpsd', 'cmpsw', 'cmpxchg', 'cmpxchg486', 'cmpxchg8b',
+    'cpuid', 'cwd', 'cwde', 'daa', 'das', 'dec', 'div', 'emms',
+    'enter', 'equ', 'f2xm1', 'fabs',
+    'fadd', 'faddp', 'fbld', 'fbstp', 'fchs', 'fclex', 'fcmovb',
+    'fcmovbe', 'fcmove', 'fcmovnb', 'fcmovnbe', 'fcmovne',
+    'fcmovnu', 'fcmovu', 'fcom', 'fcomi', 'fcomip', 'fcomp',
+    'fcompp', 'fcos', 'fdecstp', 'fdisi', 'fdiv', 'fdivp', 'fdivr',
+    'fdivrp',
+    'femms',
+    'feni', 'ffree', 'fiadd', 'ficom', 'ficomp', 'fidiv',
+    'fidivr', 'fild', 'fimul', 'fincstp', 'finit', 'fist', 'fistp',
+    'fisub', 'fisubr', 'fld', 'fld1', 'fldcw', 'fldenv', 'fldl2e',
+    'fldl2t', 'fldlg2', 'fldln2', 'fldpi', 'fldz', 'fmul', 'fmulp',
+    'fnclex', 'fndisi', 'fneni', 'fninit', 'fnop', 'fnsave',
+    'fnstcw', 'fnstenv', 'fnstsw', 'fpatan', 'fprem', 'fprem1',
+    'fptan', 'frndint', 'frstor', 'fsave', 'fscale', 'fsetpm',
+    'fsin', 'fsincos', 'fsqrt', 'fst', 'fstcw', 'fstenv', 'fstp',
+    'fstsw', 'fsub', 'fsubp', 'fsubr', 'fsubrp', 'ftst', 'fucom',
+    'fucomi', 'fucomip', 'fucomp', 'fucompp', 'fwait', 'fxam', 'fxch',
+    'fxtract', 'fyl2x', 'fyl2xp1', 'hlt', 'ibts', 'icebp', 'idiv',
+    'imul', 'in', 'inc', 'insb', 'insd', 'insw', 'int',
+    'int01', 'int1', 'int3', 'into', 'invd', 'invlpg', 'iret',
+    'iretd', 'iretw', 'jcxz', 'jecxz', 'jmp', 'lahf', 'lar', 'lds',
+    'lea', 'leave', 'les', 'lfs', 'lgdt', 'lgs', 'lidt', 'lldt',
+    'lmsw', 'loadall', 'loadall286', 'lodsb', 'lodsd', 'lodsw',
+    'loop', 'loope', 'loopne', 'loopnz', 'loopz', 'lsl', 'lss',
+    'ltr', 'mov', 'movd', 'movq', 'movsb', 'movsd', 'movsw',
+    'movsx', 'movzx', 'mul', 'neg', 'nop', 'not', 'or', 'out',
+    'outsb', 'outsd', 'outsw', 'packssdw', 'packsswb', 'packuswb',
+    'paddb', 'paddd', 'paddsb', 'paddsiw', 'paddsw', 'paddusb',
+    'paddusw', 'paddw', 'pand', 'pandn', 'paveb',
+    'pavgusb', 'pcmpeqb',
+    'pcmpeqd', 'pcmpeqw', 'pcmpgtb', 'pcmpgtd', 'pcmpgtw',
+    'pdistib',
+    'pf2id', 'pfacc', 'pfadd', 'pfcmpeq', 'pfcmpge', 'pfcmpgt',
+    'pfmax', 'pfmin', 'pfmul', 'pfrcp', 'pfrcpit1', 'pfrcpit2',
+    'pfrsqit1', 'pfrsqrt', 'pfsub', 'pfsubr', 'pi2fd',
+    'pmachriw', 'pmaddwd', 'pmagw', 'pmulhriw', 'pmulhrwa', 'pmulhrwc',
+    'pmulhw', 'pmullw', 'pmvgezb', 'pmvlzb', 'pmvnzb',
+    'pmvzb', 'pop', 'popa', 'popad', 'popaw', 'popf', 'popfd',
+    'popfw', 'por',
+    'prefetch', 'prefetchw', 'pslld', 'psllq', 'psllw', 'psrad', 'psraw',
+    'psrld', 'psrlq', 'psrlw', 'psubb', 'psubd', 'psubsb',
+    'psubsiw', 'psubsw', 'psubusb', 'psubusw', 'psubw', 'punpckhbw',
+    'punpckhdq', 'punpckhwd', 'punpcklbw', 'punpckldq', 'punpcklwd',
+    'push', 'pusha', 'pushad', 'pushaw', 'pushf', 'pushfd',
+    'pushfw', 'pxor', 'rcl', 'rcr', 'rdmsr', 'rdpmc', 'rdtsc',
+    'resb', 'ret', 'retf', 'retn',
+    'rol', 'ror', 'rsm', 'sahf', 'sal', 'salc', 'sar', 'sbb',
+    'scasb', 'scasd', 'scasw', 'sgdt', 'shl', 'shld', 'shr', 'shrd',
+    'sidt', 'sldt', 'smi', 'smsw', 'stc', 'std', 'sti', 'stosb',
+    'stosd', 'stosw', 'str', 'sub', 'test', 'umov', 'verr', 'verw',
+    'wait', 'wbinvd', 'wrmsr', 'xadd', 'xbts', 'xchg', 'xlat', 'xlatb',
+    'xor','cmov','j','set'
+  );
+{$endif INTELOP}
+
+{$ifdef ATTOP}
+  att_op2str:op2strtable=('<none>',
+    { prefixes }
+    'lock','rep','repe','repne','repnz','repz',
+    'cs','es','ds','fs','gs','ss',
+    { normal }
+    'aaa', 'aad', 'aam', 'aas', 'adc', 'add', 'and', 'arpl',
+    'bound', 'bsf', 'bsr', 'bswap', 'bt', 'btc', 'btr', 'bts',
+    'call', 'cbtw', 'cltd', 'clc', 'cld', 'cli', 'clts', 'cmc', 'cmp',
+    'cmpsb', 'cmpsl', 'cmpsw', 'cmpxchg', 'cmpxchg486', 'cmpxchg8b',
+    'cpuid', 'cwtd', 'cwtl', 'daa', 'das', 'dec', 'div',
+    'emms', 'enter', 'equ', 'f2xm1', 'fabs',
+    'fadd', 'faddp', 'fbld', 'fbstp', 'fchs', 'fclex', 'fcmovb',
+    'fcmovbe', 'fcmove', 'fcmovnb', 'fcmovnbe', 'fcmovne',
+    'fcmovnu', 'fcmovu', 'fcom', 'fcomi', 'fcomip', 'fcomp',
+    'fcompp', 'fcos', 'fdecstp', 'fdisi', 'fdiv', 'fdivp', 'fdivr',
+    'fdivrp', 'femms',
+    'feni', 'ffree', 'fiadd', 'ficom', 'ficomp', 'fidiv',
+    'fidivr', 'fild', 'fimul', 'fincstp', 'finit', 'fist', 'fistp',
+    'fisub', 'fisubr', 'fld', 'fld1', 'fldcw', 'fldenv', 'fldl2e',
+    'fldl2t', 'fldlg2', 'fldln2', 'fldpi', 'fldz', 'fmul', 'fmulp',
+    'fnclex', 'fndisi', 'fneni', 'fninit', 'fnop', 'fnsave',
+    'fnstcw', 'fnstenv', 'fnstsw', 'fpatan', 'fprem', 'fprem1',
+    'fptan', 'frndint', 'frstor', 'fsave', 'fscale', 'fsetpm',
+    'fsin', 'fsincos', 'fsqrt', 'fst', 'fstcw', 'fstenv', 'fstp',
+    'fstsw', 'fsub', 'fsubp', 'fsubr', 'fsubrp', 'ftst', 'fucom',
+    'fucomi', 'fucomip', 'fucomp', 'fucompp', 'fwait', 'fxam', 'fxch',
+    'fxtract', 'fyl2x', 'fyl2xp1', 'hlt', 'ibts', 'icebp', 'idiv',
+    'imul', 'in', 'inc', 'insb', 'insl', 'insw', 'int',
+    'int01', 'int1', 'int3', 'into', 'invd', 'invlpg', 'iret',
+    'iretd', 'iretw', 'jcxz', 'jecxz', 'jmp', 'lahf', 'lar', 'lds',
+    'lea', 'leave', 'les', 'lfs', 'lgdt', 'lgs', 'lidt', 'lldt',
+    'lmsw', 'loadall', 'loadall286', 'lodsb', 'lodsl', 'lodsw',
+    'loop', 'loope', 'loopne', 'loopnz', 'loopz', 'lsl', 'lss',
+    'ltr', 'mov', 'movd', 'movq', 'movsb', 'movsl', 'movsw',
+    'movs', 'movz', 'mul', 'neg', 'nop', 'not', 'or', 'out',
+    'outsb', 'outsl', 'outsw', 'packssd', 'packssw', 'packusw',
+    'paddb', 'paddd', 'paddsb', 'paddsiw', 'paddsw', 'paddusb',
+    'paddusw', 'paddw', 'pand', 'pandn', 'paveb',
+    'pavgusb', 'pcmpeqb',
+    'pcmpeqd', 'pcmpeqw', 'pcmpgtb', 'pcmpgtd', 'pcmpgtw',
+    'pdistib',
+    'pf2id', 'pfacc', 'pfadd', 'pfcmpeq', 'pfcmpge', 'pfcmpgt',
+    'pfmax', 'pfmin', 'pfmul', 'pfrcp', 'pfrcpit1', 'pfrcpit2',
+    'pfrsqit1', 'pfrsqrt', 'pfsub', 'pfsubr', 'pi2fd',
+    'pmachriw', 'pmaddwd', 'pmagw', 'pmulhriw', 'pmulhrwa', 'pmulhrwc',
+    'pmulhw', 'pmullw', 'pmvgezb', 'pmvlzb', 'pmvnzb',
+    'pmvzb', 'pop', 'popa', 'popal', 'popaw', 'popf', 'popfl',
+    'popfw', 'por',
+    'prefetch', 'prefetchw', 'pslld', 'psllq', 'psllw', 'psrad', 'psraw',
+    'psrld', 'psrlq', 'psrlw', 'psubb', 'psubd', 'psubsb',
+    'psubsiw', 'psubsw', 'psubusb', 'psubusw', 'psubw', 'punpckhbw',
+    'punpckhdq', 'punpckhwd', 'punpcklbw', 'punpckldq', 'punpcklwd',
+    'push', 'pusha', 'pushal', 'pushaw', 'pushf', 'pushfl',
+    'pushfw', 'pxor', 'rcl', 'rcr', 'rdmsr', 'rdpmc', 'rdtsc',
+    'resb', 'ret', 'retf', 'retn',
+    'rol', 'ror', 'rsm', 'sahf', 'sal', 'salc', 'sar', 'sbb',
+    'scasb', 'scasl', 'scasw', 'sgdt', 'shl', 'shld', 'shr', 'shrd',
+    'sidt', 'sldt', 'smi', 'smsw', 'stc', 'std', 'sti', 'stosb',
+    'stosl', 'stosw', 'str', 'sub', 'test', 'umov', 'verr', 'verw',
+    'wait', 'wbinvd', 'wrmsr', 'xadd', 'xbts', 'xchg', 'xlat', 'xlatb',
+    'xor','cmov','j','set'
+  );
+{$endif ATTOP}
+
+
+{*****************************************************************************
+                                Operand Sizes
+*****************************************************************************}
+
+type
+  topsize = (S_NO,
+    S_B,S_W,S_L,S_BW,S_BL,S_WL,
+    S_IS,S_IL,S_IQ,
+    S_FS,S_FL,S_FX,S_D,S_Q,S_FV
+  );
+
+const
+  { Intel style operands ! }
+  opsize_2_type:array[0..2,topsize] of longint=(
+    (OT_NONE,
+     OT_BITS8,OT_BITS16,OT_BITS32,OT_BITS16,OT_BITS32,OT_BITS32,
+     OT_BITS16,OT_BITS32,OT_BITS64,
+     OT_BITS32,OT_BITS64,OT_BITS80,OT_BITS64,OT_BITS64,OT_BITS64
+    ),
+    (OT_NONE,
+     OT_BITS8,OT_BITS16,OT_BITS32,OT_BITS8,OT_BITS8,OT_BITS16,
+     OT_BITS16,OT_BITS32,OT_BITS64,
+     OT_BITS32,OT_BITS64,OT_BITS80,OT_BITS64,OT_BITS64,OT_BITS64
+    ),
+    (OT_NONE,
+     OT_BITS8,OT_BITS16,OT_BITS32,OT_NONE,OT_NONE,OT_NONE,
+     OT_BITS16,OT_BITS32,OT_BITS64,
+     OT_BITS32,OT_BITS64,OT_BITS80,OT_BITS64,OT_BITS64,OT_BITS64
+    )
+  );
+
+{$ifdef ATTOP}
+  att_opsize2str : array[topsize] of string[2] = ('',
+    'b','w','l','bw','bl','wl',
+    's','l','q',
+    's','l','t','d','q','v'
+  );
+{$endif}
+
+
+{*****************************************************************************
+                                Conditions
+*****************************************************************************}
+
+type
+  TAsmCond=(C_None,
+    C_A,C_AE,C_B,C_BE,C_C,C_E,C_G,C_GE,C_L,C_LE,C_NA,C_NAE,
+    C_NB,C_NBE,C_NC,C_NE,C_NG,C_NGE,C_NL,C_NLE,C_NO,C_NP,
+    C_NS,C_NZ,C_O,C_P,C_PE,C_PO,C_S,C_Z
+  );
+
+const
+  cond2str:array[TAsmCond] of string[3]=('',
+    'a', 'ae', 'b', 'be', 'c', 'e', 'g', 'ge', 'l', 'le', 'na', 'nae',
+    'nb', 'nbe', 'nc', 'ne', 'ng', 'nge', 'nl', 'nle', 'no', 'np',
+    'ns', 'nz', 'o', 'p', 'pe', 'po', 's', 'z'
+  );
+  inverse_cond:array[TAsmCond] of TAsmCond=(C_None,
+    C_NA,C_NAE,C_NB,C_NBE,C_NC,C_NE,C_NG,C_NGE,C_NL,C_NLE,C_A,C_AE,
+    C_B,C_BE,C_C,C_E,C_G,C_GE,C_L,C_LE,C_O,C_P,
+    C_S,C_Z,C_NO,C_NP,C_NP,C_P,C_NS,C_NZ
+  );
+
+const
+  CondAsmOps=3;
+  CondAsmOp:array[0..CondAsmOps-1] of TasmOp=(
+    A_CMOVcc, A_Jcc, A_SETcc
+  );
+  CondAsmOpStr:array[0..CondAsmOps-1] of string[4]=(
+    'CMOV','J','SET'
+  );
+
+
+{*****************************************************************************
+                                  Registers
+*****************************************************************************}
+
+type
+  { enumeration for registers, don't change the order }
+  { it's used by the register size conversions        }
+  tregister = (R_NO,
+    R_EAX,R_ECX,R_EDX,R_EBX,R_ESP,R_EBP,R_ESI,R_EDI,
+    R_AX,R_CX,R_DX,R_BX,R_SP,R_BP,R_SI,R_DI,
+    R_AL,R_CL,R_DL,R_BL,R_AH,R_CH,R_BH,R_DH,
+    { for an easier assembler generation }
+    R_DEFAULT_SEG,R_CS,R_DS,R_ES,R_SS,R_FS,R_GS,
+    R_ST,R_ST0,R_ST1,R_ST2,R_ST3,R_ST4,R_ST5,R_ST6,R_ST7,
+    R_DR0,R_DR1,R_DR2,R_DR3,R_DR6,R_DR7,
+    R_CR0,R_CR2,R_CR3,R_CR4,
+    R_TR3,R_TR4,R_TR5,R_TR6,R_TR7,
+    R_MM0,R_MM1,R_MM2,R_MM3,R_MM4,R_MM5,R_MM6,R_MM7,
+    R_XMM0,R_XMM1,R_XMM2,R_XMM3,R_XMM4,R_XMM5,R_XMM6,R_XMM7
+  );
+
+  tregisterset = set of tregister;
+
+  reg2strtable = array[tregister] of string[6];
+
+const
+  firstreg = low(tregister);
+  lastreg  = high(tregister);
+
+  firstsreg = R_CS;
+  lastsreg = R_GS;
+
+  regset8bit  : tregisterset = [R_AL..R_DH];
+  regset16bit : tregisterset = [R_AX..R_DI,R_CS..R_SS];
+  regset32bit : tregisterset = [R_EAX..R_EDI];
+
+  { Convert reg to opsize }
+  reg_2_opsize:array[firstreg..lastreg] of topsize = (S_NO,
+    S_L,S_L,S_L,S_L,S_L,S_L,S_L,S_L,
+    S_W,S_W,S_W,S_W,S_W,S_W,S_W,S_W,
+    S_B,S_B,S_B,S_B,S_B,S_B,S_B,S_B,
+    S_NO,S_W,S_W,S_W,S_W,S_W,S_W,
+    S_FL,S_FL,S_FL,S_FL,S_FL,S_FL,S_FL,S_FL,S_FL,
+    S_L,S_L,S_L,S_L,S_L,S_L,
+    S_L,S_L,S_L,S_L,
+    S_L,S_L,S_L,S_L,S_L,
+    S_D,S_D,S_D,S_D,S_D,S_D,S_D,S_D,
+    S_D,S_D,S_D,S_D,S_D,S_D,S_D,S_D
+  );
+
+  { Convert reg to operand type }
+  reg_2_type:array[firstreg..lastreg] of longint = (OT_NONE,
+    OT_REG_EAX,OT_REG_ECX,OT_REG32,OT_REG32,OT_REG32,OT_REG32,OT_REG32,OT_REG32,
+    OT_REG_AX,OT_REG_CX,OT_REG_DX,OT_REG16,OT_REG16,OT_REG16,OT_REG16,OT_REG16,
+    OT_REG_AL,OT_REG_CL,OT_REG8,OT_REG8,OT_REG8,OT_REG8,OT_REG8,OT_REG8,
+    OT_NONE,OT_REG_CS,OT_REG_DESS,OT_REG_DESS,OT_REG_DESS,OT_REG_FSGS,OT_REG_FSGS,
+    OT_FPU0,OT_FPU0,OT_FPUREG,OT_FPUREG,OT_FPUREG,OT_FPUREG,OT_FPUREG,OT_FPUREG,OT_FPUREG,
+    OT_REG_DREG,OT_REG_DREG,OT_REG_DREG,OT_REG_DREG,OT_REG_DREG,OT_REG_DREG,
+    OT_REG_CREG,OT_REG_CREG,OT_REG_CREG,OT_REG_CR4,
+    OT_REG_TREG,OT_REG_TREG,OT_REG_TREG,OT_REG_TREG,OT_REG_TREG,
+    OT_MMXREG,OT_MMXREG,OT_MMXREG,OT_MMXREG,OT_MMXREG,OT_MMXREG,OT_MMXREG,OT_MMXREG,
+    OT_MMXREG,OT_MMXREG,OT_MMXREG,OT_MMXREG,OT_MMXREG,OT_MMXREG,OT_MMXREG,OT_MMXREG
+  );
+
+{$ifdef INTELOP}
+  int_reg2str : reg2strtable = ('',
+    'eax','ecx','edx','ebx','esp','ebp','esi','edi',
+    'ax','cx','dx','bx','sp','bp','si','di',
+    'al','cl','dl','bl','ah','ch','bh','dh',
+    '','cs','ds','es','ss','fs','gs',
+    'st','st(0)','st(1)','st(2)','st(3)','st(4)','st(5)','st(6)','st(7)',
+    'dr0','dr1','dr2','dr3','dr6','dr7',
+    'cr0','cr2','cr3','cr4',
+    'tr3','tr4','tr5','tr6','tr7',
+    'mm0','mm1','mm2','mm3','mm4','mm5','mm6','mm7',
+    'xmm0','xmm1','xmm2','xmm3','xmm4','xmm5','xmm6','xmm7'
+  );
+
+  int_nasmreg2str : reg2strtable = ('',
+    'eax','ecx','edx','ebx','esp','ebp','esi','edi',
+    'ax','cx','dx','bx','sp','bp','si','di',
+    'al','cl','dl','bl','ah','ch','bh','dh',
+    '','cs','ds','es','ss','fs','gs',
+    'st0','st0','st1','st2','st3','st4','st5','st6','st7',
+    'dr0','dr1','dr2','dr3','dr6','dr7',
+    'cr0','cr2','cr3','cr4',
+    'tr3','tr4','tr5','tr6','tr7',
+    'mm0','mm1','mm2','mm3','mm4','mm5','mm6','mm7',
+    'xmm0','xmm1','xmm2','xmm3','xmm4','xmm5','xmm6','xmm7'
+  );
+{$endif}
+
+{$ifdef ATTREG}
+  att_reg2str : reg2strtable = ('',
+    '%eax','%ecx','%edx','%ebx','%esp','%ebp','%esi','%edi',
+    '%ax','%cx','%dx','%bx','%sp','%bp','%si','%di',
+    '%al','%cl','%dl','%bl','%ah','%ch','%bh','%dh',
+    '','%cs','%ds','%es','%ss','%fs','%gs',
+    '%st','%st(0)','%st(1)','%st(2)','%st(3)','%st(4)','%st(5)','%st(6)','%st(7)',
+    '%dr0','%dr1','%dr2','%dr3','%dr6','%dr7',
+    '%cr0','%cr2','%cr3','%cr4',
+    '%tr3','%tr4','%tr5','%tr6','%tr7',
+    '%mm0','%mm1','%mm2','%mm3','%mm4','%mm5','%mm6','%mm7',
+    '%xmm0','%xmm1','%xmm2','%xmm3','%xmm4','%xmm5','%xmm6','%xmm7'
+  );
+{$endif ATTREG}
+
+
+{*****************************************************************************
+                                   Flags
+*****************************************************************************}
+
+type
+  TResFlags = (F_E,F_NE,F_G,F_L,F_GE,F_LE,F_C,F_NC,F_A,F_AE,F_B,F_BE);
+
+const
+  { arrays for boolean location conversions }
+  flag_2_cond : array[TResFlags] of TAsmCond =
+     (C_E,C_NE,C_G,C_L,C_GE,C_LE,C_C,C_NC,C_A,C_AE,C_B,C_BE);
+
+
+{*****************************************************************************
+                                Reference
+*****************************************************************************}
+
+type
+  trefoptions=(ref_none,ref_parafixup,ref_localfixup);
+
+  { immediate/reference record }
+  preference = ^treference;
+  treference = record
+     is_immediate : boolean; { is this used as reference or immediate }
+     segment,
+     base,
+     index       : tregister;
+     scalefactor : byte;
+     offset      : longint;
+     symbol      : pasmsymbol;
+     offsetfixup : longint;
+     options     : trefoptions;
+  end;
+
+
+{*****************************************************************************
+                               Generic Location
+*****************************************************************************}
+
+type
+  TLoc=(
+    LOC_INVALID,     { added for tracking problems}
+    LOC_FPU,         { FPU stack }
+    LOC_REGISTER,    { in a processor register }
+    LOC_MEM,         { in memory }
+    LOC_REFERENCE,   { like LOC_MEM, but lvalue }
+    LOC_JUMP,        { boolean results only, jump to false or true label }
+    LOC_FLAGS,       { boolean results only, flags are set }
+    LOC_CREGISTER,   { Constant register which shouldn't be modified }
+    LOC_MMXREGISTER, { MMX register }
+    LOC_CMMXREGISTER { Constant MMX register }
+  );
+
+  plocation = ^tlocation;
+  tlocation = packed record
+     case loc : tloc of
+        LOC_MEM,LOC_REFERENCE : (reference : treference);
+        LOC_FPU : ();
+        LOC_JUMP : ();
+        LOC_FLAGS : (resflags : tresflags);
+        LOC_INVALID : ();
+
+        { it's only for better handling }
+        LOC_MMXREGISTER : (mmxreg : tregister);
+        { segment in reference at the same place as in loc_register }
+        LOC_REGISTER,LOC_CREGISTER : (
+        case longint of
+          1 : (register,segment,registerhigh : tregister);
+          { overlay a registerlow }
+          2 : (registerlow : tregister);
+        );
+  end;
+
+
+{*****************************************************************************
+                                 Constants
+*****************************************************************************}
+
+type
+  tcpuflags = (cf_registers64);
+
+const
+  general_registers = [R_EAX,R_EBX,R_ECX,R_EDX];
+
+  registers_saved_on_cdecl = [R_ESI,R_EDI,R_EBX];
+
+  { generic register names }
+  stack_pointer = R_ESP;
+  frame_pointer = R_EBP;
+  self_pointer  = R_ESI;
+  accumulator   = R_EAX;
+
+  cpuflags : set of tcpuflags = [];
+
+  { sizes }
+  pointersize   = 4;
+  extended_size = 10;
+  sizepostfix_pointer = S_L;
+
+
+{*****************************************************************************
+                              Instruction table
+*****************************************************************************}
+
+type
+  tinsentry=packed record
+    opcode  : tasmop;
+    ops     : byte;
+    optypes : array[0..2] of longint;
+    code    : array[0..maxinfolen] of char;
+    flags   : longint;
+  end;
+  pinsentry=^tinsentry;
+
+  TInsTabCache=array[TasmOp] of longint;
+  PInsTabCache=^TInsTabCache;
+
+const
+  InsTab:array[0..instabentries-1] of TInsEntry=
+{$i i386tab.inc}
+
+var
+  InsTabCache : PInsTabCache;
+
+
+{*****************************************************************************
+                                  Helpers
+*****************************************************************************}
+
+    const
+       maxvarregs = 4;
+       varregs : array[1..maxvarregs] of tregister =
+         (R_EBX,R_EDX,R_ECX,R_EAX);
+
+    function imm_2_type(l:longint):longint;
+
+    { the following functions allow to convert registers }
+    { for example reg8toreg32(R_AL) returns R_EAX        }
+    { for example reg16toreg32(R_AL) gives an undefined  }
+    { result                                             }
+    { these functions expects that the turn of           }
+    { tregister isn't changed                            }
+    function reg8toreg16(reg : tregister) : tregister;
+    function reg8toreg32(reg : tregister) : tregister;
+    function reg16toreg8(reg : tregister) : tregister;
+    function reg32toreg8(reg : tregister) : tregister;
+    function reg32toreg16(reg : tregister) : tregister;
+    function reg16toreg32(reg : tregister) : tregister;
+
+    { these procedures must be defined by all target cpus }
+    function regtoreg8(reg : tregister) : tregister;
+    function regtoreg16(reg : tregister) : tregister;
+    function regtoreg32(reg : tregister) : tregister;
+
+    { can be ignored on 32 bit systems }
+    function regtoreg64(reg : tregister) : tregister;
+
+    { returns the operand prefix for a given register }
+    function regsize(reg : tregister) : topsize;
+
+    { resets all values of ref to defaults }
+    procedure reset_reference(var ref : treference);
+    { set mostly used values of a new reference }
+    function new_reference(base : tregister;offset : longint) : preference;
+    { same as reset_reference, but symbol is disposed }
+    { use this only for already used references       }
+    procedure clear_reference(var ref : treference);
+
+    function newreference(const r : treference) : preference;
+    procedure disposereference(var r : preference);
+
+    function reg2str(r : tregister) : string;
+
+
+implementation
+
+{*****************************************************************************
+                                  Helpers
+*****************************************************************************}
+
+    function imm_2_type(l:longint):longint;
+      begin
+        if (l>=-128) and (l<=127) then
+         imm_2_type:=OT_IMM8 or OT_SIGNED
+        else
+         if (l>=-255) and (l<=255) then
+          imm_2_type:=OT_IMM8
+        else
+         if (l>=-32768) and (l<=32767) then
+          imm_2_type:=OT_IMM16 or OT_SIGNED
+        else
+         if (l>=-65536) and (l<=65535) then
+          imm_2_type:=OT_IMM16 or OT_SIGNED
+         else
+          imm_2_type:=OT_IMM32;
+      end;
+
+    function reg2str(r : tregister) : string;
+      const
+         a : array[R_NO..R_BL] of string[3] =
+          ('','EAX','ECX','EDX','EBX','ESP','EBP','ESI','EDI',
+           'AX','CX','DX','BX','SP','BP','SI','DI',
+           'AL','CL','DL','BL');
+      begin
+         reg2str:=a[r];
+      end;
+
+
+    procedure disposereference(var r : preference);
+      begin
+         dispose(r);
+         r:=nil;
+      end;
+
+
+    function newreference(const r : treference) : preference;
+      var
+         p : preference;
+      begin
+         new(p);
+         p^:=r;
+         newreference:=p;
+      end;
+
+
+    function reg8toreg16(reg : tregister) : tregister;
+
+      begin
+         reg8toreg16:=reg32toreg16(reg8toreg32(reg));
+      end;
+
+    function reg16toreg8(reg : tregister) : tregister;
+
+      begin
+         reg16toreg8:=reg32toreg8(reg16toreg32(reg));
+      end;
+
+    function reg16toreg32(reg : tregister) : tregister;
+
+      begin
+         reg16toreg32:=tregister(byte(reg)-byte(R_EDI));
+      end;
+
+    function reg32toreg16(reg : tregister) : tregister;
+
+      begin
+         reg32toreg16:=tregister(byte(reg)+byte(R_EDI));
+      end;
+
+    function reg32toreg8(reg : tregister) : tregister;
+
+      begin
+         reg32toreg8:=tregister(byte(reg)+byte(R_DI));
+      end;
+
+    function reg8toreg32(reg : tregister) : tregister;
+
+      begin
+         reg8toreg32:=tregister(byte(reg)-byte(R_DI));
+      end;
+
+    function regtoreg8(reg : tregister) : tregister;
+
+     begin
+        regtoreg8:=reg32toreg8(reg);
+     end;
+
+    function regtoreg16(reg : tregister) : tregister;
+
+     begin
+        regtoreg16:=reg32toreg16(reg);
+     end;
+
+    function regtoreg32(reg : tregister) : tregister;
+
+     begin
+        regtoreg32:=reg;
+     end;
+
+    function regtoreg64(reg : tregister) : tregister;
+
+     begin
+        { to avoid warning }
+        regtoreg64:=R_NO;
+     end;
+
+function regsize(reg : tregister) : topsize;
+begin
+   if reg in regset8bit then
+     regsize:=S_B
+   else if reg in regset16bit then
+     regsize:=S_W
+   else if reg in regset32bit then
+     regsize:=S_L;
+end;
+
+
+procedure reset_reference(var ref : treference);
+begin
+  with ref do
+   begin
+     is_immediate:=false;
+     segment:=R_DEFAULT_SEG;
+     base:=R_NO;
+     index:=R_NO;
+     scalefactor:=0;
+     offset:=0;
+     symbol:=nil;
+     offsetfixup:=0;
+     options:=ref_none;
+   end;
+end;
+
+
+function new_reference(base : tregister;offset : longint) : preference;
+var
+  r : preference;
+begin
+  new(r);
+  reset_reference(r^);
+  r^.base:=base;
+  r^.offset:=offset;
+  new_reference:=r;
+end;
+
+
+procedure clear_reference(var ref : treference);
+begin
+  reset_reference(ref);
+end;
+
+
+{*****************************************************************************
+                              Instruction table
+*****************************************************************************}
+
+var
+  saveexit : pointer;
+
+procedure FreeInsTabCache;{$ifndef FPC}far;{$endif}
+begin
+  exitproc:=saveexit;
+  dispose(instabcache);
+end;
+
+
+procedure BuildInsTabCache;
+var
+  i : longint;
+begin
+  new(instabcache);
+  FillChar(instabcache^,sizeof(tinstabcache),$ff);
+  i:=0;
+  while (i<InsTabEntries) do
+   begin
+     if InsTabCache^[InsTab[i].OPcode]=-1 then
+      InsTabCache^[InsTab[i].OPcode]:=i;
+     inc(i);
+   end;
+  saveexit:=exitproc;
+  exitproc:=@FreeInsTabCache;
+end;
+
+
+begin
+  BuildInsTabCache;
+end.
+{
+  $Log$
+  Revision 1.1  1999-05-01 13:24:23  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.13  1999/04/14 09:07:43  peter
+    * asm reader improvements
+
+  Revision 1.12  1999/04/10 16:14:09  peter
+    * fixed optimizer
+
+  Revision 1.11  1999/03/31 13:55:33  peter
+    * assembler inlining working for ag386bin
+
+  Revision 1.10  1999/03/29 16:05:50  peter
+    * optimizer working for ag386bin
+
+  Revision 1.9  1999/03/26 00:01:14  peter
+    * first things for optimizer (compiles but cycle crashes)
+
+  Revision 1.8  1999/03/06 17:24:21  peter
+    * rewritten intel parser a lot, especially reference reading
+    * size checking added for asm parsers
+
+  Revision 1.7  1999/03/02 02:56:20  peter
+    + stabs support for binary writers
+    * more fixes and missing updates from the previous commit :(
+
+  Revision 1.6  1999/03/01 15:46:22  peter
+    * ag386bin finally make cycles correct
+    * prefixes are now also normal opcodes
+
+  Revision 1.5  1999/02/26 00:48:29  peter
+    * assembler writers fixed for ag386bin
+
+  Revision 1.4  1999/02/25 21:03:04  peter
+    * ag386bin updates
+    + coff writer
+
+  Revision 1.3  1999/02/22 02:44:18  peter
+    * ag386bin doesn't use i386.pas anymore
+
+  Revision 1.2  1999/02/22 02:16:03  peter
+    * updates for ag386bin
+
+  Revision 1.1  1999/02/16 17:59:38  peter
+    + initial files
+
+}

+ 7723 - 0
compiler/i386tab.inc

@@ -0,0 +1,7723 @@
+(
+  (
+    opcode  : A_AAA;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#55;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_AAD;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#213#10;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_AAD;
+    ops     : 1;
+    optypes : (ot_immediate,ot_none,ot_none);
+    code    : #1#213#20;
+    flags   : if_8086 or if_SB
+  ),
+  (
+    opcode  : A_AAM;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#212#10;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_AAM;
+    ops     : 1;
+    optypes : (ot_immediate,ot_none,ot_none);
+    code    : #1#212#20;
+    flags   : if_8086 or if_SB
+  ),
+  (
+    opcode  : A_AAS;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#63;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_ADC;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg8,ot_none);
+    code    : #192#1#16#65;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_ADC;
+    ops     : 2;
+    optypes : (ot_reg8,ot_reg8,ot_none);
+    code    : #192#1#16#65;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_ADC;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg16,ot_none);
+    code    : #208#192#1#17#65;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_ADC;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#192#1#17#65;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_ADC;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg32,ot_none);
+    code    : #209#192#1#17#65;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_ADC;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#192#1#17#65;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_ADC;
+    ops     : 2;
+    optypes : (ot_reg8,ot_memory,ot_none);
+    code    : #193#1#18#72;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_ADC;
+    ops     : 2;
+    optypes : (ot_reg8,ot_reg8,ot_none);
+    code    : #193#1#18#72;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_ADC;
+    ops     : 2;
+    optypes : (ot_reg16,ot_memory,ot_none);
+    code    : #208#193#1#19#72;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_ADC;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#193#1#19#72;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_ADC;
+    ops     : 2;
+    optypes : (ot_reg32,ot_memory,ot_none);
+    code    : #209#193#1#19#72;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_ADC;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#193#1#19#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_ADC;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_immediate or ot_bits8 or ot_signed,ot_none);
+    code    : #208#192#1#131#130#13;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_ADC;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_immediate or ot_bits8 or ot_signed,ot_none);
+    code    : #209#192#1#131#130#13;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_ADC;
+    ops     : 2;
+    optypes : (ot_reg_al,ot_immediate,ot_none);
+    code    : #1#20#17;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_ADC;
+    ops     : 2;
+    optypes : (ot_reg_ax,ot_immediate,ot_none);
+    code    : #208#1#21#25;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_ADC;
+    ops     : 2;
+    optypes : (ot_reg_eax,ot_immediate,ot_none);
+    code    : #209#1#21#33;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_ADC;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_immediate,ot_none);
+    code    : #192#1#128#130#17;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_ADC;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_immediate,ot_none);
+    code    : #208#192#1#129#130#25;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_ADC;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_immediate,ot_none);
+    code    : #209#192#1#129#130#33;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_ADC;
+    ops     : 2;
+    optypes : (ot_memory,ot_immediate or ot_bits8,ot_none);
+    code    : #192#1#128#130#17;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_ADC;
+    ops     : 2;
+    optypes : (ot_memory,ot_immediate or ot_bits16,ot_none);
+    code    : #208#192#1#129#130#25;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_ADC;
+    ops     : 2;
+    optypes : (ot_memory,ot_immediate or ot_bits32,ot_none);
+    code    : #209#192#1#129#130#33;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_ADD;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg8,ot_none);
+    code    : #192#15#65;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_ADD;
+    ops     : 2;
+    optypes : (ot_reg8,ot_reg8,ot_none);
+    code    : #192#15#65;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_ADD;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg16,ot_none);
+    code    : #208#192#1#1#65;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_ADD;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#192#1#1#65;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_ADD;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg32,ot_none);
+    code    : #209#192#1#1#65;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_ADD;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#192#1#1#65;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_ADD;
+    ops     : 2;
+    optypes : (ot_reg8,ot_memory,ot_none);
+    code    : #193#1#2#72;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_ADD;
+    ops     : 2;
+    optypes : (ot_reg8,ot_reg8,ot_none);
+    code    : #193#1#2#72;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_ADD;
+    ops     : 2;
+    optypes : (ot_reg16,ot_memory,ot_none);
+    code    : #208#193#1#3#72;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_ADD;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#193#1#3#72;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_ADD;
+    ops     : 2;
+    optypes : (ot_reg32,ot_memory,ot_none);
+    code    : #209#193#1#3#72;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_ADD;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#193#1#3#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_ADD;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_immediate or ot_bits8 or ot_signed,ot_none);
+    code    : #208#192#1#131#128#13;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_ADD;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_immediate or ot_bits8 or ot_signed,ot_none);
+    code    : #209#192#1#131#128#13;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_ADD;
+    ops     : 2;
+    optypes : (ot_reg_al,ot_immediate,ot_none);
+    code    : #1#4#17;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_ADD;
+    ops     : 2;
+    optypes : (ot_reg_ax,ot_immediate,ot_none);
+    code    : #208#1#5#25;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_ADD;
+    ops     : 2;
+    optypes : (ot_reg_eax,ot_immediate,ot_none);
+    code    : #209#1#5#33;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_ADD;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_immediate,ot_none);
+    code    : #192#1#128#128#17;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_ADD;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_immediate,ot_none);
+    code    : #208#192#1#129#128#25;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_ADD;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_immediate,ot_none);
+    code    : #209#192#1#129#128#33;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_ADD;
+    ops     : 2;
+    optypes : (ot_memory,ot_immediate or ot_bits8,ot_none);
+    code    : #192#1#128#128#17;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_ADD;
+    ops     : 2;
+    optypes : (ot_memory,ot_immediate or ot_bits16,ot_none);
+    code    : #208#192#1#129#128#25;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_ADD;
+    ops     : 2;
+    optypes : (ot_memory,ot_immediate or ot_bits32,ot_none);
+    code    : #209#192#1#129#128#33;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_AND;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg8,ot_none);
+    code    : #192#1#32#65;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_AND;
+    ops     : 2;
+    optypes : (ot_reg8,ot_reg8,ot_none);
+    code    : #192#1#32#65;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_AND;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg16,ot_none);
+    code    : #208#192#1#33#65;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_AND;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#192#1#33#65;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_AND;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg32,ot_none);
+    code    : #209#192#1#33#65;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_AND;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#192#1#33#65;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_AND;
+    ops     : 2;
+    optypes : (ot_reg8,ot_memory,ot_none);
+    code    : #193#1#34#72;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_AND;
+    ops     : 2;
+    optypes : (ot_reg8,ot_reg8,ot_none);
+    code    : #193#1#34#72;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_AND;
+    ops     : 2;
+    optypes : (ot_reg16,ot_memory,ot_none);
+    code    : #208#193#1#35#72;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_AND;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#193#1#35#72;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_AND;
+    ops     : 2;
+    optypes : (ot_reg32,ot_memory,ot_none);
+    code    : #209#193#1#35#72;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_AND;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#193#1#35#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_AND;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_immediate or ot_bits8 or ot_signed,ot_none);
+    code    : #208#192#1#131#132#13;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_AND;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_immediate or ot_bits8 or ot_signed,ot_none);
+    code    : #209#192#1#131#132#13;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_AND;
+    ops     : 2;
+    optypes : (ot_reg_al,ot_immediate,ot_none);
+    code    : #1#36#17;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_AND;
+    ops     : 2;
+    optypes : (ot_reg_ax,ot_immediate,ot_none);
+    code    : #208#1#37#25;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_AND;
+    ops     : 2;
+    optypes : (ot_reg_eax,ot_immediate,ot_none);
+    code    : #209#1#37#33;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_AND;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_immediate,ot_none);
+    code    : #192#1#128#132#17;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_AND;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_immediate,ot_none);
+    code    : #208#192#1#129#132#25;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_AND;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_immediate,ot_none);
+    code    : #209#192#1#129#132#33;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_AND;
+    ops     : 2;
+    optypes : (ot_memory,ot_immediate or ot_bits8,ot_none);
+    code    : #192#1#128#132#17;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_AND;
+    ops     : 2;
+    optypes : (ot_memory,ot_immediate or ot_bits16,ot_none);
+    code    : #208#192#1#129#132#25;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_AND;
+    ops     : 2;
+    optypes : (ot_memory,ot_immediate or ot_bits32,ot_none);
+    code    : #209#192#1#129#132#33;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_ARPL;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg16,ot_none);
+    code    : #192#1#99#65;
+    flags   : if_286 or if_PRIV or if_SM
+  ),
+  (
+    opcode  : A_ARPL;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #192#1#99#65;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_BOUND;
+    ops     : 2;
+    optypes : (ot_reg16,ot_memory,ot_none);
+    code    : #208#193#1#98#72;
+    flags   : if_186
+  ),
+  (
+    opcode  : A_BOUND;
+    ops     : 2;
+    optypes : (ot_reg32,ot_memory,ot_none);
+    code    : #209#193#1#98#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_BSF;
+    ops     : 2;
+    optypes : (ot_reg16,ot_memory,ot_none);
+    code    : #208#193#2#15#188#72;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_BSF;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#193#2#15#188#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_BSF;
+    ops     : 2;
+    optypes : (ot_reg32,ot_memory,ot_none);
+    code    : #209#193#2#15#188#72;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_BSF;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#193#2#15#188#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_BSR;
+    ops     : 2;
+    optypes : (ot_reg16,ot_memory,ot_none);
+    code    : #208#193#2#15#189#72;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_BSR;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#193#2#15#189#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_BSR;
+    ops     : 2;
+    optypes : (ot_reg32,ot_memory,ot_none);
+    code    : #209#193#2#15#189#72;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_BSR;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#193#2#15#189#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_BSWAP;
+    ops     : 1;
+    optypes : (ot_reg32,ot_none,ot_none);
+    code    : #209#1#15#8#200;
+    flags   : if_486
+  ),
+  (
+    opcode  : A_BT;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg16,ot_none);
+    code    : #208#192#2#15#163#65;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_BT;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#192#2#15#163#65;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_BT;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg32,ot_none);
+    code    : #209#192#2#15#163#65;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_BT;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#192#2#15#163#65;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_BT;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_immediate,ot_none);
+    code    : #208#192#2#15#186#132#21;
+    flags   : if_386 or if_SB
+  ),
+  (
+    opcode  : A_BT;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_immediate,ot_none);
+    code    : #209#192#2#15#186#132#21;
+    flags   : if_386 or if_SB
+  ),
+  (
+    opcode  : A_BTC;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg16,ot_none);
+    code    : #208#192#2#15#187#65;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_BTC;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#192#2#15#187#65;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_BTC;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg32,ot_none);
+    code    : #209#192#2#15#187#65;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_BTC;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#192#2#15#187#65;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_BTC;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_immediate,ot_none);
+    code    : #208#192#2#15#186#135#21;
+    flags   : if_386 or if_SB
+  ),
+  (
+    opcode  : A_BTC;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_immediate,ot_none);
+    code    : #209#192#2#15#186#135#21;
+    flags   : if_386 or if_SB
+  ),
+  (
+    opcode  : A_BTR;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg16,ot_none);
+    code    : #208#192#2#15#179#65;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_BTR;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#192#2#15#179#65;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_BTR;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg32,ot_none);
+    code    : #209#192#2#15#179#65;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_BTR;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#192#2#15#179#65;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_BTR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_immediate,ot_none);
+    code    : #208#192#2#15#186#134#21;
+    flags   : if_386 or if_SB
+  ),
+  (
+    opcode  : A_BTR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_immediate,ot_none);
+    code    : #209#192#2#15#186#134#21;
+    flags   : if_386 or if_SB
+  ),
+  (
+    opcode  : A_BTS;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg16,ot_none);
+    code    : #208#192#2#15#171#65;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_BTS;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#192#2#15#171#65;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_BTS;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg32,ot_none);
+    code    : #209#192#2#15#171#65;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_BTS;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#192#2#15#171#65;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_BTS;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_immediate,ot_none);
+    code    : #208#192#2#15#186#133#21;
+    flags   : if_386 or if_SB
+  ),
+  (
+    opcode  : A_BTS;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_immediate,ot_none);
+    code    : #209#192#2#15#186#133#21;
+    flags   : if_386 or if_SB
+  ),
+  (
+    opcode  : A_CALL;
+    ops     : 1;
+    optypes : (ot_immediate,ot_none,ot_none);
+    code    : #210#1#232#52;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_CALL;
+    ops     : 1;
+    optypes : (ot_immediate or ot_near,ot_none,ot_none);
+    code    : #210#1#232#52;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_CALL;
+    ops     : 1;
+    optypes : (ot_immediate or ot_far,ot_none,ot_none);
+    code    : #210#1#154#28#31;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_CALL;
+    ops     : 1;
+    optypes : (ot_immediate or ot_immediate,ot_none,ot_none);
+    code    : #210#1#154#29#24;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_CALL;
+    ops     : 1;
+    optypes : (ot_immediate or ot_bits16 or ot_immediate,ot_none,ot_none);
+    code    : #208#1#154#25#24;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_CALL;
+    ops     : 1;
+    optypes : (ot_immediate or ot_immediate or ot_bits16,ot_none,ot_none);
+    code    : #208#1#154#25#24;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_CALL;
+    ops     : 1;
+    optypes : (ot_immediate or ot_bits32 or ot_immediate,ot_none,ot_none);
+    code    : #209#1#154#33#24;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_CALL;
+    ops     : 1;
+    optypes : (ot_immediate or ot_immediate or ot_bits32,ot_none,ot_none);
+    code    : #209#1#154#33#24;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_CALL;
+    ops     : 1;
+    optypes : (ot_memory or ot_far,ot_none,ot_none);
+    code    : #210#192#1#255#131;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_CALL;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits16 or ot_far,ot_none,ot_none);
+    code    : #208#192#1#255#131;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_CALL;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits32 or ot_far,ot_none,ot_none);
+    code    : #209#192#1#255#131;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_CALL;
+    ops     : 1;
+    optypes : (ot_memory or ot_near,ot_none,ot_none);
+    code    : #210#192#1#255#130;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_CALL;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits16 or ot_near,ot_none,ot_none);
+    code    : #208#192#1#255#130;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_CALL;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits32 or ot_near,ot_none,ot_none);
+    code    : #209#192#1#255#130;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_CALL;
+    ops     : 1;
+    optypes : (ot_reg16,ot_none,ot_none);
+    code    : #208#192#1#255#130;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_CALL;
+    ops     : 1;
+    optypes : (ot_reg32,ot_none,ot_none);
+    code    : #209#192#1#255#130;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_CALL;
+    ops     : 1;
+    optypes : (ot_memory,ot_none,ot_none);
+    code    : #210#192#1#255#130;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_CALL;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits16,ot_none,ot_none);
+    code    : #208#192#1#255#130;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_CALL;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits32,ot_none,ot_none);
+    code    : #209#192#1#255#130;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_CBW;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #208#1#152;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_CDQ;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #209#1#153;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_CLC;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#248;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_CLD;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#252;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_CLI;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#250;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_CLTS;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#15#6;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_CMC;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#245;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_CMP;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg8,ot_none);
+    code    : #192#1#56#65;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_CMP;
+    ops     : 2;
+    optypes : (ot_reg8,ot_reg8,ot_none);
+    code    : #192#1#56#65;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_CMP;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg16,ot_none);
+    code    : #208#192#1#57#65;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_CMP;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#192#1#57#65;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_CMP;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg32,ot_none);
+    code    : #209#192#1#57#65;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_CMP;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#192#1#57#65;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_CMP;
+    ops     : 2;
+    optypes : (ot_reg8,ot_memory,ot_none);
+    code    : #193#1#58#72;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_CMP;
+    ops     : 2;
+    optypes : (ot_reg8,ot_reg8,ot_none);
+    code    : #193#1#58#72;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_CMP;
+    ops     : 2;
+    optypes : (ot_reg16,ot_memory,ot_none);
+    code    : #208#193#1#59#72;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_CMP;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#193#1#59#72;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_CMP;
+    ops     : 2;
+    optypes : (ot_reg32,ot_memory,ot_none);
+    code    : #209#193#1#59#72;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_CMP;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#193#1#59#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_CMP;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_immediate or ot_bits8 or ot_signed,ot_none);
+    code    : #208#192#1#131#135#13;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_CMP;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_immediate or ot_bits8 or ot_signed,ot_none);
+    code    : #209#192#1#131#135#13;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_CMP;
+    ops     : 2;
+    optypes : (ot_reg_al,ot_immediate,ot_none);
+    code    : #1#60#17;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_CMP;
+    ops     : 2;
+    optypes : (ot_reg_ax,ot_immediate,ot_none);
+    code    : #208#1#61#25;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_CMP;
+    ops     : 2;
+    optypes : (ot_reg_eax,ot_immediate,ot_none);
+    code    : #209#1#61#33;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_CMP;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_immediate,ot_none);
+    code    : #192#1#128#135#17;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_CMP;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_immediate,ot_none);
+    code    : #208#192#1#129#135#25;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_CMP;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_immediate,ot_none);
+    code    : #209#192#1#129#135#33;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_CMP;
+    ops     : 2;
+    optypes : (ot_memory,ot_immediate or ot_bits8,ot_none);
+    code    : #192#1#128#135#17;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_CMP;
+    ops     : 2;
+    optypes : (ot_memory,ot_immediate or ot_bits16,ot_none);
+    code    : #208#192#1#129#135#25;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_CMP;
+    ops     : 2;
+    optypes : (ot_memory,ot_immediate or ot_bits32,ot_none);
+    code    : #209#192#1#129#135#33;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_CMPSB;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#166;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_CMPSD;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #209#1#167;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_CMPSW;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #208#1#167;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_CMPXCHG;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg8,ot_none);
+    code    : #192#2#15#176#65;
+    flags   : if_PENT or if_SM
+  ),
+  (
+    opcode  : A_CMPXCHG;
+    ops     : 2;
+    optypes : (ot_reg8,ot_reg8,ot_none);
+    code    : #192#2#15#176#65;
+    flags   : if_PENT
+  ),
+  (
+    opcode  : A_CMPXCHG;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg16,ot_none);
+    code    : #208#192#2#15#177#65;
+    flags   : if_PENT or if_SM
+  ),
+  (
+    opcode  : A_CMPXCHG;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#192#2#15#177#65;
+    flags   : if_PENT
+  ),
+  (
+    opcode  : A_CMPXCHG;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg32,ot_none);
+    code    : #209#192#2#15#177#65;
+    flags   : if_PENT or if_SM
+  ),
+  (
+    opcode  : A_CMPXCHG;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#192#2#15#177#65;
+    flags   : if_PENT
+  ),
+  (
+    opcode  : A_CMPXCHG486;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg8,ot_none);
+    code    : #192#2#15#166#65;
+    flags   : if_486 or if_SM or if_UNDOC
+  ),
+  (
+    opcode  : A_CMPXCHG486;
+    ops     : 2;
+    optypes : (ot_reg8,ot_reg8,ot_none);
+    code    : #192#2#15#166#65;
+    flags   : if_486 or if_UNDOC
+  ),
+  (
+    opcode  : A_CMPXCHG486;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg16,ot_none);
+    code    : #208#192#2#15#167#65;
+    flags   : if_486 or if_SM or if_UNDOC
+  ),
+  (
+    opcode  : A_CMPXCHG486;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#192#2#15#167#65;
+    flags   : if_486 or if_UNDOC
+  ),
+  (
+    opcode  : A_CMPXCHG486;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg32,ot_none);
+    code    : #209#192#2#15#167#65;
+    flags   : if_486 or if_SM or if_UNDOC
+  ),
+  (
+    opcode  : A_CMPXCHG486;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#192#2#15#167#65;
+    flags   : if_486 or if_UNDOC
+  ),
+  (
+    opcode  : A_CMPXCHG8B;
+    ops     : 1;
+    optypes : (ot_memory,ot_none,ot_none);
+    code    : #192#2#15#199#129;
+    flags   : if_PENT
+  ),
+  (
+    opcode  : A_CPUID;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#15#162;
+    flags   : if_PENT
+  ),
+  (
+    opcode  : A_CS;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#46;
+    flags   : if_8086 or if_PRE
+  ),
+  (
+    opcode  : A_CWD;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #208#1#153;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_CWDE;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #209#1#152;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_DAA;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#39;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_DAS;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#47;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_DEC;
+    ops     : 1;
+    optypes : (ot_reg16,ot_none,ot_none);
+    code    : #208#8#72;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_DEC;
+    ops     : 1;
+    optypes : (ot_reg32,ot_none,ot_none);
+    code    : #209#8#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_DEC;
+    ops     : 1;
+    optypes : (ot_regmem or ot_bits8,ot_none,ot_none);
+    code    : #192#1#254#129;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_DEC;
+    ops     : 1;
+    optypes : (ot_regmem or ot_bits16,ot_none,ot_none);
+    code    : #208#192#1#255#129;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_DEC;
+    ops     : 1;
+    optypes : (ot_regmem or ot_bits32,ot_none,ot_none);
+    code    : #209#192#1#255#129;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_DIV;
+    ops     : 1;
+    optypes : (ot_regmem or ot_bits8,ot_none,ot_none);
+    code    : #192#1#246#134;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_DIV;
+    ops     : 1;
+    optypes : (ot_regmem or ot_bits16,ot_none,ot_none);
+    code    : #208#192#1#247#134;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_DIV;
+    ops     : 1;
+    optypes : (ot_regmem or ot_bits32,ot_none,ot_none);
+    code    : #209#192#1#247#134;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_DS;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#62;
+    flags   : if_8086 or if_PRE
+  ),
+  (
+    opcode  : A_EMMS;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#15#119;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_ENTER;
+    ops     : 2;
+    optypes : (ot_immediate,ot_immediate,ot_none);
+    code    : #1#200#24#21;
+    flags   : if_186
+  ),
+  (
+    opcode  : A_ES;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#38;
+    flags   : if_8086 or if_PRE
+  ),
+  (
+    opcode  : A_F2XM1;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#217#240;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FABS;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#217#225;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FADD;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits32,ot_none,ot_none);
+    code    : #192#1#216#128;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FADD;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits64,ot_none,ot_none);
+    code    : #192#1#220#128;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FADD;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#220#193;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FADD;
+    ops     : 1;
+    optypes : (ot_fpureg or ot_to,ot_none,ot_none);
+    code    : #1#220#8#192;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FADD;
+    ops     : 2;
+    optypes : (ot_fpureg,ot_fpu0,ot_none);
+    code    : #1#220#8#192;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FADD;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#216#8#192;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FADD;
+    ops     : 2;
+    optypes : (ot_fpu0,ot_fpureg,ot_none);
+    code    : #1#216#9#192;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FADDP;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#222#193;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FADDP;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#222#8#192;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FADDP;
+    ops     : 2;
+    optypes : (ot_fpureg,ot_fpu0,ot_none);
+    code    : #1#222#8#192;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FBLD;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits80,ot_none,ot_none);
+    code    : #192#1#223#132;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FBLD;
+    ops     : 1;
+    optypes : (ot_memory,ot_none,ot_none);
+    code    : #192#1#223#132;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FBSTP;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits80,ot_none,ot_none);
+    code    : #192#1#223#134;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FBSTP;
+    ops     : 1;
+    optypes : (ot_memory,ot_none,ot_none);
+    code    : #192#1#223#134;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FCHS;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#217#224;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FCLEX;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #3#155#219#226;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FCMOVB;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#218#193;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FCMOVB;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#218#8#192;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FCMOVB;
+    ops     : 2;
+    optypes : (ot_fpu0,ot_fpureg,ot_none);
+    code    : #1#218#9#192;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FCMOVBE;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#218#209;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FCMOVBE;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#218#8#208;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FCMOVBE;
+    ops     : 2;
+    optypes : (ot_fpu0,ot_fpureg,ot_none);
+    code    : #1#218#9#208;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FCMOVE;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#218#201;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FCMOVE;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#218#8#200;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FCMOVE;
+    ops     : 2;
+    optypes : (ot_fpu0,ot_fpureg,ot_none);
+    code    : #1#218#9#200;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FCMOVNB;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#219#193;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FCMOVNB;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#219#8#192;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FCMOVNB;
+    ops     : 2;
+    optypes : (ot_fpu0,ot_fpureg,ot_none);
+    code    : #1#219#9#192;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FCMOVNBE;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#219#209;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FCMOVNBE;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#219#8#208;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FCMOVNBE;
+    ops     : 2;
+    optypes : (ot_fpu0,ot_fpureg,ot_none);
+    code    : #1#219#9#208;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FCMOVNE;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#219#201;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FCMOVNE;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#219#8#200;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FCMOVNE;
+    ops     : 2;
+    optypes : (ot_fpu0,ot_fpureg,ot_none);
+    code    : #1#219#9#200;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FCMOVNU;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#219#217;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FCMOVNU;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#219#8#216;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FCMOVNU;
+    ops     : 2;
+    optypes : (ot_fpu0,ot_fpureg,ot_none);
+    code    : #1#219#9#216;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FCMOVU;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#218#217;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FCMOVU;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#218#8#216;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FCMOVU;
+    ops     : 2;
+    optypes : (ot_fpu0,ot_fpureg,ot_none);
+    code    : #1#218#9#216;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FCOM;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits32,ot_none,ot_none);
+    code    : #192#1#216#130;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FCOM;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits64,ot_none,ot_none);
+    code    : #192#1#220#130;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FCOM;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#216#209;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FCOM;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#216#8#208;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FCOM;
+    ops     : 2;
+    optypes : (ot_fpu0,ot_fpureg,ot_none);
+    code    : #1#216#9#208;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FCOMI;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#219#241;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FCOMI;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#219#8#240;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FCOMI;
+    ops     : 2;
+    optypes : (ot_fpu0,ot_fpureg,ot_none);
+    code    : #1#219#9#240;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FCOMIP;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#223#241;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FCOMIP;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#223#8#240;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FCOMIP;
+    ops     : 2;
+    optypes : (ot_fpu0,ot_fpureg,ot_none);
+    code    : #1#223#9#240;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FCOMP;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits32,ot_none,ot_none);
+    code    : #192#1#216#131;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FCOMP;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits64,ot_none,ot_none);
+    code    : #192#1#220#131;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FCOMP;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#216#217;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FCOMP;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#216#8#216;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FCOMP;
+    ops     : 2;
+    optypes : (ot_fpu0,ot_fpureg,ot_none);
+    code    : #1#216#9#216;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FCOMPP;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#222#217;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FCOS;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#217#255;
+    flags   : if_386 or if_FPU
+  ),
+  (
+    opcode  : A_FDECSTP;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#217#246;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FDISI;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #3#155#219#225;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FDIV;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits32,ot_none,ot_none);
+    code    : #192#1#216#134;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FDIV;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits64,ot_none,ot_none);
+    code    : #192#1#220#134;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FDIV;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#220#241;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FDIV;
+    ops     : 1;
+    optypes : (ot_fpureg or ot_to,ot_none,ot_none);
+    code    : #1#220#8#240;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FDIV;
+    ops     : 2;
+    optypes : (ot_fpureg,ot_fpu0,ot_none);
+    code    : #1#220#8#240;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FDIV;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#216#8#240;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FDIV;
+    ops     : 2;
+    optypes : (ot_fpu0,ot_fpureg,ot_none);
+    code    : #1#216#9#240;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FDIVP;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#222#241;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FDIVP;
+    ops     : 2;
+    optypes : (ot_fpureg,ot_fpu0,ot_none);
+    code    : #1#222#8#240;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FDIVP;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#222#8#240;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FDIVR;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits32,ot_none,ot_none);
+    code    : #192#1#216#135;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FDIVR;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits64,ot_none,ot_none);
+    code    : #192#1#220#135;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FDIVR;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#220#249;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FDIVR;
+    ops     : 1;
+    optypes : (ot_fpureg or ot_to,ot_none,ot_none);
+    code    : #1#220#8#248;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FDIVR;
+    ops     : 2;
+    optypes : (ot_fpureg,ot_fpu0,ot_none);
+    code    : #1#220#8#248;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FDIVR;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#216#8#248;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FDIVR;
+    ops     : 2;
+    optypes : (ot_fpu0,ot_fpureg,ot_none);
+    code    : #1#216#9#248;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FDIVRP;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#222#249;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FDIVRP;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#222#8#248;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FDIVRP;
+    ops     : 2;
+    optypes : (ot_fpureg,ot_fpu0,ot_none);
+    code    : #1#222#8#248;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FEMMS;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none or ot_signed);
+    code    : #2#15#14;
+    flags   : if_PENT or if_MMX or if_FPU
+  ),
+  (
+    opcode  : A_FENI;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #3#155#219#224;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FFREE;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#221#8#192;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FIADD;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits32,ot_none,ot_none);
+    code    : #192#1#218#128;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FIADD;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits16,ot_none,ot_none);
+    code    : #192#1#222#128;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FICOM;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits32,ot_none,ot_none);
+    code    : #192#1#218#130;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FICOM;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits16,ot_none,ot_none);
+    code    : #192#1#222#130;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FICOMP;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits32,ot_none,ot_none);
+    code    : #192#1#218#131;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FICOMP;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits16,ot_none,ot_none);
+    code    : #192#1#222#131;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FIDIV;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits32,ot_none,ot_none);
+    code    : #192#1#218#134;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FIDIV;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits16,ot_none,ot_none);
+    code    : #192#1#222#134;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FIDIVR;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits32,ot_none,ot_none);
+    code    : #192#1#218#135;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FIDIVR;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits16,ot_none,ot_none);
+    code    : #192#1#222#135;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FILD;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits32,ot_none,ot_none);
+    code    : #192#1#219#128;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FILD;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits16,ot_none,ot_none);
+    code    : #192#1#223#128;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FILD;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits64,ot_none,ot_none);
+    code    : #192#1#223#133;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FIMUL;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits32,ot_none,ot_none);
+    code    : #192#1#218#129;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FIMUL;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits16,ot_none,ot_none);
+    code    : #192#1#222#129;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FINCSTP;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#217#247;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FINIT;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #3#155#219#227;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FIST;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits32,ot_none,ot_none);
+    code    : #192#1#219#130;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FIST;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits16,ot_none,ot_none);
+    code    : #192#1#223#130;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FISTP;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits32,ot_none,ot_none);
+    code    : #192#1#219#131;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FISTP;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits16,ot_none,ot_none);
+    code    : #192#1#223#131;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FISTP;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits64,ot_none,ot_none);
+    code    : #192#1#223#135;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FISUB;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits32,ot_none,ot_none);
+    code    : #192#1#218#132;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FISUB;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits16,ot_none,ot_none);
+    code    : #192#1#222#132;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FISUBR;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits32,ot_none,ot_none);
+    code    : #192#1#218#133;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FISUBR;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits16,ot_none,ot_none);
+    code    : #192#1#222#133;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FLD;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits32,ot_none,ot_none);
+    code    : #192#1#217#128;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FLD;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits64,ot_none,ot_none);
+    code    : #192#1#221#128;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FLD;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits80,ot_none,ot_none);
+    code    : #192#1#219#133;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FLD;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#217#8#192;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FLD1;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#217#232;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FLDCW;
+    ops     : 1;
+    optypes : (ot_memory,ot_none,ot_none);
+    code    : #192#1#217#133;
+    flags   : if_8086 or if_FPU or if_SW
+  ),
+  (
+    opcode  : A_FLDENV;
+    ops     : 1;
+    optypes : (ot_memory,ot_none,ot_none);
+    code    : #192#1#217#132;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FLDL2E;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#217#234;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FLDL2T;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#217#233;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FLDLG2;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#217#236;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FLDLN2;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#217#237;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FLDPI;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#217#235;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FLDZ;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#217#238;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FMUL;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits32,ot_none,ot_none);
+    code    : #192#1#216#129;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FMUL;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits64,ot_none,ot_none);
+    code    : #192#1#220#129;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FMUL;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#220#201;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FMUL;
+    ops     : 1;
+    optypes : (ot_fpureg or ot_to,ot_none,ot_none);
+    code    : #1#220#8#200;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FMUL;
+    ops     : 2;
+    optypes : (ot_fpureg,ot_fpu0,ot_none);
+    code    : #1#220#8#200;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FMUL;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#216#8#200;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FMUL;
+    ops     : 2;
+    optypes : (ot_fpu0,ot_fpureg,ot_none);
+    code    : #1#216#9#200;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FMULP;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#222#201;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FMULP;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#222#8#200;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FMULP;
+    ops     : 2;
+    optypes : (ot_fpureg,ot_fpu0,ot_none);
+    code    : #1#222#8#200;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FNCLEX;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#219#226;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FNDISI;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#219#225;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FNENI;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#219#224;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FNINIT;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#219#227;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FNOP;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#217#208;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FNSAVE;
+    ops     : 1;
+    optypes : (ot_memory,ot_none,ot_none);
+    code    : #192#1#221#134;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FNSTCW;
+    ops     : 1;
+    optypes : (ot_memory,ot_none,ot_none);
+    code    : #192#1#217#135;
+    flags   : if_8086 or if_FPU or if_SW
+  ),
+  (
+    opcode  : A_FNSTENV;
+    ops     : 1;
+    optypes : (ot_memory,ot_none,ot_none);
+    code    : #192#1#217#134;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FNSTSW;
+    ops     : 1;
+    optypes : (ot_memory,ot_none,ot_none);
+    code    : #192#1#221#135;
+    flags   : if_8086 or if_FPU or if_SW
+  ),
+  (
+    opcode  : A_FNSTSW;
+    ops     : 1;
+    optypes : (ot_reg_ax,ot_none,ot_none);
+    code    : #2#223#224;
+    flags   : if_286 or if_FPU
+  ),
+  (
+    opcode  : A_FPATAN;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#217#243;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FPREM;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#217#248;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FPREM1;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#217#245;
+    flags   : if_386 or if_FPU
+  ),
+  (
+    opcode  : A_FPTAN;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#217#242;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FRNDINT;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#217#252;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FRSTOR;
+    ops     : 1;
+    optypes : (ot_memory,ot_none,ot_none);
+    code    : #192#1#221#132;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FS;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#100;
+    flags   : if_386 or if_PRE
+  ),
+  (
+    opcode  : A_FSAVE;
+    ops     : 1;
+    optypes : (ot_memory,ot_none,ot_none);
+    code    : #192#2#155#221#134;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FSCALE;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#217#253;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FSETPM;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#219#228;
+    flags   : if_286 or if_FPU
+  ),
+  (
+    opcode  : A_FSIN;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#217#254;
+    flags   : if_386 or if_FPU
+  ),
+  (
+    opcode  : A_FSINCOS;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#217#251;
+    flags   : if_386 or if_FPU
+  ),
+  (
+    opcode  : A_FSQRT;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#217#250;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FST;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits32,ot_none,ot_none);
+    code    : #192#1#217#130;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FST;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits64,ot_none,ot_none);
+    code    : #192#1#221#130;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FST;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#221#8#208;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FSTCW;
+    ops     : 1;
+    optypes : (ot_memory,ot_none,ot_none);
+    code    : #192#2#155#217#135;
+    flags   : if_8086 or if_FPU or if_SW
+  ),
+  (
+    opcode  : A_FSTENV;
+    ops     : 1;
+    optypes : (ot_memory,ot_none,ot_none);
+    code    : #192#2#155#217#134;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FSTP;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits32,ot_none,ot_none);
+    code    : #192#1#217#131;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FSTP;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits64,ot_none,ot_none);
+    code    : #192#1#221#131;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FSTP;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits80,ot_none,ot_none);
+    code    : #192#1#219#135;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FSTP;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#221#8#216;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FSTSW;
+    ops     : 1;
+    optypes : (ot_memory,ot_none,ot_none);
+    code    : #192#2#155#221#135;
+    flags   : if_8086 or if_FPU or if_SW
+  ),
+  (
+    opcode  : A_FSTSW;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #3#155#223#224;
+    flags   : if_286 or if_FPU
+  ),
+  (
+    opcode  : A_FSTSW;
+    ops     : 1;
+    optypes : (ot_reg_ax,ot_none,ot_none);
+    code    : #3#155#223#224;
+    flags   : if_286 or if_FPU
+  ),
+  (
+    opcode  : A_FSUB;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits32,ot_none,ot_none);
+    code    : #192#1#216#132;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FSUB;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits64,ot_none,ot_none);
+    code    : #192#1#220#132;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FSUB;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#220#225;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FSUB;
+    ops     : 1;
+    optypes : (ot_fpureg or ot_to,ot_none,ot_none);
+    code    : #1#220#8#224;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FSUB;
+    ops     : 2;
+    optypes : (ot_fpureg,ot_fpu0,ot_none);
+    code    : #1#220#8#224;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FSUB;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#216#8#224;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FSUB;
+    ops     : 2;
+    optypes : (ot_fpu0,ot_fpureg,ot_none);
+    code    : #1#216#9#224;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FSUBP;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#222#225;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FSUBP;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#222#8#224;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FSUBP;
+    ops     : 2;
+    optypes : (ot_fpureg,ot_fpu0,ot_none);
+    code    : #1#222#8#224;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FSUBR;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits32,ot_none,ot_none);
+    code    : #192#1#216#133;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FSUBR;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits64,ot_none,ot_none);
+    code    : #192#1#220#133;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FSUBR;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#220#233;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FSUBR;
+    ops     : 1;
+    optypes : (ot_fpureg or ot_to,ot_none,ot_none);
+    code    : #1#220#8#232;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FSUBR;
+    ops     : 2;
+    optypes : (ot_fpureg,ot_fpu0,ot_none);
+    code    : #1#220#8#232;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FSUBR;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#216#8#232;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FSUBR;
+    ops     : 2;
+    optypes : (ot_fpu0,ot_fpureg,ot_none);
+    code    : #1#216#9#232;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FSUBRP;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#222#233;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FSUBRP;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#222#8#232;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FSUBRP;
+    ops     : 2;
+    optypes : (ot_fpureg,ot_fpu0,ot_none);
+    code    : #1#222#8#232;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FTST;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#217#228;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FUCOM;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#221#225;
+    flags   : if_386 or if_FPU
+  ),
+  (
+    opcode  : A_FUCOM;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#221#8#224;
+    flags   : if_386 or if_FPU
+  ),
+  (
+    opcode  : A_FUCOM;
+    ops     : 2;
+    optypes : (ot_fpu0,ot_fpureg,ot_none);
+    code    : #1#221#9#224;
+    flags   : if_386 or if_FPU
+  ),
+  (
+    opcode  : A_FUCOMI;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#219#233;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FUCOMI;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#219#8#232;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FUCOMI;
+    ops     : 2;
+    optypes : (ot_fpu0,ot_fpureg,ot_none);
+    code    : #1#219#9#232;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FUCOMIP;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#223#233;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FUCOMIP;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#223#8#232;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FUCOMIP;
+    ops     : 2;
+    optypes : (ot_fpu0,ot_fpureg,ot_none);
+    code    : #1#223#9#232;
+    flags   : if_P6 or if_FPU
+  ),
+  (
+    opcode  : A_FUCOMP;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#221#233;
+    flags   : if_386 or if_FPU
+  ),
+  (
+    opcode  : A_FUCOMP;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#221#8#232;
+    flags   : if_386 or if_FPU
+  ),
+  (
+    opcode  : A_FUCOMP;
+    ops     : 2;
+    optypes : (ot_fpu0,ot_fpureg,ot_none);
+    code    : #1#221#9#232;
+    flags   : if_386 or if_FPU
+  ),
+  (
+    opcode  : A_FUCOMPP;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#218#233;
+    flags   : if_386 or if_FPU
+  ),
+  (
+    opcode  : A_FWAIT;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#155;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FXAM;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#217#229;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FXCH;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#217#201;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FXCH;
+    ops     : 1;
+    optypes : (ot_fpureg,ot_none,ot_none);
+    code    : #1#217#8#200;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FXCH;
+    ops     : 2;
+    optypes : (ot_fpureg,ot_fpu0,ot_none);
+    code    : #1#217#8#200;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FXCH;
+    ops     : 2;
+    optypes : (ot_fpu0,ot_fpureg,ot_none);
+    code    : #1#217#9#200;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FXTRACT;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#217#244;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FYL2X;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#217#241;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_FYL2XP1;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#217#249;
+    flags   : if_8086 or if_FPU
+  ),
+  (
+    opcode  : A_GS;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#101;
+    flags   : if_386 or if_PRE
+  ),
+  (
+    opcode  : A_HLT;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#244;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_IBTS;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg16,ot_none);
+    code    : #208#192#2#15#167#65;
+    flags   : if_386 or if_SW or if_UNDOC
+  ),
+  (
+    opcode  : A_IBTS;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#192#2#15#167#65;
+    flags   : if_386 or if_UNDOC
+  ),
+  (
+    opcode  : A_IBTS;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg32,ot_none);
+    code    : #209#192#2#15#167#65;
+    flags   : if_386 or if_SD or if_UNDOC
+  ),
+  (
+    opcode  : A_IBTS;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#192#2#15#167#65;
+    flags   : if_386 or if_UNDOC
+  ),
+  (
+    opcode  : A_ICEBP;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#241;
+    flags   : if_P6
+  ),
+  (
+    opcode  : A_IDIV;
+    ops     : 1;
+    optypes : (ot_regmem or ot_bits8,ot_none,ot_none);
+    code    : #192#1#246#135;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_IDIV;
+    ops     : 1;
+    optypes : (ot_regmem or ot_bits16,ot_none,ot_none);
+    code    : #208#192#1#247#135;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_IDIV;
+    ops     : 1;
+    optypes : (ot_regmem or ot_bits32,ot_none,ot_none);
+    code    : #209#192#1#247#135;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_IMUL;
+    ops     : 1;
+    optypes : (ot_regmem or ot_bits8,ot_none,ot_none);
+    code    : #192#1#246#133;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_IMUL;
+    ops     : 1;
+    optypes : (ot_regmem or ot_bits16,ot_none,ot_none);
+    code    : #208#192#1#247#133;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_IMUL;
+    ops     : 1;
+    optypes : (ot_regmem or ot_bits32,ot_none,ot_none);
+    code    : #209#192#1#247#133;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_IMUL;
+    ops     : 2;
+    optypes : (ot_reg16,ot_memory,ot_none);
+    code    : #208#193#2#15#175#72;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_IMUL;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#193#2#15#175#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_IMUL;
+    ops     : 2;
+    optypes : (ot_reg32,ot_memory,ot_none);
+    code    : #209#193#2#15#175#72;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_IMUL;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#193#2#15#175#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_IMUL;
+    ops     : 3;
+    optypes : (ot_reg16,ot_memory,ot_immediate or ot_bits8 or ot_signed);
+    code    : #208#193#1#107#72#14;
+    flags   : if_286 or if_SM
+  ),
+  (
+    opcode  : A_IMUL;
+    ops     : 3;
+    optypes : (ot_reg16,ot_reg16,ot_immediate or ot_bits8 or ot_signed);
+    code    : #208#193#1#107#72#14;
+    flags   : if_286
+  ),
+  (
+    opcode  : A_IMUL;
+    ops     : 3;
+    optypes : (ot_reg16,ot_memory,ot_immediate);
+    code    : #208#193#1#105#72#26;
+    flags   : if_286 or if_SM
+  ),
+  (
+    opcode  : A_IMUL;
+    ops     : 3;
+    optypes : (ot_reg16,ot_reg16,ot_immediate);
+    code    : #208#193#1#105#72#26;
+    flags   : if_286 or if_SM
+  ),
+  (
+    opcode  : A_IMUL;
+    ops     : 3;
+    optypes : (ot_reg32,ot_memory,ot_immediate or ot_bits8 or ot_signed);
+    code    : #209#193#1#107#72#14;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_IMUL;
+    ops     : 3;
+    optypes : (ot_reg32,ot_reg32,ot_immediate or ot_bits8 or ot_signed);
+    code    : #209#193#1#107#72#14;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_IMUL;
+    ops     : 3;
+    optypes : (ot_reg32,ot_memory,ot_immediate);
+    code    : #209#193#1#105#72#34;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_IMUL;
+    ops     : 3;
+    optypes : (ot_reg32,ot_reg32,ot_immediate);
+    code    : #209#193#1#105#72#34;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_IMUL;
+    ops     : 2;
+    optypes : (ot_reg16,ot_immediate or ot_bits8 or ot_signed,ot_none);
+    code    : #208#1#107#64#13;
+    flags   : if_286
+  ),
+  (
+    opcode  : A_IMUL;
+    ops     : 2;
+    optypes : (ot_reg16,ot_immediate,ot_none);
+    code    : #208#1#105#64#25;
+    flags   : if_286 or if_SM
+  ),
+  (
+    opcode  : A_IMUL;
+    ops     : 2;
+    optypes : (ot_reg32,ot_immediate or ot_bits8 or ot_signed,ot_none);
+    code    : #209#1#107#64#13;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_IMUL;
+    ops     : 2;
+    optypes : (ot_reg32,ot_immediate,ot_none);
+    code    : #209#1#105#64#33;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_IN;
+    ops     : 2;
+    optypes : (ot_reg_al,ot_immediate,ot_none);
+    code    : #1#228#21;
+    flags   : if_8086 or if_SB
+  ),
+  (
+    opcode  : A_IN;
+    ops     : 2;
+    optypes : (ot_reg_ax,ot_immediate,ot_none);
+    code    : #208#1#229#21;
+    flags   : if_8086 or if_SB
+  ),
+  (
+    opcode  : A_IN;
+    ops     : 2;
+    optypes : (ot_reg_eax,ot_immediate,ot_none);
+    code    : #209#1#229#21;
+    flags   : if_386 or if_SB
+  ),
+  (
+    opcode  : A_IN;
+    ops     : 2;
+    optypes : (ot_reg_al,ot_reg_dx,ot_none);
+    code    : #1#236;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_IN;
+    ops     : 2;
+    optypes : (ot_reg_ax,ot_reg_dx,ot_none);
+    code    : #208#1#237;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_IN;
+    ops     : 2;
+    optypes : (ot_reg_eax,ot_reg_dx,ot_none);
+    code    : #209#1#237;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_INC;
+    ops     : 1;
+    optypes : (ot_reg16,ot_none,ot_none);
+    code    : #208#8#64;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_INC;
+    ops     : 1;
+    optypes : (ot_reg32,ot_none,ot_none);
+    code    : #209#8#64;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_INC;
+    ops     : 1;
+    optypes : (ot_regmem or ot_bits8,ot_none,ot_none);
+    code    : #192#1#254#128;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_INC;
+    ops     : 1;
+    optypes : (ot_regmem or ot_bits16,ot_none,ot_none);
+    code    : #208#192#1#255#128;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_INC;
+    ops     : 1;
+    optypes : (ot_regmem or ot_bits32,ot_none,ot_none);
+    code    : #209#192#1#255#128;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_INSB;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#108;
+    flags   : if_186
+  ),
+  (
+    opcode  : A_INSD;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #209#1#109;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_INSW;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #208#1#109;
+    flags   : if_186
+  ),
+  (
+    opcode  : A_INT;
+    ops     : 1;
+    optypes : (ot_immediate,ot_none,ot_none);
+    code    : #1#205#20;
+    flags   : if_8086 or if_SB
+  ),
+  (
+    opcode  : A_INT01;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#241;
+    flags   : if_P6
+  ),
+  (
+    opcode  : A_INT1;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#241;
+    flags   : if_P6
+  ),
+  (
+    opcode  : A_INT3;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#204;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_INTO;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#206;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_INVD;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#15#8;
+    flags   : if_486
+  ),
+  (
+    opcode  : A_INVLPG;
+    ops     : 1;
+    optypes : (ot_memory,ot_none,ot_none);
+    code    : #192#2#15#1#135;
+    flags   : if_486
+  ),
+  (
+    opcode  : A_IRET;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #210#1#207;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_IRETD;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #209#1#207;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_IRETW;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #208#1#207;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_JCXZ;
+    ops     : 1;
+    optypes : (ot_immediate,ot_none,ot_none);
+    code    : #208#1#227#40;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_JECXZ;
+    ops     : 1;
+    optypes : (ot_immediate,ot_none,ot_none);
+    code    : #209#1#227#40;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_JMP;
+    ops     : 1;
+    optypes : (ot_immediate or ot_short,ot_none,ot_none);
+    code    : #1#235#40;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_JMP;
+    ops     : 1;
+    optypes : (ot_immediate,ot_none,ot_none);
+    code    : #210#1#233#52;
+    flags   : if_8086 or if_PASS2
+  ),
+  (
+    opcode  : A_JMP;
+    ops     : 1;
+    optypes : (ot_immediate or ot_near,ot_none,ot_none);
+    code    : #210#1#233#52;
+    flags   : if_8086 or if_PASS2
+  ),
+  (
+    opcode  : A_JMP;
+    ops     : 1;
+    optypes : (ot_immediate or ot_far,ot_none,ot_none);
+    code    : #210#1#234#28#31;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_JMP;
+    ops     : 1;
+    optypes : (ot_immediate or ot_immediate,ot_none,ot_none);
+    code    : #210#1#234#29#24;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_JMP;
+    ops     : 1;
+    optypes : (ot_immediate or ot_bits16 or ot_immediate,ot_none,ot_none);
+    code    : #208#1#234#25#24;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_JMP;
+    ops     : 1;
+    optypes : (ot_immediate or ot_immediate or ot_bits16,ot_none,ot_none);
+    code    : #208#1#234#25#24;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_JMP;
+    ops     : 1;
+    optypes : (ot_immediate or ot_bits32 or ot_immediate,ot_none,ot_none);
+    code    : #209#1#234#33#24;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_JMP;
+    ops     : 1;
+    optypes : (ot_immediate or ot_immediate or ot_bits32,ot_none,ot_none);
+    code    : #209#1#234#33#24;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_JMP;
+    ops     : 1;
+    optypes : (ot_memory or ot_far,ot_none,ot_none);
+    code    : #210#192#1#255#133;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_JMP;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits16 or ot_far,ot_none,ot_none);
+    code    : #208#192#1#255#133;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_JMP;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits32 or ot_far,ot_none,ot_none);
+    code    : #209#192#1#255#133;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_JMP;
+    ops     : 1;
+    optypes : (ot_memory or ot_near,ot_none,ot_none);
+    code    : #210#192#1#255#132;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_JMP;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits16 or ot_near,ot_none,ot_none);
+    code    : #208#192#1#255#132;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_JMP;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits32 or ot_near,ot_none,ot_none);
+    code    : #209#192#1#255#132;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_JMP;
+    ops     : 1;
+    optypes : (ot_reg16,ot_none,ot_none);
+    code    : #208#192#1#255#132;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_JMP;
+    ops     : 1;
+    optypes : (ot_reg32,ot_none,ot_none);
+    code    : #209#192#1#255#132;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_JMP;
+    ops     : 1;
+    optypes : (ot_memory,ot_none,ot_none);
+    code    : #210#192#1#255#132;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_JMP;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits16,ot_none,ot_none);
+    code    : #208#192#1#255#132;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_JMP;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits32,ot_none,ot_none);
+    code    : #209#192#1#255#132;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_LAHF;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#159;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_LAR;
+    ops     : 2;
+    optypes : (ot_reg16,ot_memory,ot_none);
+    code    : #208#193#2#15#2#72;
+    flags   : if_286 or if_PRIV or if_SM
+  ),
+  (
+    opcode  : A_LAR;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#193#2#15#2#72;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_LAR;
+    ops     : 2;
+    optypes : (ot_reg32,ot_memory,ot_none);
+    code    : #209#193#2#15#2#72;
+    flags   : if_286 or if_PRIV or if_SM
+  ),
+  (
+    opcode  : A_LAR;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#193#2#15#2#72;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_LDS;
+    ops     : 2;
+    optypes : (ot_reg16,ot_memory,ot_none);
+    code    : #208#193#1#197#72;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_LDS;
+    ops     : 2;
+    optypes : (ot_reg32,ot_memory,ot_none);
+    code    : #209#193#1#197#72;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_LEA;
+    ops     : 2;
+    optypes : (ot_reg16,ot_memory,ot_none);
+    code    : #208#193#1#141#72;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_LEA;
+    ops     : 2;
+    optypes : (ot_reg32,ot_memory,ot_none);
+    code    : #209#193#1#141#72;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_LEA;
+    ops     : 2;
+    optypes : (ot_reg32,ot_immediate or ot_bits32,ot_none);
+    code    : #209#193#1#141#72;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_LEAVE;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#201;
+    flags   : if_186
+  ),
+  (
+    opcode  : A_LES;
+    ops     : 2;
+    optypes : (ot_reg16,ot_memory,ot_none);
+    code    : #208#193#1#196#72;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_LES;
+    ops     : 2;
+    optypes : (ot_reg32,ot_memory,ot_none);
+    code    : #209#193#1#196#72;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_LFS;
+    ops     : 2;
+    optypes : (ot_reg16,ot_memory,ot_none);
+    code    : #208#193#2#15#180#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_LFS;
+    ops     : 2;
+    optypes : (ot_reg32,ot_memory,ot_none);
+    code    : #209#193#2#15#180#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_LGDT;
+    ops     : 1;
+    optypes : (ot_memory,ot_none,ot_none);
+    code    : #192#2#15#1#130;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_LGS;
+    ops     : 2;
+    optypes : (ot_reg16,ot_memory,ot_none);
+    code    : #208#193#2#15#181#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_LGS;
+    ops     : 2;
+    optypes : (ot_reg32,ot_memory,ot_none);
+    code    : #209#193#2#15#181#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_LIDT;
+    ops     : 1;
+    optypes : (ot_memory,ot_none,ot_none);
+    code    : #192#2#15#1#131;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_LLDT;
+    ops     : 1;
+    optypes : (ot_memory,ot_none,ot_none);
+    code    : #192#1#15#15#130;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_LLDT;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits16,ot_none,ot_none);
+    code    : #192#1#15#15#130;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_LLDT;
+    ops     : 1;
+    optypes : (ot_reg16,ot_none,ot_none);
+    code    : #192#1#15#15#130;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_LMSW;
+    ops     : 1;
+    optypes : (ot_memory,ot_none,ot_none);
+    code    : #192#2#15#1#134;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_LMSW;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits16,ot_none,ot_none);
+    code    : #192#2#15#1#134;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_LMSW;
+    ops     : 1;
+    optypes : (ot_reg16,ot_none,ot_none);
+    code    : #192#2#15#1#134;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_LOADALL;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#15#7;
+    flags   : if_386 or if_UNDOC
+  ),
+  (
+    opcode  : A_LOADALL286;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#15#5;
+    flags   : if_286 or if_UNDOC
+  ),
+  (
+    opcode  : A_LOCK;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#240;
+    flags   : if_8086 or if_PRE
+  ),
+  (
+    opcode  : A_LODSB;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#172;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_LODSD;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #209#1#173;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_LODSW;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #208#1#173;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_LOOP;
+    ops     : 1;
+    optypes : (ot_immediate,ot_none,ot_none);
+    code    : #202#1#226#40;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_LOOP;
+    ops     : 2;
+    optypes : (ot_immediate,ot_reg_cx,ot_none);
+    code    : #200#1#226#40;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_LOOP;
+    ops     : 2;
+    optypes : (ot_immediate,ot_reg_ecx,ot_none);
+    code    : #201#1#226#40;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_LOOPE;
+    ops     : 1;
+    optypes : (ot_immediate,ot_none,ot_none);
+    code    : #202#1#225#40;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_LOOPE;
+    ops     : 2;
+    optypes : (ot_immediate,ot_reg_cx,ot_none);
+    code    : #200#1#225#40;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_LOOPE;
+    ops     : 2;
+    optypes : (ot_immediate,ot_reg_ecx,ot_none);
+    code    : #201#1#225#40;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_LOOPNE;
+    ops     : 1;
+    optypes : (ot_immediate,ot_none,ot_none);
+    code    : #202#1#224#40;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_LOOPNE;
+    ops     : 2;
+    optypes : (ot_immediate,ot_reg_cx,ot_none);
+    code    : #200#1#224#40;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_LOOPNE;
+    ops     : 2;
+    optypes : (ot_immediate,ot_reg_ecx,ot_none);
+    code    : #201#1#224#40;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_LOOPNZ;
+    ops     : 1;
+    optypes : (ot_immediate,ot_none,ot_none);
+    code    : #202#1#224#40;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_LOOPNZ;
+    ops     : 2;
+    optypes : (ot_immediate,ot_reg_cx,ot_none);
+    code    : #200#1#224#40;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_LOOPNZ;
+    ops     : 2;
+    optypes : (ot_immediate,ot_reg_ecx,ot_none);
+    code    : #201#1#224#40;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_LOOPZ;
+    ops     : 1;
+    optypes : (ot_immediate,ot_none,ot_none);
+    code    : #202#1#225#40;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_LOOPZ;
+    ops     : 2;
+    optypes : (ot_immediate,ot_reg_cx,ot_none);
+    code    : #200#1#225#40;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_LOOPZ;
+    ops     : 2;
+    optypes : (ot_immediate,ot_reg_ecx,ot_none);
+    code    : #201#1#225#40;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_LSL;
+    ops     : 2;
+    optypes : (ot_reg16,ot_memory,ot_none);
+    code    : #208#193#2#15#3#72;
+    flags   : if_286 or if_PRIV or if_SM
+  ),
+  (
+    opcode  : A_LSL;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#193#2#15#3#72;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_LSL;
+    ops     : 2;
+    optypes : (ot_reg32,ot_memory,ot_none);
+    code    : #209#193#2#15#3#72;
+    flags   : if_286 or if_PRIV or if_SM
+  ),
+  (
+    opcode  : A_LSL;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#193#2#15#3#72;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_LSS;
+    ops     : 2;
+    optypes : (ot_reg16,ot_memory,ot_none);
+    code    : #208#193#2#15#178#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_LSS;
+    ops     : 2;
+    optypes : (ot_reg32,ot_memory,ot_none);
+    code    : #209#193#2#15#178#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_LTR;
+    ops     : 1;
+    optypes : (ot_memory,ot_none,ot_none);
+    code    : #192#1#15#15#131;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_LTR;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits16,ot_none,ot_none);
+    code    : #192#1#15#15#131;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_LTR;
+    ops     : 1;
+    optypes : (ot_reg16,ot_none,ot_none);
+    code    : #192#1#15#15#131;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg_cs,ot_none);
+    code    : #208#192#1#140#129;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg_dess,ot_none);
+    code    : #208#192#1#140#65;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg_fsgs,ot_none);
+    code    : #208#192#1#140#65;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg_cs,ot_none);
+    code    : #208#192#1#140#129;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg_dess,ot_none);
+    code    : #208#192#1#140#65;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg_fsgs,ot_none);
+    code    : #208#192#1#140#65;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_reg_cs,ot_none);
+    code    : #209#192#1#140#129;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_reg_dess,ot_none);
+    code    : #209#192#1#140#65;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_reg_fsgs,ot_none);
+    code    : #209#192#1#140#65;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_reg_dess,ot_memory,ot_none);
+    code    : #208#193#1#142#72;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_reg_fsgs,ot_memory,ot_none);
+    code    : #208#193#1#142#72;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_reg_dess,ot_reg16,ot_none);
+    code    : #208#193#1#142#72;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_reg_fsgs,ot_reg16,ot_none);
+    code    : #208#193#1#142#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_reg_dess,ot_regmem or ot_bits32,ot_none);
+    code    : #209#193#1#142#72;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_reg_fsgs,ot_regmem or ot_bits32,ot_none);
+    code    : #209#193#1#142#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_reg_al,ot_mem_offs,ot_none);
+    code    : #193#1#160#29;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_reg_ax,ot_mem_offs,ot_none);
+    code    : #193#208#1#161#29;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_reg_eax,ot_mem_offs,ot_none);
+    code    : #193#209#1#161#29;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_mem_offs,ot_reg_al,ot_none);
+    code    : #192#1#162#28;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_mem_offs,ot_reg_ax,ot_none);
+    code    : #192#208#1#163#28;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_mem_offs,ot_reg_eax,ot_none);
+    code    : #192#209#1#163#28;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg_cr4,ot_none);
+    code    : #2#15#32#132;
+    flags   : if_PENT
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg_creg,ot_none);
+    code    : #2#15#32#65;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg_dreg,ot_none);
+    code    : #2#15#33#65;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg_treg,ot_none);
+    code    : #2#15#36#65;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_reg_cr4,ot_reg32,ot_none);
+    code    : #2#15#34#140;
+    flags   : if_PENT
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_reg_creg,ot_reg32,ot_none);
+    code    : #2#15#34#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_reg_dreg,ot_reg32,ot_none);
+    code    : #2#15#35#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_reg_treg,ot_reg32,ot_none);
+    code    : #2#15#38#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg8,ot_none);
+    code    : #192#1#136#65;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_reg8,ot_reg8,ot_none);
+    code    : #192#1#136#65;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg16,ot_none);
+    code    : #208#192#1#137#65;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#192#1#137#65;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg32,ot_none);
+    code    : #209#192#1#137#65;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#192#1#137#65;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_reg8,ot_memory,ot_none);
+    code    : #193#1#138#72;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_reg8,ot_reg8,ot_none);
+    code    : #193#1#138#72;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_reg16,ot_memory,ot_none);
+    code    : #208#193#1#139#72;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#193#1#139#72;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_reg32,ot_memory,ot_none);
+    code    : #209#193#1#139#72;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#193#1#139#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_reg8,ot_immediate,ot_none);
+    code    : #8#176#17;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_reg16,ot_immediate,ot_none);
+    code    : #208#8#184#25;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_reg32,ot_immediate,ot_none);
+    code    : #209#8#184#33;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_immediate,ot_none);
+    code    : #192#1#198#128#17;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_immediate,ot_none);
+    code    : #208#192#1#199#128#25;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_immediate,ot_none);
+    code    : #209#192#1#199#128#33;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_memory,ot_immediate or ot_bits8,ot_none);
+    code    : #192#1#198#128#17;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_memory,ot_immediate or ot_bits16,ot_none);
+    code    : #208#192#1#199#128#25;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_memory,ot_immediate or ot_bits32,ot_none);
+    code    : #209#192#1#199#128#33;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_MOVD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#110#72;
+    flags   : if_PENT or if_MMX or if_SD
+  ),
+  (
+    opcode  : A_MOVD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_reg32,ot_none);
+    code    : #2#15#110#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_MOVD;
+    ops     : 2;
+    optypes : (ot_memory,ot_mmxreg,ot_none);
+    code    : #192#2#15#126#65;
+    flags   : if_PENT or if_MMX or if_SD
+  ),
+  (
+    opcode  : A_MOVD;
+    ops     : 2;
+    optypes : (ot_reg32,ot_mmxreg,ot_none);
+    code    : #2#15#126#65;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_MOVQ;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#111#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_MOVQ;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#111#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_MOVQ;
+    ops     : 2;
+    optypes : (ot_memory,ot_mmxreg,ot_none);
+    code    : #192#2#15#127#65;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_MOVQ;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#127#65;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_MOVSB;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#164;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_MOVSD;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #209#1#165;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_MOVSW;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #208#1#165;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_MOVSX;
+    ops     : 2;
+    optypes : (ot_reg16,ot_memory,ot_none);
+    code    : #208#193#2#15#190#72;
+    flags   : if_386 or if_SB
+  ),
+  (
+    opcode  : A_MOVSX;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg8,ot_none);
+    code    : #208#193#2#15#190#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_MOVSX;
+    ops     : 2;
+    optypes : (ot_reg32,ot_regmem or ot_bits8,ot_none);
+    code    : #209#193#2#15#190#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_MOVSX;
+    ops     : 2;
+    optypes : (ot_reg32,ot_regmem or ot_bits16,ot_none);
+    code    : #209#193#2#15#191#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_MOVZX;
+    ops     : 2;
+    optypes : (ot_reg16,ot_memory,ot_none);
+    code    : #208#193#2#15#182#72;
+    flags   : if_386 or if_SB
+  ),
+  (
+    opcode  : A_MOVZX;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg8,ot_none);
+    code    : #208#193#2#15#182#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_MOVZX;
+    ops     : 2;
+    optypes : (ot_reg32,ot_regmem or ot_bits8,ot_none);
+    code    : #209#193#2#15#182#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_MOVZX;
+    ops     : 2;
+    optypes : (ot_reg32,ot_regmem or ot_bits16,ot_none);
+    code    : #209#193#2#15#183#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_MUL;
+    ops     : 1;
+    optypes : (ot_regmem or ot_bits8,ot_none,ot_none);
+    code    : #192#1#246#132;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_MUL;
+    ops     : 1;
+    optypes : (ot_regmem or ot_bits16,ot_none,ot_none);
+    code    : #208#192#1#247#132;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_MUL;
+    ops     : 1;
+    optypes : (ot_regmem or ot_bits32,ot_none,ot_none);
+    code    : #209#192#1#247#132;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_NEG;
+    ops     : 1;
+    optypes : (ot_regmem or ot_bits8,ot_none,ot_none);
+    code    : #192#1#246#131;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_NEG;
+    ops     : 1;
+    optypes : (ot_regmem or ot_bits16,ot_none,ot_none);
+    code    : #208#192#1#247#131;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_NEG;
+    ops     : 1;
+    optypes : (ot_regmem or ot_bits32,ot_none,ot_none);
+    code    : #209#192#1#247#131;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_NOP;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#144;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_NOT;
+    ops     : 1;
+    optypes : (ot_regmem or ot_bits8,ot_none,ot_none);
+    code    : #192#1#246#130;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_NOT;
+    ops     : 1;
+    optypes : (ot_regmem or ot_bits16,ot_none,ot_none);
+    code    : #208#192#1#247#130;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_NOT;
+    ops     : 1;
+    optypes : (ot_regmem or ot_bits32,ot_none,ot_none);
+    code    : #209#192#1#247#130;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_OR;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg8,ot_none);
+    code    : #192#1#8#65;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_OR;
+    ops     : 2;
+    optypes : (ot_reg8,ot_reg8,ot_none);
+    code    : #192#1#8#65;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_OR;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg16,ot_none);
+    code    : #208#192#1#9#65;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_OR;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#192#1#9#65;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_OR;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg32,ot_none);
+    code    : #209#192#1#9#65;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_OR;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#192#1#9#65;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_OR;
+    ops     : 2;
+    optypes : (ot_reg8,ot_memory,ot_none);
+    code    : #193#1#10#72;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_OR;
+    ops     : 2;
+    optypes : (ot_reg8,ot_reg8,ot_none);
+    code    : #193#1#10#72;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_OR;
+    ops     : 2;
+    optypes : (ot_reg16,ot_memory,ot_none);
+    code    : #208#193#1#11#72;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_OR;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#193#1#11#72;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_OR;
+    ops     : 2;
+    optypes : (ot_reg32,ot_memory,ot_none);
+    code    : #209#193#1#11#72;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_OR;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#193#1#11#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_OR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_immediate or ot_bits8 or ot_signed,ot_none);
+    code    : #208#192#1#131#129#13;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_OR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_immediate or ot_bits8 or ot_signed,ot_none);
+    code    : #209#192#1#131#129#13;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_OR;
+    ops     : 2;
+    optypes : (ot_reg_al,ot_immediate,ot_none);
+    code    : #1#12#17;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_OR;
+    ops     : 2;
+    optypes : (ot_reg_ax,ot_immediate,ot_none);
+    code    : #208#1#13#25;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_OR;
+    ops     : 2;
+    optypes : (ot_reg_eax,ot_immediate,ot_none);
+    code    : #209#1#13#33;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_OR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_immediate,ot_none);
+    code    : #192#1#128#129#17;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_OR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_immediate,ot_none);
+    code    : #208#192#1#129#129#25;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_OR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_immediate,ot_none);
+    code    : #209#192#1#129#129#33;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_OR;
+    ops     : 2;
+    optypes : (ot_memory,ot_immediate or ot_bits8,ot_none);
+    code    : #192#1#128#129#17;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_OR;
+    ops     : 2;
+    optypes : (ot_memory,ot_immediate or ot_bits16,ot_none);
+    code    : #208#192#1#129#129#25;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_OR;
+    ops     : 2;
+    optypes : (ot_memory,ot_immediate or ot_bits32,ot_none);
+    code    : #209#192#1#129#129#33;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_OUT;
+    ops     : 2;
+    optypes : (ot_immediate,ot_reg_al,ot_none);
+    code    : #1#230#20;
+    flags   : if_8086 or if_SB
+  ),
+  (
+    opcode  : A_OUT;
+    ops     : 2;
+    optypes : (ot_immediate,ot_reg_ax,ot_none);
+    code    : #208#1#231#20;
+    flags   : if_8086 or if_SB
+  ),
+  (
+    opcode  : A_OUT;
+    ops     : 2;
+    optypes : (ot_immediate,ot_reg_eax,ot_none);
+    code    : #209#1#231#20;
+    flags   : if_386 or if_SB
+  ),
+  (
+    opcode  : A_OUT;
+    ops     : 2;
+    optypes : (ot_reg_dx,ot_reg_al,ot_none);
+    code    : #1#238;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_OUT;
+    ops     : 2;
+    optypes : (ot_reg_dx,ot_reg_ax,ot_none);
+    code    : #208#1#239;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_OUT;
+    ops     : 2;
+    optypes : (ot_reg_dx,ot_reg_eax,ot_none);
+    code    : #209#1#239;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_OUTSB;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#110;
+    flags   : if_186
+  ),
+  (
+    opcode  : A_OUTSD;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #209#1#111;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_OUTSW;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #208#1#111;
+    flags   : if_186
+  ),
+  (
+    opcode  : A_PACKSSDW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#107#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PACKSSDW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#107#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PACKSSWB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#99#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PACKSSWB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#99#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PACKUSWB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#103#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PACKUSWB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#103#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PADDB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#252#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PADDB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#252#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PADDD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#254#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PADDD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#254#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PADDSB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#236#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PADDSB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#236#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PADDSIW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#81#72;
+    flags   : if_PENT or if_MMX or if_SM or if_CYRIX
+  ),
+  (
+    opcode  : A_PADDSIW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#81#72;
+    flags   : if_PENT or if_MMX or if_CYRIX
+  ),
+  (
+    opcode  : A_PADDSW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#237#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PADDSW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#237#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PADDUSB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#220#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PADDUSB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#220#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PADDUSW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#221#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PADDUSW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#221#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PADDW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#253#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PADDW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#253#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PAND;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#219#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PAND;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#219#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PANDN;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#223#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PANDN;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#223#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PAVEB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#80#72;
+    flags   : if_PENT or if_MMX or if_SM or if_CYRIX
+  ),
+  (
+    opcode  : A_PAVEB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#80#72;
+    flags   : if_PENT or if_MMX or if_CYRIX
+  ),
+  (
+    opcode  : A_PAVGUSB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#15#72#1#191;
+    flags   : if_PENT or if_MMX or if_SM or if_FPU
+  ),
+  (
+    opcode  : A_PAVGUSB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#15#72#1#191;
+    flags   : if_PENT or if_MMX or if_FPU
+  ),
+  (
+    opcode  : A_PCMPEQB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#116#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PCMPEQB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#116#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PCMPEQD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#118#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PCMPEQD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#118#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PCMPEQW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#117#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PCMPEQW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#117#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PCMPGTB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#100#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PCMPGTB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#100#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PCMPGTD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#102#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PCMPGTD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#102#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PCMPGTW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#101#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PCMPGTW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#101#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PDISTIB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#84#72;
+    flags   : if_PENT or if_MMX or if_SM or if_CYRIX
+  ),
+  (
+    opcode  : A_PF2ID;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#15#72#1#29;
+    flags   : if_PENT or if_MMX or if_SM or if_FPU
+  ),
+  (
+    opcode  : A_PF2ID;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#15#72#1#29;
+    flags   : if_PENT or if_MMX or if_FPU
+  ),
+  (
+    opcode  : A_PFACC;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#15#72#1#174;
+    flags   : if_PENT or if_MMX or if_SM or if_FPU
+  ),
+  (
+    opcode  : A_PFACC;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#15#72#1#174;
+    flags   : if_PENT or if_MMX or if_FPU
+  ),
+  (
+    opcode  : A_PFADD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#15#72#1#158;
+    flags   : if_PENT or if_MMX or if_SM or if_FPU
+  ),
+  (
+    opcode  : A_PFADD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#15#72#1#158;
+    flags   : if_PENT or if_MMX or if_FPU
+  ),
+  (
+    opcode  : A_PFCMPEQ;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#15#72#1#176;
+    flags   : if_PENT or if_MMX or if_SM or if_FPU
+  ),
+  (
+    opcode  : A_PFCMPEQ;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#15#72#1#176;
+    flags   : if_PENT or if_MMX or if_FPU
+  ),
+  (
+    opcode  : A_PFCMPGE;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#15#72#1#144;
+    flags   : if_PENT or if_MMX or if_SM or if_FPU
+  ),
+  (
+    opcode  : A_PFCMPGE;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#15#72#1#144;
+    flags   : if_PENT or if_MMX or if_FPU
+  ),
+  (
+    opcode  : A_PFCMPGT;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#15#72#1#160;
+    flags   : if_PENT or if_MMX or if_SM or if_FPU
+  ),
+  (
+    opcode  : A_PFCMPGT;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#15#72#1#160;
+    flags   : if_PENT or if_MMX or if_FPU
+  ),
+  (
+    opcode  : A_PFMAX;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#15#72#1#164;
+    flags   : if_PENT or if_MMX or if_SM or if_FPU
+  ),
+  (
+    opcode  : A_PFMAX;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#15#72#1#164;
+    flags   : if_PENT or if_MMX or if_FPU
+  ),
+  (
+    opcode  : A_PFMIN;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#15#72#1#148;
+    flags   : if_PENT or if_MMX or if_SM or if_FPU
+  ),
+  (
+    opcode  : A_PFMIN;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#15#72#1#148;
+    flags   : if_PENT or if_MMX or if_FPU
+  ),
+  (
+    opcode  : A_PFMUL;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#15#72#1#180;
+    flags   : if_PENT or if_MMX or if_SM or if_FPU
+  ),
+  (
+    opcode  : A_PFMUL;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#15#72#1#180;
+    flags   : if_PENT or if_MMX or if_FPU
+  ),
+  (
+    opcode  : A_PFRCP;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#15#72#1#150;
+    flags   : if_PENT or if_MMX or if_SM or if_FPU
+  ),
+  (
+    opcode  : A_PFRCP;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#15#72#1#150;
+    flags   : if_PENT or if_MMX or if_FPU
+  ),
+  (
+    opcode  : A_PFRCPIT1;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#15#72#1#166;
+    flags   : if_PENT or if_MMX or if_SM or if_FPU
+  ),
+  (
+    opcode  : A_PFRCPIT1;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#15#72#1#166;
+    flags   : if_PENT or if_MMX or if_FPU
+  ),
+  (
+    opcode  : A_PFRCPIT2;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#15#72#1#182;
+    flags   : if_PENT or if_MMX or if_SM or if_FPU
+  ),
+  (
+    opcode  : A_PFRCPIT2;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#15#72#1#182;
+    flags   : if_PENT or if_MMX or if_FPU
+  ),
+  (
+    opcode  : A_PFRSQIT1;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#15#72#1#167;
+    flags   : if_PENT or if_MMX or if_SM or if_FPU
+  ),
+  (
+    opcode  : A_PFRSQIT1;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#15#72#1#167;
+    flags   : if_PENT or if_MMX or if_FPU
+  ),
+  (
+    opcode  : A_PFRSQRT;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#15#72#1#151;
+    flags   : if_PENT or if_MMX or if_SM or if_FPU
+  ),
+  (
+    opcode  : A_PFRSQRT;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#15#72#1#151;
+    flags   : if_PENT or if_MMX or if_FPU
+  ),
+  (
+    opcode  : A_PFSUB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#15#72#1#154;
+    flags   : if_PENT or if_MMX or if_SM or if_FPU
+  ),
+  (
+    opcode  : A_PFSUB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#15#72#1#154;
+    flags   : if_PENT or if_MMX or if_FPU
+  ),
+  (
+    opcode  : A_PFSUBR;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#15#72#1#170;
+    flags   : if_PENT or if_MMX or if_SM or if_FPU
+  ),
+  (
+    opcode  : A_PFSUBR;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#15#72#1#170;
+    flags   : if_PENT or if_MMX or if_FPU
+  ),
+  (
+    opcode  : A_PI2FD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#15#72#1#13;
+    flags   : if_PENT or if_MMX or if_SM or if_FPU
+  ),
+  (
+    opcode  : A_PI2FD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#15#72#1#13;
+    flags   : if_PENT or if_MMX or if_FPU
+  ),
+  (
+    opcode  : A_PMACHRIW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#94#72;
+    flags   : if_PENT or if_MMX or if_SM or if_CYRIX
+  ),
+  (
+    opcode  : A_PMADDWD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#245#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PMADDWD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#245#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PMAGW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#82#72;
+    flags   : if_PENT or if_MMX or if_SM or if_CYRIX
+  ),
+  (
+    opcode  : A_PMAGW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#82#72;
+    flags   : if_PENT or if_MMX or if_CYRIX
+  ),
+  (
+    opcode  : A_PMULHRIW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#93#72;
+    flags   : if_PENT or if_MMX or if_SM or if_CYRIX
+  ),
+  (
+    opcode  : A_PMULHRIW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#93#72;
+    flags   : if_PENT or if_MMX or if_CYRIX
+  ),
+  (
+    opcode  : A_PMULHRWA;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#15#72#1#183;
+    flags   : if_PENT or if_MMX or if_SM or if_FPU
+  ),
+  (
+    opcode  : A_PMULHRWA;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#15#72#1#183;
+    flags   : if_PENT or if_MMX or if_FPU
+  ),
+  (
+    opcode  : A_PMULHRWC;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#89#72;
+    flags   : if_PENT or if_MMX or if_SM or if_CYRIX
+  ),
+  (
+    opcode  : A_PMULHRWC;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#89#72;
+    flags   : if_PENT or if_MMX or if_CYRIX
+  ),
+  (
+    opcode  : A_PMULHW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#229#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PMULHW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#229#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PMULLW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#213#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PMULLW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#213#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PMVGEZB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#92#72;
+    flags   : if_PENT or if_MMX or if_SM or if_CYRIX
+  ),
+  (
+    opcode  : A_PMVLZB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#91#72;
+    flags   : if_PENT or if_MMX or if_SM or if_CYRIX
+  ),
+  (
+    opcode  : A_PMVNZB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#90#72;
+    flags   : if_PENT or if_MMX or if_SM or if_CYRIX
+  ),
+  (
+    opcode  : A_PMVZB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#88#72;
+    flags   : if_PENT or if_MMX or if_SM or if_CYRIX
+  ),
+  (
+    opcode  : A_POP;
+    ops     : 1;
+    optypes : (ot_reg16,ot_none,ot_none);
+    code    : #208#8#88;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_POP;
+    ops     : 1;
+    optypes : (ot_reg32,ot_none,ot_none);
+    code    : #209#8#88;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_POP;
+    ops     : 1;
+    optypes : (ot_regmem or ot_bits16,ot_none,ot_none);
+    code    : #208#192#1#143#128;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_POP;
+    ops     : 1;
+    optypes : (ot_regmem or ot_bits32,ot_none,ot_none);
+    code    : #209#192#1#143#128;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_POP;
+    ops     : 1;
+    optypes : (ot_reg_cs,ot_none,ot_none);
+    code    : #1#15;
+    flags   : if_8086 or if_UNDOC
+  ),
+  (
+    opcode  : A_POP;
+    ops     : 1;
+    optypes : (ot_reg_dess,ot_none,ot_none);
+    code    : #4;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_POP;
+    ops     : 1;
+    optypes : (ot_reg_fsgs,ot_none,ot_none);
+    code    : #1#15#5;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_POPA;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #210#1#97;
+    flags   : if_186
+  ),
+  (
+    opcode  : A_POPAD;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #209#1#97;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_POPAW;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #208#1#97;
+    flags   : if_186
+  ),
+  (
+    opcode  : A_POPF;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #210#1#157;
+    flags   : if_186
+  ),
+  (
+    opcode  : A_POPFD;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #209#1#157;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_POPFW;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #208#1#157;
+    flags   : if_186
+  ),
+  (
+    opcode  : A_POR;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#235#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_POR;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#235#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PREFETCH;
+    ops     : 1;
+    optypes : (ot_memory,ot_none or ot_signed,ot_none);
+    code    : #2#15#13#128;
+    flags   : if_PENT or if_MMX or if_SM or if_FPU
+  ),
+  (
+    opcode  : A_PREFETCHW;
+    ops     : 1;
+    optypes : (ot_memory,ot_none or ot_signed,ot_none);
+    code    : #2#15#13#129;
+    flags   : if_PENT or if_MMX or if_SM or if_FPU
+  ),
+  (
+    opcode  : A_PSLLD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#242#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PSLLD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#242#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PSLLD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_immediate,ot_none);
+    code    : #2#15#114#134#21;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PSLLQ;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#243#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PSLLQ;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#243#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PSLLQ;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_immediate,ot_none);
+    code    : #2#15#115#134#21;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PSLLW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#241#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PSLLW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#241#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PSLLW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_immediate,ot_none);
+    code    : #2#15#113#134#21;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PSRAD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#226#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PSRAD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#226#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PSRAD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_immediate,ot_none);
+    code    : #2#15#114#132#21;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PSRAW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#225#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PSRAW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#225#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PSRAW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_immediate,ot_none);
+    code    : #2#15#113#132#21;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PSRLD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#210#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PSRLD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#210#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PSRLD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_immediate,ot_none);
+    code    : #2#15#114#130#21;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PSRLQ;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#211#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PSRLQ;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#211#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PSRLQ;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_immediate,ot_none);
+    code    : #2#15#115#130#21;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PSRLW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#209#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PSRLW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#209#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PSRLW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_immediate,ot_none);
+    code    : #2#15#113#130#21;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PSUBB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#248#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PSUBB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#248#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PSUBD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#250#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PSUBD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#250#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PSUBSB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#232#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PSUBSB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#232#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PSUBSIW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#85#72;
+    flags   : if_PENT or if_MMX or if_SM or if_CYRIX
+  ),
+  (
+    opcode  : A_PSUBSIW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#85#72;
+    flags   : if_PENT or if_MMX or if_CYRIX
+  ),
+  (
+    opcode  : A_PSUBSW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#233#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PSUBSW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#233#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PSUBUSB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#216#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PSUBUSB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#216#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PSUBUSW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#217#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PSUBUSW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#217#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PSUBW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#249#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PSUBW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#249#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PUNPCKHBW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#104#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PUNPCKHBW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#104#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PUNPCKHDQ;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#106#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PUNPCKHDQ;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#106#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PUNPCKHWD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#105#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PUNPCKHWD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#105#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PUNPCKLBW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#96#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PUNPCKLBW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#96#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PUNPCKLDQ;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#98#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PUNPCKLDQ;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#98#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PUNPCKLWD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#97#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PUNPCKLWD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#97#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_PUSH;
+    ops     : 1;
+    optypes : (ot_reg16,ot_none,ot_none);
+    code    : #208#8#80;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_PUSH;
+    ops     : 1;
+    optypes : (ot_reg32,ot_none,ot_none);
+    code    : #209#8#80;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_PUSH;
+    ops     : 1;
+    optypes : (ot_regmem or ot_bits16,ot_none,ot_none);
+    code    : #208#192#1#255#134;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_PUSH;
+    ops     : 1;
+    optypes : (ot_regmem or ot_bits32,ot_none,ot_none);
+    code    : #209#192#1#255#134;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_PUSH;
+    ops     : 1;
+    optypes : (ot_reg_fsgs,ot_none,ot_none);
+    code    : #1#15#7;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_PUSH;
+    ops     : 1;
+    optypes : (ot_reg_sreg,ot_none,ot_none);
+    code    : #6;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_PUSH;
+    ops     : 1;
+    optypes : (ot_immediate or ot_bits8 or ot_signed,ot_none,ot_none);
+    code    : #1#106#12;
+    flags   : if_286
+  ),
+  (
+    opcode  : A_PUSH;
+    ops     : 1;
+    optypes : (ot_immediate or ot_bits16,ot_none,ot_none);
+    code    : #208#1#104#24;
+    flags   : if_286
+  ),
+  (
+    opcode  : A_PUSH;
+    ops     : 1;
+    optypes : (ot_immediate or ot_bits32,ot_none,ot_none);
+    code    : #209#1#104#32;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_PUSHA;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #210#1#96;
+    flags   : if_186
+  ),
+  (
+    opcode  : A_PUSHAD;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #209#1#96;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_PUSHAW;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #208#1#96;
+    flags   : if_186
+  ),
+  (
+    opcode  : A_PUSHF;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #210#1#156;
+    flags   : if_186
+  ),
+  (
+    opcode  : A_PUSHFD;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #209#1#156;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_PUSHFW;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #208#1#156;
+    flags   : if_186
+  ),
+  (
+    opcode  : A_PXOR;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#2#15#239#72;
+    flags   : if_PENT or if_MMX or if_SM
+  ),
+  (
+    opcode  : A_PXOR;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #2#15#239#72;
+    flags   : if_PENT or if_MMX
+  ),
+  (
+    opcode  : A_RCL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_unity,ot_none);
+    code    : #192#1#208#130;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_RCL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_reg_cl,ot_none);
+    code    : #192#1#210#130;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_RCL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_immediate,ot_none);
+    code    : #192#1#192#130#21;
+    flags   : if_186 or if_SB
+  ),
+  (
+    opcode  : A_RCL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_unity,ot_none);
+    code    : #208#192#1#209#130;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_RCL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_reg_cl,ot_none);
+    code    : #208#192#1#211#130;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_RCL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_immediate,ot_none);
+    code    : #208#192#1#193#130#21;
+    flags   : if_186 or if_SB
+  ),
+  (
+    opcode  : A_RCL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_unity,ot_none);
+    code    : #209#192#1#209#130;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_RCL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_reg_cl,ot_none);
+    code    : #209#192#1#211#130;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_RCL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_immediate,ot_none);
+    code    : #209#192#1#193#130#21;
+    flags   : if_386 or if_SB
+  ),
+  (
+    opcode  : A_RCR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_unity,ot_none);
+    code    : #192#1#208#131;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_RCR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_reg_cl,ot_none);
+    code    : #192#1#210#131;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_RCR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_immediate,ot_none);
+    code    : #192#1#192#131#21;
+    flags   : if_186 or if_SB
+  ),
+  (
+    opcode  : A_RCR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_unity,ot_none);
+    code    : #208#192#1#209#131;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_RCR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_reg_cl,ot_none);
+    code    : #208#192#1#211#131;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_RCR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_immediate,ot_none);
+    code    : #208#192#1#193#131#21;
+    flags   : if_186 or if_SB
+  ),
+  (
+    opcode  : A_RCR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_unity,ot_none);
+    code    : #209#192#1#209#131;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_RCR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_reg_cl,ot_none);
+    code    : #209#192#1#211#131;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_RCR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_immediate,ot_none);
+    code    : #209#192#1#193#131#21;
+    flags   : if_386 or if_SB
+  ),
+  (
+    opcode  : A_RDMSR;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#15#50;
+    flags   : if_PENT
+  ),
+  (
+    opcode  : A_RDPMC;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#15#51;
+    flags   : if_P6
+  ),
+  (
+    opcode  : A_RDTSC;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#15#49;
+    flags   : if_PENT
+  ),
+  (
+    opcode  : A_REP;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#243;
+    flags   : if_8086 or if_PRE
+  ),
+  (
+    opcode  : A_REPE;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#243;
+    flags   : if_8086 or if_PRE
+  ),
+  (
+    opcode  : A_REPNE;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#242;
+    flags   : if_8086 or if_PRE
+  ),
+  (
+    opcode  : A_REPNZ;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#242;
+    flags   : if_8086 or if_PRE
+  ),
+  (
+    opcode  : A_REPZ;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#243;
+    flags   : if_8086 or if_PRE
+  ),
+  (
+    opcode  : A_RESB;
+    ops     : 1;
+    optypes : (ot_immediate,ot_none,ot_none);
+    code    : #224;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_RET;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#195;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_RET;
+    ops     : 1;
+    optypes : (ot_immediate,ot_none,ot_none);
+    code    : #1#194#24;
+    flags   : if_8086 or if_SW
+  ),
+  (
+    opcode  : A_RETF;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#203;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_RETF;
+    ops     : 1;
+    optypes : (ot_immediate,ot_none,ot_none);
+    code    : #1#202#24;
+    flags   : if_8086 or if_SW
+  ),
+  (
+    opcode  : A_RETN;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#195;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_RETN;
+    ops     : 1;
+    optypes : (ot_immediate,ot_none,ot_none);
+    code    : #1#194#24;
+    flags   : if_8086 or if_SW
+  ),
+  (
+    opcode  : A_ROL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_unity,ot_none);
+    code    : #192#1#208#128;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_ROL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_reg_cl,ot_none);
+    code    : #192#1#210#128;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_ROL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_immediate,ot_none);
+    code    : #192#1#192#128#21;
+    flags   : if_186 or if_SB
+  ),
+  (
+    opcode  : A_ROL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_unity,ot_none);
+    code    : #208#192#1#209#128;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_ROL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_reg_cl,ot_none);
+    code    : #208#192#1#211#128;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_ROL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_immediate,ot_none);
+    code    : #208#192#1#193#128#21;
+    flags   : if_186 or if_SB
+  ),
+  (
+    opcode  : A_ROL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_unity,ot_none);
+    code    : #209#192#1#209#128;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_ROL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_reg_cl,ot_none);
+    code    : #209#192#1#211#128;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_ROL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_immediate,ot_none);
+    code    : #209#192#1#193#128#21;
+    flags   : if_386 or if_SB
+  ),
+  (
+    opcode  : A_ROR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_unity,ot_none);
+    code    : #192#1#208#129;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_ROR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_reg_cl,ot_none);
+    code    : #192#1#210#129;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_ROR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_immediate,ot_none);
+    code    : #192#1#192#129#21;
+    flags   : if_186 or if_SB
+  ),
+  (
+    opcode  : A_ROR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_unity,ot_none);
+    code    : #208#192#1#209#129;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_ROR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_reg_cl,ot_none);
+    code    : #208#192#1#211#129;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_ROR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_immediate,ot_none);
+    code    : #208#192#1#193#129#21;
+    flags   : if_186 or if_SB
+  ),
+  (
+    opcode  : A_ROR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_unity,ot_none);
+    code    : #209#192#1#209#129;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_ROR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_reg_cl,ot_none);
+    code    : #209#192#1#211#129;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_ROR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_immediate,ot_none);
+    code    : #209#192#1#193#129#21;
+    flags   : if_386 or if_SB
+  ),
+  (
+    opcode  : A_RSM;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#15#170;
+    flags   : if_PENT
+  ),
+  (
+    opcode  : A_SAHF;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#158;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_SAL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_unity,ot_none);
+    code    : #192#1#208#132;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_SAL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_reg_cl,ot_none);
+    code    : #192#1#210#132;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_SAL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_immediate,ot_none);
+    code    : #192#1#192#132#21;
+    flags   : if_186 or if_SB
+  ),
+  (
+    opcode  : A_SAL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_unity,ot_none);
+    code    : #208#192#1#209#132;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_SAL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_reg_cl,ot_none);
+    code    : #208#192#1#211#132;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_SAL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_immediate,ot_none);
+    code    : #208#192#1#193#132#21;
+    flags   : if_186 or if_SB
+  ),
+  (
+    opcode  : A_SAL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_unity,ot_none);
+    code    : #209#192#1#209#132;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_SAL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_reg_cl,ot_none);
+    code    : #209#192#1#211#132;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_SAL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_immediate,ot_none);
+    code    : #209#192#1#193#132#21;
+    flags   : if_386 or if_SB
+  ),
+  (
+    opcode  : A_SALC;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#214;
+    flags   : if_8086 or if_UNDOC
+  ),
+  (
+    opcode  : A_SAR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_unity,ot_none);
+    code    : #192#1#208#135;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_SAR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_reg_cl,ot_none);
+    code    : #192#1#210#135;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_SAR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_immediate,ot_none);
+    code    : #192#1#192#135#21;
+    flags   : if_186 or if_SB
+  ),
+  (
+    opcode  : A_SAR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_unity,ot_none);
+    code    : #208#192#1#209#135;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_SAR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_reg_cl,ot_none);
+    code    : #208#192#1#211#135;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_SAR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_immediate,ot_none);
+    code    : #208#192#1#193#135#21;
+    flags   : if_186 or if_SB
+  ),
+  (
+    opcode  : A_SAR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_unity,ot_none);
+    code    : #209#192#1#209#135;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_SAR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_reg_cl,ot_none);
+    code    : #209#192#1#211#135;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_SAR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_immediate,ot_none);
+    code    : #209#192#1#193#135#21;
+    flags   : if_386 or if_SB
+  ),
+  (
+    opcode  : A_SBB;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg8,ot_none);
+    code    : #192#1#24#65;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_SBB;
+    ops     : 2;
+    optypes : (ot_reg8,ot_reg8,ot_none);
+    code    : #192#1#24#65;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_SBB;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg16,ot_none);
+    code    : #208#192#1#25#65;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_SBB;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#192#1#25#65;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_SBB;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg32,ot_none);
+    code    : #209#192#1#25#65;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_SBB;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#192#1#25#65;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_SBB;
+    ops     : 2;
+    optypes : (ot_reg8,ot_memory,ot_none);
+    code    : #193#1#26#72;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_SBB;
+    ops     : 2;
+    optypes : (ot_reg8,ot_reg8,ot_none);
+    code    : #193#1#26#72;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_SBB;
+    ops     : 2;
+    optypes : (ot_reg16,ot_memory,ot_none);
+    code    : #208#193#1#27#72;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_SBB;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#193#1#27#72;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_SBB;
+    ops     : 2;
+    optypes : (ot_reg32,ot_memory,ot_none);
+    code    : #209#193#1#27#72;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_SBB;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#193#1#27#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_SBB;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_immediate or ot_bits8 or ot_signed,ot_none);
+    code    : #208#192#1#131#131#13;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_SBB;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_immediate or ot_bits8 or ot_signed,ot_none);
+    code    : #209#192#1#131#131#13;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_SBB;
+    ops     : 2;
+    optypes : (ot_reg_al,ot_immediate,ot_none);
+    code    : #1#28#17;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_SBB;
+    ops     : 2;
+    optypes : (ot_reg_ax,ot_immediate,ot_none);
+    code    : #208#1#29#25;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_SBB;
+    ops     : 2;
+    optypes : (ot_reg_eax,ot_immediate,ot_none);
+    code    : #209#1#29#33;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_SBB;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_immediate,ot_none);
+    code    : #192#1#128#131#17;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_SBB;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_immediate,ot_none);
+    code    : #208#192#1#129#131#25;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_SBB;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_immediate,ot_none);
+    code    : #209#192#1#129#131#33;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_SBB;
+    ops     : 2;
+    optypes : (ot_memory,ot_immediate or ot_bits8,ot_none);
+    code    : #192#1#128#131#17;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_SBB;
+    ops     : 2;
+    optypes : (ot_memory,ot_immediate or ot_bits16,ot_none);
+    code    : #208#192#1#129#131#25;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_SBB;
+    ops     : 2;
+    optypes : (ot_memory,ot_immediate or ot_bits32,ot_none);
+    code    : #209#192#1#129#131#33;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_SCASB;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#174;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_SCASD;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #209#1#175;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_SCASW;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #208#1#175;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_SGDT;
+    ops     : 1;
+    optypes : (ot_memory,ot_none,ot_none);
+    code    : #192#2#15#1#128;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_SHL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_unity,ot_none);
+    code    : #192#1#208#132;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_SHL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_reg_cl,ot_none);
+    code    : #192#1#210#132;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_SHL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_immediate,ot_none);
+    code    : #192#1#192#132#21;
+    flags   : if_186 or if_SB
+  ),
+  (
+    opcode  : A_SHL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_unity,ot_none);
+    code    : #208#192#1#209#132;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_SHL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_reg_cl,ot_none);
+    code    : #208#192#1#211#132;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_SHL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_immediate,ot_none);
+    code    : #208#192#1#193#132#21;
+    flags   : if_186 or if_SB
+  ),
+  (
+    opcode  : A_SHL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_unity,ot_none);
+    code    : #209#192#1#209#132;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_SHL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_reg_cl,ot_none);
+    code    : #209#192#1#211#132;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_SHL;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_immediate,ot_none);
+    code    : #209#192#1#193#132#21;
+    flags   : if_386 or if_SB
+  ),
+  (
+    opcode  : A_SHLD;
+    ops     : 3;
+    optypes : (ot_memory,ot_reg16,ot_immediate);
+    code    : #192#208#2#15#164#65#22;
+    flags   : if_386 or if_SM2
+  ),
+  (
+    opcode  : A_SHLD;
+    ops     : 3;
+    optypes : (ot_reg16,ot_reg16,ot_immediate);
+    code    : #192#208#2#15#164#65#22;
+    flags   : if_386 or if_SM2
+  ),
+  (
+    opcode  : A_SHLD;
+    ops     : 3;
+    optypes : (ot_memory,ot_reg32,ot_immediate);
+    code    : #192#209#2#15#164#65#22;
+    flags   : if_386 or if_SM2
+  ),
+  (
+    opcode  : A_SHLD;
+    ops     : 3;
+    optypes : (ot_reg32,ot_reg32,ot_immediate);
+    code    : #192#209#2#15#164#65#22;
+    flags   : if_386 or if_SM2
+  ),
+  (
+    opcode  : A_SHLD;
+    ops     : 3;
+    optypes : (ot_memory,ot_reg16,ot_reg_cl);
+    code    : #192#208#2#15#165#65;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_SHLD;
+    ops     : 3;
+    optypes : (ot_reg16,ot_reg16,ot_reg_cl);
+    code    : #192#208#2#15#165#65;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_SHLD;
+    ops     : 3;
+    optypes : (ot_memory,ot_reg32,ot_reg_cl);
+    code    : #192#209#2#15#165#65;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_SHLD;
+    ops     : 3;
+    optypes : (ot_reg32,ot_reg32,ot_reg_cl);
+    code    : #192#209#2#15#165#65;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_SHR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_unity,ot_none);
+    code    : #192#1#208#133;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_SHR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_reg_cl,ot_none);
+    code    : #192#1#210#133;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_SHR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_immediate,ot_none);
+    code    : #192#1#192#133#21;
+    flags   : if_186 or if_SB
+  ),
+  (
+    opcode  : A_SHR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_unity,ot_none);
+    code    : #208#192#1#209#133;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_SHR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_reg_cl,ot_none);
+    code    : #208#192#1#211#133;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_SHR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_immediate,ot_none);
+    code    : #208#192#1#193#133#21;
+    flags   : if_186 or if_SB
+  ),
+  (
+    opcode  : A_SHR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_unity,ot_none);
+    code    : #209#192#1#209#133;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_SHR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_reg_cl,ot_none);
+    code    : #209#192#1#211#133;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_SHR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_immediate,ot_none);
+    code    : #209#192#1#193#133#21;
+    flags   : if_386 or if_SB
+  ),
+  (
+    opcode  : A_SHRD;
+    ops     : 3;
+    optypes : (ot_memory,ot_reg16,ot_immediate);
+    code    : #192#208#2#15#172#65#22;
+    flags   : if_386 or if_SM2
+  ),
+  (
+    opcode  : A_SHRD;
+    ops     : 3;
+    optypes : (ot_reg16,ot_reg16,ot_immediate);
+    code    : #192#208#2#15#172#65#22;
+    flags   : if_386 or if_SM2
+  ),
+  (
+    opcode  : A_SHRD;
+    ops     : 3;
+    optypes : (ot_memory,ot_reg32,ot_immediate);
+    code    : #192#209#2#15#172#65#22;
+    flags   : if_386 or if_SM2
+  ),
+  (
+    opcode  : A_SHRD;
+    ops     : 3;
+    optypes : (ot_reg32,ot_reg32,ot_immediate);
+    code    : #192#209#2#15#172#65#22;
+    flags   : if_386 or if_SM2
+  ),
+  (
+    opcode  : A_SHRD;
+    ops     : 3;
+    optypes : (ot_memory,ot_reg16,ot_reg_cl);
+    code    : #192#208#2#15#173#65;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_SHRD;
+    ops     : 3;
+    optypes : (ot_reg16,ot_reg16,ot_reg_cl);
+    code    : #192#208#2#15#173#65;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_SHRD;
+    ops     : 3;
+    optypes : (ot_memory,ot_reg32,ot_reg_cl);
+    code    : #192#209#2#15#173#65;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_SHRD;
+    ops     : 3;
+    optypes : (ot_reg32,ot_reg32,ot_reg_cl);
+    code    : #192#209#2#15#173#65;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_SIDT;
+    ops     : 1;
+    optypes : (ot_memory,ot_none,ot_none);
+    code    : #192#2#15#1#129;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_SLDT;
+    ops     : 1;
+    optypes : (ot_memory,ot_none,ot_none);
+    code    : #192#1#15#15#128;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_SLDT;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits16,ot_none,ot_none);
+    code    : #192#1#15#15#128;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_SLDT;
+    ops     : 1;
+    optypes : (ot_reg16,ot_none,ot_none);
+    code    : #192#1#15#15#128;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_SMI;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#241;
+    flags   : if_386 or if_UNDOC
+  ),
+  (
+    opcode  : A_SMSW;
+    ops     : 1;
+    optypes : (ot_memory,ot_none,ot_none);
+    code    : #192#2#15#1#132;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_SMSW;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits16,ot_none,ot_none);
+    code    : #192#2#15#1#132;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_SMSW;
+    ops     : 1;
+    optypes : (ot_reg16,ot_none,ot_none);
+    code    : #192#2#15#1#132;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_SS;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#54;
+    flags   : if_8086 or if_PRE
+  ),
+  (
+    opcode  : A_STC;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#249;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_STD;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#253;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_STI;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#251;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_STOSB;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#170;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_STOSD;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #209#1#171;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_STOSW;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #208#1#171;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_STR;
+    ops     : 1;
+    optypes : (ot_memory,ot_none,ot_none);
+    code    : #192#1#15#15#129;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_STR;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits16,ot_none,ot_none);
+    code    : #192#1#15#15#129;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_STR;
+    ops     : 1;
+    optypes : (ot_reg16,ot_none,ot_none);
+    code    : #192#1#15#15#129;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_SUB;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg8,ot_none);
+    code    : #192#1#40#65;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_SUB;
+    ops     : 2;
+    optypes : (ot_reg8,ot_reg8,ot_none);
+    code    : #192#1#40#65;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_SUB;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg16,ot_none);
+    code    : #208#192#1#41#65;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_SUB;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#192#1#41#65;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_SUB;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg32,ot_none);
+    code    : #209#192#1#41#65;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_SUB;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#192#1#41#65;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_SUB;
+    ops     : 2;
+    optypes : (ot_reg8,ot_memory,ot_none);
+    code    : #193#1#42#72;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_SUB;
+    ops     : 2;
+    optypes : (ot_reg8,ot_reg8,ot_none);
+    code    : #193#1#42#72;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_SUB;
+    ops     : 2;
+    optypes : (ot_reg16,ot_memory,ot_none);
+    code    : #208#193#1#43#72;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_SUB;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#193#1#43#72;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_SUB;
+    ops     : 2;
+    optypes : (ot_reg32,ot_memory,ot_none);
+    code    : #209#193#1#43#72;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_SUB;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#193#1#43#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_SUB;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_immediate or ot_bits8 or ot_signed,ot_none);
+    code    : #208#192#1#131#133#13;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_SUB;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_immediate or ot_bits8 or ot_signed,ot_none);
+    code    : #209#192#1#131#133#13;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_SUB;
+    ops     : 2;
+    optypes : (ot_reg_al,ot_immediate,ot_none);
+    code    : #1#44#17;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_SUB;
+    ops     : 2;
+    optypes : (ot_reg_ax,ot_immediate,ot_none);
+    code    : #208#1#45#25;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_SUB;
+    ops     : 2;
+    optypes : (ot_reg_eax,ot_immediate,ot_none);
+    code    : #209#1#45#33;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_SUB;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_immediate,ot_none);
+    code    : #192#1#128#133#17;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_SUB;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_immediate,ot_none);
+    code    : #208#192#1#129#133#25;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_SUB;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_immediate,ot_none);
+    code    : #209#192#1#129#133#33;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_SUB;
+    ops     : 2;
+    optypes : (ot_memory,ot_immediate or ot_bits8,ot_none);
+    code    : #192#1#128#133#17;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_SUB;
+    ops     : 2;
+    optypes : (ot_memory,ot_immediate or ot_bits16,ot_none);
+    code    : #208#192#1#129#133#25;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_SUB;
+    ops     : 2;
+    optypes : (ot_memory,ot_immediate or ot_bits32,ot_none);
+    code    : #209#192#1#129#133#33;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_TEST;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg8,ot_none);
+    code    : #192#1#132#65;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_TEST;
+    ops     : 2;
+    optypes : (ot_reg8,ot_reg8,ot_none);
+    code    : #192#1#132#65;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_TEST;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg16,ot_none);
+    code    : #208#192#1#133#65;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_TEST;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#192#1#133#65;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_TEST;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg32,ot_none);
+    code    : #209#192#1#133#65;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_TEST;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#192#1#133#65;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_TEST;
+    ops     : 2;
+    optypes : (ot_reg8,ot_memory,ot_none);
+    code    : #193#1#132#72;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_TEST;
+    ops     : 2;
+    optypes : (ot_reg16,ot_memory,ot_none);
+    code    : #208#193#1#133#72;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_TEST;
+    ops     : 2;
+    optypes : (ot_reg32,ot_memory,ot_none);
+    code    : #209#193#1#133#72;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_TEST;
+    ops     : 2;
+    optypes : (ot_reg_al,ot_immediate,ot_none);
+    code    : #1#168#17;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_TEST;
+    ops     : 2;
+    optypes : (ot_reg_ax,ot_immediate,ot_none);
+    code    : #208#1#169#25;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_TEST;
+    ops     : 2;
+    optypes : (ot_reg_eax,ot_immediate,ot_none);
+    code    : #209#1#169#33;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_TEST;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_immediate,ot_none);
+    code    : #192#1#246#128#17;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_TEST;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_immediate,ot_none);
+    code    : #208#192#1#247#128#25;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_TEST;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_immediate,ot_none);
+    code    : #209#192#1#247#128#33;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_TEST;
+    ops     : 2;
+    optypes : (ot_memory,ot_immediate or ot_bits8,ot_none);
+    code    : #192#1#246#128#17;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_TEST;
+    ops     : 2;
+    optypes : (ot_memory,ot_immediate or ot_bits16,ot_none);
+    code    : #208#192#1#247#128#25;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_TEST;
+    ops     : 2;
+    optypes : (ot_memory,ot_immediate or ot_bits32,ot_none);
+    code    : #209#192#1#247#128#33;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_UMOV;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg8,ot_none);
+    code    : #192#2#15#16#65;
+    flags   : if_386 or if_UNDOC or if_SM
+  ),
+  (
+    opcode  : A_UMOV;
+    ops     : 2;
+    optypes : (ot_reg8,ot_reg8,ot_none);
+    code    : #192#2#15#16#65;
+    flags   : if_386 or if_UNDOC
+  ),
+  (
+    opcode  : A_UMOV;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg16,ot_none);
+    code    : #208#192#2#15#17#65;
+    flags   : if_386 or if_UNDOC or if_SM
+  ),
+  (
+    opcode  : A_UMOV;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#192#2#15#17#65;
+    flags   : if_386 or if_UNDOC
+  ),
+  (
+    opcode  : A_UMOV;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg32,ot_none);
+    code    : #209#192#2#15#17#65;
+    flags   : if_386 or if_UNDOC or if_SM
+  ),
+  (
+    opcode  : A_UMOV;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#192#2#15#17#65;
+    flags   : if_386 or if_UNDOC
+  ),
+  (
+    opcode  : A_UMOV;
+    ops     : 2;
+    optypes : (ot_reg8,ot_memory,ot_none);
+    code    : #193#2#15#18#72;
+    flags   : if_386 or if_UNDOC or if_SM
+  ),
+  (
+    opcode  : A_UMOV;
+    ops     : 2;
+    optypes : (ot_reg8,ot_reg8,ot_none);
+    code    : #193#2#15#18#72;
+    flags   : if_386 or if_UNDOC
+  ),
+  (
+    opcode  : A_UMOV;
+    ops     : 2;
+    optypes : (ot_reg16,ot_memory,ot_none);
+    code    : #208#193#2#15#19#72;
+    flags   : if_386 or if_UNDOC or if_SM
+  ),
+  (
+    opcode  : A_UMOV;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#193#2#15#19#72;
+    flags   : if_386 or if_UNDOC
+  ),
+  (
+    opcode  : A_UMOV;
+    ops     : 2;
+    optypes : (ot_reg32,ot_memory,ot_none);
+    code    : #209#193#2#15#19#72;
+    flags   : if_386 or if_UNDOC or if_SM
+  ),
+  (
+    opcode  : A_UMOV;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#193#2#15#19#72;
+    flags   : if_386 or if_UNDOC
+  ),
+  (
+    opcode  : A_VERR;
+    ops     : 1;
+    optypes : (ot_memory,ot_none,ot_none);
+    code    : #192#1#15#15#132;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_VERR;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits16,ot_none,ot_none);
+    code    : #192#1#15#15#132;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_VERR;
+    ops     : 1;
+    optypes : (ot_reg16,ot_none,ot_none);
+    code    : #192#1#15#15#132;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_VERW;
+    ops     : 1;
+    optypes : (ot_memory,ot_none,ot_none);
+    code    : #192#1#15#15#133;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_VERW;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits16,ot_none,ot_none);
+    code    : #192#1#15#15#133;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_VERW;
+    ops     : 1;
+    optypes : (ot_reg16,ot_none,ot_none);
+    code    : #192#1#15#15#133;
+    flags   : if_286 or if_PRIV
+  ),
+  (
+    opcode  : A_WAIT;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#155;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_WBINVD;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#15#9;
+    flags   : if_486
+  ),
+  (
+    opcode  : A_WRMSR;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#15#48;
+    flags   : if_PENT
+  ),
+  (
+    opcode  : A_XADD;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg8,ot_none);
+    code    : #192#2#15#192#65;
+    flags   : if_486 or if_SM
+  ),
+  (
+    opcode  : A_XADD;
+    ops     : 2;
+    optypes : (ot_reg8,ot_reg8,ot_none);
+    code    : #192#2#15#192#65;
+    flags   : if_486
+  ),
+  (
+    opcode  : A_XADD;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg16,ot_none);
+    code    : #208#192#2#15#193#65;
+    flags   : if_486 or if_SM
+  ),
+  (
+    opcode  : A_XADD;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#192#2#15#193#65;
+    flags   : if_486
+  ),
+  (
+    opcode  : A_XADD;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg32,ot_none);
+    code    : #209#192#2#15#193#65;
+    flags   : if_486 or if_SM
+  ),
+  (
+    opcode  : A_XADD;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#192#2#15#193#65;
+    flags   : if_486
+  ),
+  (
+    opcode  : A_XBTS;
+    ops     : 2;
+    optypes : (ot_reg16,ot_memory,ot_none);
+    code    : #208#193#2#15#166#72;
+    flags   : if_386 or if_SW or if_UNDOC
+  ),
+  (
+    opcode  : A_XBTS;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#193#2#15#166#72;
+    flags   : if_386 or if_UNDOC
+  ),
+  (
+    opcode  : A_XBTS;
+    ops     : 2;
+    optypes : (ot_reg32,ot_memory,ot_none);
+    code    : #209#193#2#15#166#72;
+    flags   : if_386 or if_SD or if_UNDOC
+  ),
+  (
+    opcode  : A_XBTS;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#193#2#15#166#72;
+    flags   : if_386 or if_UNDOC
+  ),
+  (
+    opcode  : A_XCHG;
+    ops     : 2;
+    optypes : (ot_reg_ax,ot_reg16,ot_none);
+    code    : #208#9#144;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_XCHG;
+    ops     : 2;
+    optypes : (ot_reg_eax,ot_reg32,ot_none);
+    code    : #209#9#144;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_XCHG;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg_ax,ot_none);
+    code    : #208#8#144;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_XCHG;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg_eax,ot_none);
+    code    : #209#8#144;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_XCHG;
+    ops     : 2;
+    optypes : (ot_reg8,ot_memory,ot_none);
+    code    : #193#1#134#72;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_XCHG;
+    ops     : 2;
+    optypes : (ot_reg8,ot_reg8,ot_none);
+    code    : #193#1#134#72;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_XCHG;
+    ops     : 2;
+    optypes : (ot_reg16,ot_memory,ot_none);
+    code    : #208#193#1#135#72;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_XCHG;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#193#1#135#72;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_XCHG;
+    ops     : 2;
+    optypes : (ot_reg32,ot_memory,ot_none);
+    code    : #209#193#1#135#72;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_XCHG;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#193#1#135#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_XCHG;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg8,ot_none);
+    code    : #192#1#134#65;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_XCHG;
+    ops     : 2;
+    optypes : (ot_reg8,ot_reg8,ot_none);
+    code    : #192#1#134#65;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_XCHG;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg16,ot_none);
+    code    : #208#192#1#135#65;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_XCHG;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#192#1#135#65;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_XCHG;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg32,ot_none);
+    code    : #209#192#1#135#65;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_XCHG;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#192#1#135#65;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_XLAT;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#215;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_XLATB;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #1#215;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_XOR;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg8,ot_none);
+    code    : #192#1#48#65;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_XOR;
+    ops     : 2;
+    optypes : (ot_reg8,ot_reg8,ot_none);
+    code    : #192#1#48#65;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_XOR;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg16,ot_none);
+    code    : #208#192#1#49#65;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_XOR;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#192#1#49#65;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_XOR;
+    ops     : 2;
+    optypes : (ot_memory,ot_reg32,ot_none);
+    code    : #209#192#1#49#65;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_XOR;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#192#1#49#65;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_XOR;
+    ops     : 2;
+    optypes : (ot_reg8,ot_memory,ot_none);
+    code    : #193#1#50#72;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_XOR;
+    ops     : 2;
+    optypes : (ot_reg8,ot_reg8,ot_none);
+    code    : #193#1#50#72;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_XOR;
+    ops     : 2;
+    optypes : (ot_reg16,ot_memory,ot_none);
+    code    : #208#193#1#51#72;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_XOR;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#193#1#51#72;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_XOR;
+    ops     : 2;
+    optypes : (ot_reg32,ot_memory,ot_none);
+    code    : #209#193#1#51#72;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_XOR;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#193#1#51#72;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_XOR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_immediate or ot_bits8 or ot_signed,ot_none);
+    code    : #208#192#1#131#134#13;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_XOR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_immediate or ot_bits8 or ot_signed,ot_none);
+    code    : #209#192#1#131#134#13;
+    flags   : if_386
+  ),
+  (
+    opcode  : A_XOR;
+    ops     : 2;
+    optypes : (ot_reg_al,ot_immediate,ot_none);
+    code    : #1#52#17;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_XOR;
+    ops     : 2;
+    optypes : (ot_reg_ax,ot_immediate,ot_none);
+    code    : #208#1#53#25;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_XOR;
+    ops     : 2;
+    optypes : (ot_reg_eax,ot_immediate,ot_none);
+    code    : #209#1#53#33;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_XOR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits8,ot_immediate,ot_none);
+    code    : #192#1#128#134#17;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_XOR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits16,ot_immediate,ot_none);
+    code    : #208#192#1#129#134#25;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_XOR;
+    ops     : 2;
+    optypes : (ot_regmem or ot_bits32,ot_immediate,ot_none);
+    code    : #209#192#1#129#134#33;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_XOR;
+    ops     : 2;
+    optypes : (ot_memory,ot_immediate or ot_bits8,ot_none);
+    code    : #192#1#128#134#17;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_XOR;
+    ops     : 2;
+    optypes : (ot_memory,ot_immediate or ot_bits16,ot_none);
+    code    : #208#192#1#129#134#25;
+    flags   : if_8086 or if_SM
+  ),
+  (
+    opcode  : A_XOR;
+    ops     : 2;
+    optypes : (ot_memory,ot_immediate or ot_bits32,ot_none);
+    code    : #209#192#1#129#134#33;
+    flags   : if_386 or if_SM
+  ),
+  (
+    opcode  : A_CMOVcc;
+    ops     : 2;
+    optypes : (ot_reg16,ot_memory,ot_none);
+    code    : #208#193#1#15#216#64#72;
+    flags   : if_P6 or if_SM
+  ),
+  (
+    opcode  : A_CMOVcc;
+    ops     : 2;
+    optypes : (ot_reg16,ot_reg16,ot_none);
+    code    : #208#193#1#15#216#64#72;
+    flags   : if_P6
+  ),
+  (
+    opcode  : A_CMOVcc;
+    ops     : 2;
+    optypes : (ot_reg32,ot_memory,ot_none);
+    code    : #209#193#1#15#216#64#72;
+    flags   : if_P6 or if_SM
+  ),
+  (
+    opcode  : A_CMOVcc;
+    ops     : 2;
+    optypes : (ot_reg32,ot_reg32,ot_none);
+    code    : #209#193#1#15#216#64#72;
+    flags   : if_P6
+  ),
+  (
+    opcode  : A_Jcc;
+    ops     : 1;
+    optypes : (ot_immediate or ot_near,ot_none,ot_none);
+    code    : #210#1#15#216#128#52;
+    flags   : if_386 or if_PASS2
+  ),
+  (
+    opcode  : A_Jcc;
+    ops     : 1;
+    optypes : (ot_immediate,ot_none,ot_none);
+    code    : #216#112#40;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_Jcc;
+    ops     : 1;
+    optypes : (ot_immediate or ot_short,ot_none,ot_none);
+    code    : #216#112#40;
+    flags   : if_8086
+  ),
+  (
+    opcode  : A_SETcc;
+    ops     : 1;
+    optypes : (ot_memory,ot_none,ot_none);
+    code    : #192#1#15#216#144#128;
+    flags   : if_386 or if_SB
+  ),
+  (
+    opcode  : A_SETcc;
+    ops     : 1;
+    optypes : (ot_reg8,ot_none,ot_none);
+    code    : #192#1#15#216#144#128;
+    flags   : if_386
+  )
+);

+ 279 - 0
compiler/nasmconv.pas

@@ -0,0 +1,279 @@
+program nasmconv;
+
+var
+   infile,outfile : text;
+   s : string;
+   i : longint;
+
+
+      function Replace(var s:string;const s1,s2:string):boolean;
+      var
+        i  : longint;
+      begin
+        i:=pos(s1,s);
+        if i>0 then
+         begin
+           Delete(s,i,length(s1));
+           Insert(s2,s,i);
+           Replace:=true;
+         end
+        else
+         Replace:=false;
+      end;
+
+
+function formatop(s:string):string;
+   const
+     replaces=19;
+     replacetab : array[1..replaces,1..2] of string[32]=(
+       (':',' or ot_colon'),
+       ('mem8','mem or ot_bits8'),
+       ('mem16','mem or ot_bits16'),
+       ('mem32','mem or ot_bits32'),
+       ('mem64','mem or ot_bits64'),
+       ('mem80','mem or ot_bits80'),
+       ('mem','memory'),
+       ('memory_offs','mem_offs'),
+       ('imm8','imm or ot_bits8'),
+       ('imm16','imm or ot_bits16'),
+       ('imm32','imm or ot_bits32'),
+       ('imm64','imm or ot_bits64'),
+       ('imm80','imm or ot_bits80'),
+       ('imm','immediate'),
+       ('rm8','regmem or ot_bits8'),
+       ('rm16','regmem or ot_bits16'),
+       ('rm32','regmem or ot_bits32'),
+       ('rm64','regmem or ot_bits64'),
+       ('rm80','regmem or ot_bits80')
+     );
+  var
+    i : longint;
+  begin
+    for i:=1to replaces do
+     replace(s,replacetab[i,1],replacetab[i,2]);
+    formatop:=s;
+  end;
+
+
+procedure maybe_newline;
+
+  begin
+     if s[i]=#10 then
+       begin
+          readln(infile,s);
+          i:=1;
+       end;
+     while s[1]=';' do
+       begin
+          readln(infile,s);
+          i:=1;
+       end;
+  end;
+
+function readnumber : longint;
+
+  var
+     base : longint;
+     result : longint;
+
+  begin
+     result:=0;
+     if s[i]='\' then
+       begin
+          base:=8;
+          inc(i);
+          if s[i]='x' then
+            begin
+               base:=16;
+               inc(i);
+            end;
+       end
+     else
+       base:=10;
+     s[i]:=upcase(s[i]);
+     while s[i] in ['0'..'9','A'..'F'] do
+       begin
+          case s[i] of
+             '0'..'9':
+               result:=result*base+ord(s[i])-ord('0');
+
+             'A'..'F':
+               result:=result*base+ord(s[i])-ord('A')+10;
+          end;
+          inc(i);
+       end;
+     readnumber:=result;
+  end;
+
+function tostr(l : longint) : string;
+
+  var
+     hs : string;
+
+  begin
+     str(l,hs);
+     tostr:=hs;
+  end;
+
+function readstr : string;
+
+  var
+     result : string;
+
+  begin
+     result:='';
+     while (s[i] in ['0'..'9','A'..'Z','a'..'z','_']) and (i<=length(s)) do
+       begin
+          result:=result+s[i];
+          inc(i);
+       end;
+     readstr:=result;
+  end;
+
+procedure skipspace;
+
+  begin
+     while (s[i] in [' ',#9]) do
+       inc(i);
+  end;
+
+var
+   hs : string;
+   j : longint;
+   first : boolean;
+   maxinfolen,
+   code : byte;
+   insns : longint;
+   { instruction fields }
+   last,
+   ops    : longint;
+   opcode,
+   codes,
+   flags   : string;
+   optypes : array[1..3] of string;
+begin
+   writeln('Nasm Instruction Table Converter Version 0.99.11');
+   insns:=0;
+   assign(infile,'insns.dat');
+   reset(infile);
+   assign(outfile,'i386tab.inc');
+   rewrite(outfile);
+   writeln(outfile,'(');
+   first:=true;
+   while not(eof(infile)) do
+     begin
+        { handle comment }
+        readln(infile,s);
+        if s[1]=';' then
+          continue;
+        { clear }
+        opcode:='';
+        ops:=0;
+        optypes[1]:='';
+        optypes[2]:='';
+        optypes[3]:='';
+        codes:='';
+        flags:='';
+        { opcode }
+        opcode:='A_';
+        i:=1;
+        while not(s[i] in [' ',#9]) do
+          begin
+            opcode:=opcode+s[i];
+            inc(i);
+          end;
+        skipspace;
+        { ops and optypes }
+        repeat
+          hs:=readstr;
+          if (hs='void') or (hs='ignore') then
+            break;
+          inc(ops);
+          optypes[ops]:=optypes[ops]+'ot_'+formatop(hs);
+          if s[i]=':' then
+            begin
+               inc(i);
+               optypes[ops]:=optypes[ops]+' or ot_'+formatop(readstr);
+            end;
+          while s[i]='|' do
+            begin
+               inc(i);
+               optypes[ops]:=optypes[ops]+' or ot_'+formatop(readstr);
+            end;
+          if s[i]=',' then
+            inc(i)
+          else
+            break;
+        until false;
+        for j:=1 to 3-ops do
+          optypes[3-j+1]:='ot_none';
+        { codes }
+        skipspace;
+        j:=0;
+        last:=0;
+        if s[i] in ['\','0'..'9'] then
+          begin
+             while not(s[i] in [' ',#9]) do
+               begin
+                 code:=readnumber;
+                 { for some codes we want also to change the optypes, but not
+                   if the last byte was a 1 then this byte belongs to a direct
+                   copy }
+                 if last<>1 then
+                  begin
+                    case code of
+                      12,13,14 :
+                        optypes[code-11]:=optypes[code-11]+' or ot_signed';
+                    end;
+                  end;
+                 codes:=codes+'#'+tostr(code);
+                 last:=code;
+                 inc(j);
+               end;
+          end
+        else
+          codes:='#0';
+        if j>maxinfolen then
+         maxinfolen:=j;
+        { flags }
+        skipspace;
+        while not(s[i] in [' ',#9,#13,#10]) and (i<=length(s)) do
+          begin
+             hs:=readstr;
+             if hs='ignore' then
+              begin
+                flags:='0';
+                break;
+              end;
+             if hs<>'ND' then
+              begin
+                if flags<>'' then
+                 flags:=flags+' or ';
+                flags:=flags+'if_'+hs;
+              end;
+             if (s[i]=',') and (i<=length(s)) then
+              inc(i)
+             else
+              break;
+          end;
+      { write instruction }
+        if not(first) then
+          writeln(outfile,',')
+        else
+          first:=false;
+        writeln(outfile,'  (');
+        writeln(outfile,'    opcode  : ',opcode,';');
+        writeln(outfile,'    ops     : ',ops,';');
+        writeln(outfile,'    optypes : (',optypes[1],',',optypes[2],',',optypes[3],');');
+        writeln(outfile,'    code    : ',codes,';');
+        writeln(outfile,'    flags   : ',flags);
+        write(outfile,'  )');
+        maybe_newline;
+        inc(insns);
+     end;
+   writeln(outfile);
+   writeln(outfile,');');
+   close(infile);
+   close(outfile);
+   writeln(insns,' nodes procesed (maxinfolen=',maxinfolen,')');
+end.

+ 272 - 0
compiler/og386.pas

@@ -0,0 +1,272 @@
+{
+    $Id$
+    Copyright (c) 1999 by Florian Klaempfl
+
+    Contains the base stuff for 386 binary object file writers
+
+    * This code was inspired by the NASM sources
+      The Netwide Assembler is copyright (C) 1996 Simon Tatham and
+      Julian Hall. All rights reserved.
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+unit og386;
+
+  interface
+    uses
+       dos,
+       owbase,owar,
+       i386base,aasm;
+
+    type
+       tsecsize = array[tsection] of longint;
+
+       relative_type = (relative_false,relative_true,relative_rva);
+
+       pobjectalloc = ^tobjectalloc;
+       tobjectalloc = object
+         currsec : tsection;
+         secsize : tsecsize;
+         constructor init;
+         destructor  done;
+         procedure setsection(sec:tsection);
+         function  sectionsize:longint;
+         procedure sectionalloc(l:longint);
+         procedure resetsections;
+       end;
+
+       pobjectoutput = ^tobjectoutput;
+       tobjectoutput = object
+         writer    : pobjectwriter;
+         path      : pathstr;
+         ObjFile   : string;
+         IsEndFile : boolean;  { special 'end' file for import dir ? }
+         currsec   : tsection;
+         constructor init;
+         destructor  done;virtual;
+         { Writing }
+         procedure NextSmartName;
+         procedure initwriting;virtual;
+         procedure donewriting;virtual;
+         procedure writebytes(var data;len:longint);virtual;
+         procedure writealloc(len:longint);virtual;
+         procedure writereloc(data,len:longint;p:pasmsymbol;relative:relative_type);virtual;
+         procedure writesymbol(p:pasmsymbol);virtual;
+         procedure writestabs(section:tsection;offset:longint;p:pchar;nidx,nother,line:longint;reloc:boolean);virtual;
+         procedure defaultsection(sec:tsection);
+       end;
+
+    var
+      objectalloc  : pobjectalloc;
+      objectoutput : pobjectoutput;
+
+  implementation
+
+    uses
+      systems,globtype,globals,verbose,files,
+      assemble;
+
+
+{****************************************************************************
+                                tobjectoutput
+****************************************************************************}
+
+    constructor tobjectalloc.init;
+      begin
+      end;
+
+
+    destructor tobjectalloc.done;
+      begin
+      end;
+
+
+    procedure tobjectalloc.setsection(sec:tsection);
+      begin
+        currsec:=sec;
+      end;
+
+
+    procedure tobjectalloc.resetsections;
+      begin
+        FillChar(secsize,sizeof(secsize),0);
+      end;
+
+
+    procedure tobjectalloc.sectionalloc(l:longint);
+      begin
+        inc(secsize[currsec],l);
+      end;
+
+
+    function tobjectalloc.sectionsize:longint;
+      begin
+        sectionsize:=secsize[currsec];
+      end;
+
+
+
+{****************************************************************************
+                                tobjectoutput
+****************************************************************************}
+
+    constructor tobjectoutput.init;
+      var
+        i : longint;
+      begin
+        objfile:=current_module^.objfilename^;
+      { Which path will be used ? }
+        if (cs_smartlink in aktmoduleswitches) and
+           (cs_asm_leave in aktglobalswitches) then
+         begin
+           path:=current_module^.path^+FixFileName(current_module^.modulename^)+target_info.smartext;
+           {$I-}
+            mkdir(path);
+           {$I+}
+           i:=ioresult;
+           path:=FixPath(path,false);
+         end
+        else
+         path:=current_module^.path^;
+      { init writer }
+        if (cs_smartlink in aktmoduleswitches) and
+           not(cs_asm_leave in aktglobalswitches) then
+          writer:=New(parobjectwriter,Init(current_module^.staticlibfilename^))
+        else
+          writer:=New(pobjectwriter,Init);
+      end;
+
+
+    destructor tobjectoutput.done;
+      begin
+        Dispose(writer,done);
+      end;
+
+
+    procedure tobjectoutput.NextSmartName;
+      var
+        s : string;
+      begin
+        inc(SmartLinkFilesCnt);
+        if SmartLinkFilesCnt>999999 then
+         Message(assem_f_too_many_asm_files);
+        if (cs_asm_leave in aktglobalswitches) then
+          begin
+            if IsEndFile then
+             begin
+               s:=current_module^.asmprefix^+'e';
+               IsEndFile:=false;
+             end
+            else
+             s:=current_module^.asmprefix^;
+            ObjFile:=Path+FixFileName(s+tostr(SmartLinkFilesCnt)+target_info.objext)
+          end
+        else
+          begin
+            if IsEndFile then
+             begin
+               s:=current_module^.modulename^+'_e';
+               IsEndFile:=false;
+             end
+            else
+             s:=current_module^.modulename^+'_';
+            ObjFile:=FixFileName(s+tostr(SmartLinkFilesCnt)+target_info.objext);
+          end;
+      end;
+
+
+    procedure tobjectoutput.initwriting;
+      begin
+        if (cs_smartlink in aktmoduleswitches) then
+         NextSmartName;
+        writer^.create(objfile);
+      end;
+
+
+    procedure tobjectoutput.donewriting;
+      begin
+        writer^.close;
+      end;
+
+
+    procedure tobjectoutput.defaultsection(sec:tsection);
+      begin
+        currsec:=sec;
+      end;
+
+    procedure tobjectoutput.writesymbol(p:pasmsymbol);
+      begin
+        RunError(211);
+      end;
+
+    procedure tobjectoutput.writereloc(data,len:longint;p:pasmsymbol;relative:relative_type);
+      begin
+        RunError(211);
+      end;
+
+    procedure tobjectoutput.writebytes(var data;len:longint);
+      begin
+        RunError(211);
+      end;
+
+    procedure tobjectoutput.writealloc(len:longint);
+      begin
+        RunError(211);
+      end;
+
+   procedure tobjectoutput.writestabs(section:tsection;offset:longint;p:pchar;nidx,nother,line:longint;reloc:boolean);
+      begin
+        RunError(211);
+      end;
+
+end.
+{
+  $Log$
+  Revision 1.1  1999-05-01 13:24:23  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.8  1999/03/18 20:30:48  peter
+    + .a writer
+
+  Revision 1.7  1999/03/10 13:41:09  pierre
+   + partial implementation for win32 !
+     winhello works but pp still does not !
+
+  Revision 1.6  1999/03/08 14:51:08  peter
+    + smartlinking for ag386bin
+
+  Revision 1.5  1999/03/05 13:09:51  peter
+    * first things for tai_cut support for ag386bin
+
+  Revision 1.4  1999/03/03 01:36:45  pierre
+    + stabs output working (though not really tested)
+      for a simple file the only difference to GAS output is due
+      to the VMA of the different sections
+
+  Revision 1.3  1999/03/02 02:56:26  peter
+    + stabs support for binary writers
+    * more fixes and missing updates from the previous commit :(
+
+  Revision 1.2  1999/02/25 21:03:09  peter
+    * ag386bin updates
+    + coff writer
+
+  Revision 1.1  1999/02/16 17:59:39  peter
+    + initial files
+
+}

+ 890 - 0
compiler/og386cff.pas

@@ -0,0 +1,890 @@
+{
+    $Id$
+    Copyright (c) 1999 by Florian Klaempfl
+
+    Contains the 386 binary coff writer
+
+    * This code was inspired by the NASM sources
+      The Netwide Assembler is copyright (C) 1996 Simon Tatham and
+      Julian Hall. All rights reserved.
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+unit og386cff;
+
+{
+  Notes on COFF:
+
+  (0) When I say `standard COFF' below, I mean `COFF as output and
+  used by DJGPP'. I assume DJGPP gets it right.
+
+  (1) Win32 appears to interpret the term `relative relocation'
+  differently from standard COFF. Standard COFF understands a
+  relative relocation to mean that during relocation you add the
+  address of the symbol you're referencing, and subtract the base
+  address of the section you're in. Win32 COFF, by contrast, seems
+  to add the address of the symbol and then subtract the address
+  of THE BYTE AFTER THE RELOCATED DWORD. Hence the two formats are
+  subtly incompatible.
+
+  (2) Win32 doesn't bother putting any flags in the header flags
+  field (at offset 0x12 into the file).
+
+  (3) Win32 uses some extra flags into the section header table:
+  it defines flags 0x80000000 (writable), 0x40000000 (readable)
+  and 0x20000000 (executable), and uses them in the expected
+  combinations. It also defines 0x00100000 through 0x00700000 for
+  section alignments of 1 through 64 bytes.
+
+  (4) Both standard COFF and Win32 COFF seem to use the DWORD
+  field directly after the section name in the section header
+  table for something strange: they store what the address of the
+  section start point _would_ be, if you laid all the sections end
+  to end starting at zero. Dunno why. Microsoft's documentation
+  lists this field as "Virtual Size of Section", which doesn't
+  seem to fit at all. In fact, Win32 even includes non-linked
+  sections such as .drectve in this calculation.
+
+  (5) Standard COFF does something very strange to common
+  variables: the relocation point for a common variable is as far
+  _before_ the variable as its size stretches out _after_ it. So
+  we must fix up common variable references. Win32 seems to be
+  sensible on this one.
+}
+  interface
+
+    uses
+       cobjects,
+       og386,i386base,aasm;
+
+    type
+       preloc = ^treloc;
+       treloc = packed record
+          next     : preloc;
+          address  : longint;
+          symbol   : pasmsymbol;
+          section  : tsection; { only used if symbol=nil }
+          relative : relative_type;
+       end;
+
+       psymbol = ^tsymbol;
+       tsymbol = packed record
+         name    : string[8];
+         strpos  : longint;
+         section : longint;
+         value   : longint;
+         typ     : TAsmsymtype;
+       end;
+
+       pcoffsection = ^tcoffsection;
+       tcoffsection = object
+          index : tsection;
+          data  : PDynamicArray;
+          len,
+          pos,
+          datapos,
+          relocpos,
+          nrelocs,
+          flags     : longint;
+          relochead : PReloc;
+          reloctail : ^PReloc;
+          constructor init(sec:TSection;Aflags:longint);
+          destructor  done;
+          procedure  write(var d;l:longint);
+          procedure  alloc(l:longint);
+          procedure  addsymreloc(ofs:longint;p:pasmsymbol;relative:relative_type);
+          procedure  addsectionreloc(ofs:longint;sec:tsection);
+       end;
+
+       pgenericcoffoutput = ^tgenericcoffoutput;
+       tgenericcoffoutput = object(tobjectoutput)
+         win32   : boolean;
+         sects   : array[TSection] of PCoffSection;
+         strs,
+         syms    : Pdynamicarray;
+         initsym : longint;
+         constructor init;
+         destructor  done;virtual;
+         procedure initwriting;virtual;
+         procedure donewriting;virtual;
+         procedure writebytes(var data;len:longint);virtual;
+         procedure writealloc(len:longint);virtual;
+         procedure writereloc(data,len:longint;p:pasmsymbol;relative:relative_type);virtual;
+         procedure writesymbol(p:pasmsymbol);virtual;
+         procedure writestabs(section:tsection;offset:longint;p:pchar;nidx,nother,line:longint;reloc:boolean);virtual;
+
+         function  text_flags : longint;virtual;
+         function  data_flags : longint;virtual;
+         function  bss_flags : longint;virtual;
+         function  info_flags : longint;virtual;
+       private
+         procedure createsection(sec:tsection);
+         procedure write_relocs(s:pcoffsection);
+         procedure write_symbol(const name:string;strpos,value,section,typ,aux:longint);
+         procedure write_symbols;
+         procedure writetodisk;
+       end;
+
+       pdjgppcoffoutput = ^tdjgppcoffoutput;
+       tdjgppcoffoutput = object(tgenericcoffoutput)
+         constructor init;
+         function text_flags : longint;virtual;
+         function data_flags : longint;virtual;
+         function bss_flags : longint;virtual;
+         function info_flags : longint;virtual;
+       end;
+
+       pwin32coffoutput = ^twin32coffoutput;
+       twin32coffoutput = object(tgenericcoffoutput)
+         constructor init;
+         function text_flags : longint;virtual;
+         function data_flags : longint;virtual;
+         function bss_flags : longint;virtual;
+         function info_flags : longint;virtual;
+       end;
+
+  implementation
+
+      uses
+        strings,verbose,
+        globtype,globals,files;
+
+      type
+      { Structures which are written directly to the output file }
+        coffheader=packed record
+          mach   : word;
+          nsects : word;
+          time   : longint;
+          sympos : longint;
+          syms   : longint;
+          opthdr : word;
+          flag   : word;
+        end;
+        coffsechdr=packed record
+          name     : array[0..7] of char;
+          vsize    : longint;
+          rvaofs   : longint;
+          datalen  : longint;
+          datapos  : longint;
+          relocpos : longint;
+          lineno1  : longint;
+          nrelocs  : word;
+          lineno2  : word;
+          flags    : longint;
+        end;
+        coffsectionrec=packed record
+          len     : longint;
+          nrelocs : word;
+          empty   : array[0..11] of char;
+        end;
+        coffreloc=packed record
+          address  : longint;
+          sym      : longint;
+          relative : word;
+        end;
+        coffsymbol=packed record
+          name    : array[0..3] of char; { real is [0..7], which overlaps the strpos ! }
+          strpos  : longint;
+          value   : longint;
+          section : integer;
+          empty   : integer;
+          typ     : byte;
+          aux     : byte;
+        end;
+        pcoffstab=^coffstab;
+        coffstab=packed record
+          strpos  : longint;
+          ntype   : byte;
+          nother  : byte;
+          ndesc   : word;
+          nvalue  : longint;
+        end;
+
+
+      const
+        sec_2_str : array[tsection] of string[8]=('',
+          '.text','.data','.bss',
+          '.stab','.stabstr',
+          '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
+          ''
+        );
+
+
+{****************************************************************************
+                               TSection
+****************************************************************************}
+
+    constructor tcoffsection.init(sec:TSection;Aflags:longint);
+      begin
+        index:=sec;
+        flags:=AFlags;
+        relocHead:=nil;
+        relocTail:=@relocHead;
+        Len:=0;
+        NRelocs:=0;
+        if sec=sec_bss then
+         data:=nil
+        else
+         new(Data,Init(1,8192));
+      end;
+
+
+    destructor tcoffsection.done;
+      begin
+        if assigned(Data) then
+          dispose(Data,done);
+      end;
+
+
+    procedure  tcoffsection.write(var d;l:longint);
+      begin
+        if not assigned(Data) then
+         Internalerror(3334441);
+        Data^.write(d,l);
+        inc(len,l);
+      end;
+
+
+    procedure  tcoffsection.alloc(l:longint);
+      begin
+        if assigned(Data) then
+         Internalerror(3334442);
+        inc(len,l);
+      end;
+
+
+    procedure tcoffsection.addsymreloc(ofs:longint;p:pasmsymbol;relative:relative_type);
+      var
+        r : PReloc;
+      begin
+        new(r);
+        reloctail^:=r;
+        reloctail:=@r^.next;
+        r^.next:=nil;
+        r^.address:=ofs;
+        r^.symbol:=p;
+        r^.section:=sec_none;
+        r^.relative:=relative;
+        inc(nrelocs);
+      end;
+
+
+    procedure tcoffsection.addsectionreloc(ofs:longint;sec:tsection);
+      var
+        r : PReloc;
+      begin
+        new(r);
+        reloctail^:=r;
+        reloctail:=@r^.next;
+        r^.next:=nil;
+        r^.address:=ofs;
+        r^.symbol:=nil;
+        r^.section:=sec;
+        r^.relative:=relative_false;
+        inc(nrelocs);
+      end;
+
+
+{****************************************************************************
+                            Genericcoffoutput
+****************************************************************************}
+
+    const
+{$ifdef TP}
+      symbolresize = 50;
+      strsresize   = 200;
+{$else}
+      symbolresize = 200;
+      strsresize   = 8192;
+{$endif}
+
+    constructor tgenericcoffoutput.init;
+      begin
+        inherited init;
+      end;
+
+
+    destructor tgenericcoffoutput.done;
+      begin
+        inherited done;
+      end;
+
+
+    procedure tgenericcoffoutput.initwriting;
+      var
+        s : string;
+      begin
+        inherited initwriting;
+        { reset }
+        initsym:=0;
+        new(syms,init(sizeof(TSymbol),symbolresize));
+        new(strs,init(1,strsresize));
+        FillChar(Sects,sizeof(Sects),0);
+        { we need at least the following 3 sections }
+        createsection(sec_code);
+        createsection(sec_data);
+        createsection(sec_bss);
+        if (cs_debuginfo in aktmoduleswitches) then
+         begin
+           createsection(sec_stab);
+           createsection(sec_stabstr);
+           writestabs(sec_none,0,nil,0,0,0,false);
+           { write zero pchar and name together (PM) }
+           s:=#0+SplitFileName(current_module^.mainsource^)+#0;
+           sects[sec_stabstr]^.write(s[1],length(s));
+         end;
+      end;
+
+
+    procedure tgenericcoffoutput.donewriting;
+      var
+        sec : tsection;
+      begin
+        writetodisk;
+        dispose(syms,done);
+        dispose(strs,done);
+        for sec:=low(tsection) to high(tsection) do
+         if assigned(sects[sec]) then
+          dispose(sects[sec],done);
+        inherited donewriting;
+      end;
+
+
+    function tgenericcoffoutput.text_flags : longint;
+      begin
+        text_flags:=0;
+      end;
+
+    function tgenericcoffoutput.data_flags : longint;
+      begin
+        data_flags:=0;
+      end;
+
+    function tgenericcoffoutput.bss_flags : longint;
+      begin
+        bss_flags:=0;
+      end;
+
+    function tgenericcoffoutput.info_flags : longint;
+      begin
+        info_flags:=0;
+      end;
+
+
+    procedure tgenericcoffoutput.createsection(sec:TSection);
+      var
+        Aflags : longint;
+      begin
+        Aflags:=0;
+        case sec of
+          sec_code :
+            Aflags:=text_flags;
+          sec_data :
+            Aflags:=data_flags;
+          sec_bss :
+            Aflags:=bss_flags;
+        { sec_info :
+            Aflags:=info_flags; }
+          else
+            Aflags:=0;
+        end;
+        sects[sec]:=new(PcoffSection,init(Sec,Aflags));
+      end;
+
+
+    procedure tgenericcoffoutput.writesymbol(p:pasmsymbol);
+      var
+        pos : longint;
+        sym : tsymbol;
+        c   : char;
+        s   : string;
+      begin
+        { already written ? }
+        if p^.idx<>-1 then
+         exit;
+        { be sure that the section will exists }
+        if (p^.section<>sec_none) and not(assigned(sects[p^.section])) then
+          createsection(p^.section);
+        { symbolname }
+        pos:=strs^.usedsize+4;
+        c:=#0;
+        s:=p^.name;
+        if length(s)>8 then
+         begin
+           s:=s+#0;
+           strs^.write(s[1],length(s));
+         end
+        else
+         pos:=-1;
+        FillChar(sym,sizeof(sym),0);
+        sym.strpos:=pos;
+        if pos=-1 then
+         sym.name:=s;
+        sym.value:=p^.size;
+        sym.typ:=p^.typ;
+        { if local of global then set the section value to the address
+          of the symbol }
+        if p^.typ in [AS_LOCAL,AS_GLOBAL] then
+         begin
+           sym.section:=ord(p^.section);
+           sym.value:=p^.address;
+         end;
+        { update the asmsymbol index }
+        p^.idx:=syms^.count;
+        { store the symbol, but not the local ones (PM) }
+        if (p^.typ<>AS_LOCAL) or ((copy(s,1,2)<>'.L') and
+          ((copy(s,1,1)<>'L') or not win32)) then
+          syms^.write(sym,1);
+        { make the exported syms known to the objectwriter
+          (needed for .a generation) }
+        if (p^.typ=AS_GLOBAL) or
+           ((p^.typ=AS_EXTERNAL) and (sym.value=p^.size) and (sym.value>0)) then
+          writer^.writesym(p^.name);
+      end;
+
+
+    procedure tgenericcoffoutput.writebytes(var data;len:longint);
+      begin
+        if not assigned(sects[currsec]) then
+         createsection(currsec);
+        sects[currsec]^.write(data,len);
+      end;
+
+
+    procedure tgenericcoffoutput.writealloc(len:longint);
+      begin
+        if not assigned(sects[currsec]) then
+         createsection(currsec);
+        sects[currsec]^.alloc(len);
+      end;
+
+
+    procedure tgenericcoffoutput.writereloc(data,len:longint;p:pasmsymbol;relative:relative_type);
+      begin
+        if not assigned(sects[currsec]) then
+         createsection(currsec);
+        if assigned(p) then
+         begin
+           { no symbol relocation need inside a section }
+           if p^.section=currsec then
+             begin
+               if relative=relative_false then
+                 begin
+                   sects[currsec]^.addsectionreloc(sects[currsec]^.len,currsec);
+                   inc(data,p^.address);
+                 end
+               else if relative=relative_true then
+                 begin
+                   inc(data,p^.address-len-sects[currsec]^.len);
+                 end
+               else if relative=relative_rva then
+                 begin
+                   { don't know if this can happens !! }
+                   { does this work ?? }
+                   sects[currsec]^.addsectionreloc(sects[currsec]^.len,currsec);
+                   inc(data,p^.address);
+                 end;
+             end
+           else
+             begin
+               writesymbol(p);
+               if (p^.section<>sec_none) and (relative=relative_false) then
+                 begin
+                   sects[currsec]^.addsectionreloc(sects[currsec]^.len,p^.section);
+                 end
+               else
+                 sects[currsec]^.addsymreloc(sects[currsec]^.len,p,relative);
+               if not win32 then {seems wrong to me (PM) }
+                begin
+                  {if p^.section<>sec_none then
+                    this is the cause of the strange
+                    feature see Note (5) before
+                    address contains the size for
+                    global vars switched to common }
+                    inc(data,p^.address);
+                end
+               else
+                if (relative<>relative_true) and (p^.section<>sec_none) then
+                 inc(data,p^.address);
+               if relative=relative_true then
+                begin
+                  if win32 then
+                    {inc(data,4-len)}
+                    dec(data,len-4{+p^.address})
+                  else
+                    dec(data,len+sects[currsec]^.len);
+                end;
+            end;
+         end;
+        sects[currsec]^.write(data,len);
+      end;
+
+
+    procedure tgenericcoffoutput.writestabs(section:tsection;offset:longint;p:pchar;nidx,nother,line:longint;reloc : boolean);
+      var
+        stab : coffstab;
+        s : tsection;
+      begin
+        if section=sec_none then
+         s:=currsec
+        else
+         s:=section;
+        { local var can be at offset -1 !! PM }
+        if (offset=-1) and reloc then
+         begin
+           if s=sec_none then
+            offset:=0
+           else
+            offset:=sects[s]^.len;
+         end;
+        fillchar(stab,sizeof(coffstab),0);
+        if assigned(p) and (p[0]<>#0) then
+         begin
+           stab.strpos:=sects[sec_stabstr]^.len;
+           sects[sec_stabstr]^.write(p^,strlen(p)+1);
+         end;
+        stab.ntype:=nidx;
+        stab.ndesc:=line;
+        stab.nother:=nother;
+        stab.nvalue:=offset;
+        sects[sec_stab]^.write(stab,sizeof(stab));
+        { when the offset is not 0 then write a relocation, take also the
+          hdrstab into account with the offset }
+        if reloc then
+          sects[sec_stab]^.addsectionreloc(sects[sec_stab]^.len-4,s);
+      end;
+
+
+    procedure tgenericcoffoutput.write_relocs(s:pcoffsection);
+      var
+        rel  : coffreloc;
+        hr,r : preloc;
+      begin
+        r:=s^.relochead;
+        while assigned(r) do
+         begin
+           rel.address:=r^.address;
+           if assigned(r^.symbol) then
+            begin
+              if (r^.symbol^.typ=AS_LOCAL) then
+               rel.sym:=2*ord(r^.symbol^.section)
+              else
+               rel.sym:=r^.symbol^.idx+initsym;
+            end
+           else
+            rel.sym:=2*ord(r^.section);
+           case r^.relative of
+             relative_true  : rel.relative:=$14;
+             relative_false : rel.relative:=$6;
+             relative_rva   : rel.relative:=$7;
+           end;
+           writer^.write(rel,sizeof(rel));
+           { goto next and dispose this reloc }
+           hr:=r;
+           r:=r^.next;
+           dispose(hr);
+         end;
+      end;
+
+
+    procedure tgenericcoffoutput.write_symbol(const name:string;strpos,value,section,typ,aux:longint);
+      var
+        sym : coffsymbol;
+      begin
+        FillChar(sym,sizeof(sym),0);
+        if strpos=-1 then
+         move(name[1],sym.name,length(name))
+        else
+         sym.strpos:=strpos;
+        sym.value:=value;
+        sym.section:=section;
+        sym.typ:=typ;
+        sym.aux:=aux;
+        writer^.write(sym,sizeof(sym));
+      end;
+
+
+    procedure tgenericcoffoutput.write_symbols;
+      var
+        filename : string[18];
+        sec : tsection;
+        i   : longint;
+        globalval : byte;
+        secrec : coffsectionrec;
+        sym : tsymbol;
+      begin
+        { The `.file' record, and the file name auxiliary record. }
+        write_symbol ('.file', -1, 0, -2, $67, 1);
+        fillchar(filename,sizeof(filename),0);
+        filename:=SplitFileName(current_module^.mainsource^);
+        writer^.write(filename[1],sizeof(filename)-1);
+        { The section records, with their auxiliaries }
+        i:=0;
+        for sec:=low(tsection) to high(tsection) do
+         if assigned(sects[sec]) then
+          begin
+            inc(i);
+            write_symbol(sec_2_str[sec],-1,{sects[sec]^.pos}0,i,3,1);
+            fillchar(secrec,sizeof(secrec),0);
+            secrec.len:=sects[sec]^.len;
+            secrec.nrelocs:=sects[sec]^.nrelocs;
+            writer^.write(secrec,sizeof(secrec));
+          end;
+        { The real symbols. }
+        syms^.seek(0);
+        for i:=1 to syms^.count do
+         begin
+           syms^.read(sym,1);
+           if sym.typ=AS_LOCAL then
+             globalval:=3
+           else
+             globalval:=2;
+           write_symbol(sym.name,sym.strpos,sym.value,sym.section,globalval,0);
+         end;
+      end;
+
+
+    procedure tgenericcoffoutput.writetodisk;
+      var
+        datapos,
+        nsects,pos,sympos,i,fillsize : longint;
+        sec    : tsection;
+        header : coffheader;
+        sechdr : coffsechdr;
+        empty  : array[0..15] of byte;
+      begin
+      { calc amount of sections we have and align sections at 4 bytes }
+        fillchar(empty,sizeof(empty),0);
+        nsects:=0;
+        for sec:=low(tsection) to high(tsection) do
+        { .stabstr section length must be without alignment !! }
+         if assigned(sects[sec]) then
+          begin
+          { fill with zero }
+            fillsize:=4-(sects[sec]^.len and 3);
+            if fillsize<>4 then
+             begin
+               if assigned(sects[sec]^.data) then
+                 sects[sec]^.write(empty,fillsize)
+               else
+                 sects[sec]^.alloc(fillsize);
+               { .stabstr section length must be without alignment !! }
+               if (sec=sec_stabstr) then
+                 dec(sects[sec]^.len,fillsize);
+             end;
+            inc(nsects);
+          end;
+      { Calculate the filepositions }
+        datapos:=sizeof(coffheader)+sizeof(coffsechdr)*nsects;
+        pos:=0;
+        initsym:=2; { 2 for the file }
+        { sections first }
+        for sec:=low(tsection) to high(tsection) do
+         if assigned(sects[sec]) then
+          begin
+            sects[sec]^.pos:=pos;
+            sects[sec]^.datapos:=datapos;
+            inc(pos,sects[sec]^.len);
+            if assigned(sects[sec]^.data) then
+              inc(datapos,sects[sec]^.len);
+            { align after stabstr section !! }
+            if (sec=sec_stabstr) and ((sects[sec]^.len and 3)<>0) then
+              inc(datapos,4-(sects[sec]^.len and 3));
+            inc(initsym,2); { 2 for each section }
+          end;
+        { relocs }
+        for sec:=low(tsection) to high(tsection) do
+         if assigned(sects[sec]) then
+          begin
+            sects[sec]^.relocpos:=datapos;
+            inc(datapos,10*sects[sec]^.nrelocs);
+          end;
+        { symbols }
+        sympos:=datapos;
+      { COFF header }
+        fillchar(header,sizeof(coffheader),0);
+        header.mach:=$14c;
+        header.nsects:=nsects;
+        header.sympos:=sympos;
+        header.syms:=syms^.count+initsym;
+        if not win32 then
+         header.flag:=$104;
+        writer^.write(header,sizeof(header));
+      { Section headers }
+        for sec:=low(tsection) to high(tsection) do
+         if assigned(sects[sec]) then
+          begin
+            fillchar(sechdr,sizeof(sechdr),0);
+            move(sec_2_str[sec][1],sechdr.name,length(sec_2_str[sec]));
+            if not win32 then
+              sechdr.vsize:=sects[sec]^.pos
+            else if sec=sec_bss then
+              sechdr.vsize:=sects[sec]^.len;
+            sechdr.datalen:=sects[sec]^.len;
+            { apparently win32 asw leaves section at datapos zero }
+            { this was an error by me (PM) }
+            if (sects[sec]^.len>0) and assigned(sects[sec]^.data) then
+              sechdr.datapos:=sects[sec]^.datapos;
+            sechdr.relocpos:=sects[sec]^.relocpos;
+            sechdr.nrelocs:=sects[sec]^.nrelocs;
+            sechdr.flags:=sects[sec]^.flags;
+            writer^.write(sechdr,sizeof(sechdr));
+          end;
+      { Sections }
+        for sec:=low(tsection) to high(tsection) do
+         if assigned(sects[sec]) and
+            assigned(sects[sec]^.data) then
+          begin
+            { For the stab section we need an HdrSym which can now be
+              calculated more easily }
+            if sec=sec_stab then
+             begin
+               pcoffstab(sects[sec_stab]^.data^.data)^.nvalue:=sects[sec_stabstr]^.len;
+               pcoffstab(sects[sec_stab]^.data^.data)^.strpos:=1;
+               pcoffstab(sects[sec_stab]^.data^.data)^.ndesc:=
+                 (sects[sec_stab]^.len div sizeof(coffstab))-1{+1 according to gas output PM};
+             end;
+            writer^.write(sects[sec]^.data^.data^,sects[sec]^.data^.usedsize);
+          end;
+      { Relocs }
+        for sec:=low(tsection) to high(tsection) do
+         if assigned(sects[sec]) then
+          write_relocs(sects[sec]);
+      { Symbols }
+        write_symbols;
+      { Strings }
+        i:=strs^.usedsize+4;
+        writer^.write(i,4);
+        writer^.write(strs^.data^,strs^.usedsize);
+      end;
+
+
+{****************************************************************************
+                            DJGppcoffoutput
+****************************************************************************}
+
+    constructor tdjgppcoffoutput.init;
+      begin
+        inherited init;
+        win32:=false;
+      end;
+
+    function tdjgppcoffoutput.text_flags : longint;
+      begin
+        text_flags:=$20;
+      end;
+
+    function tdjgppcoffoutput.data_flags : longint;
+      begin
+        data_flags:=$40;
+      end;
+
+    function tdjgppcoffoutput.bss_flags : longint;
+      begin
+        bss_flags:=$80;
+      end;
+
+    function tdjgppcoffoutput.info_flags : longint;
+      begin
+        writeln('djgpp coff doesn''t support info sections');
+        info_flags:=$40;
+      end;
+
+
+{****************************************************************************
+                            Win32coffoutput
+****************************************************************************}
+
+    constructor twin32coffoutput.init;
+      begin
+        inherited init;
+        win32:=true;
+      end;
+
+    function twin32coffoutput.text_flags : longint;
+      begin
+        text_flags:={ $60500020}$60300020{changed to get same as asw.exe (PM)};
+      end;
+
+    function twin32coffoutput.data_flags : longint;
+      begin
+        data_flags:=$c0300040;
+      end;
+
+    function twin32coffoutput.bss_flags : longint;
+      begin
+        bss_flags:=$c0300080;
+      end;
+
+    function twin32coffoutput.info_flags : longint;
+      begin
+        info_flags:=$100a00;
+      end;
+
+
+end.
+{
+  $Log$
+  Revision 1.1  1999-05-01 13:24:24  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.13  1999/03/18 20:30:49  peter
+    + .a writer
+
+  Revision 1.12  1999/03/12 00:20:06  pierre
+   + win32 output working !
+
+  Revision 1.11  1999/03/11 13:43:08  pierre
+   * more fixes for win32
+
+  Revision 1.10  1999/03/10 13:41:10  pierre
+   + partial implementation for win32 !
+     winhello works but pp still does not !
+
+  Revision 1.9  1999/03/08 14:51:09  peter
+    + smartlinking for ag386bin
+
+  Revision 1.8  1999/03/05 13:09:52  peter
+    * first things for tai_cut support for ag386bin
+
+  Revision 1.7  1999/03/04 13:44:58  pierre
+   * win32 pecoff sections datapos allways zero
+
+  Revision 1.6  1999/03/03 11:41:54  pierre
+    + stabs info corrected to give results near to GAS output
+    * local labels (with .L are not stored in object anymore)
+      so we get the same number of symbols as from GAS !
+
+  Revision 1.5  1999/03/03 01:36:46  pierre
+    + stabs output working (though not really tested)
+      for a simple file the only difference to GAS output is due
+      to the VMA of the different sections
+
+  Revision 1.4  1999/03/02 02:56:27  peter
+    + stabs support for binary writers
+    * more fixes and missing updates from the previous commit :(
+
+  Revision 1.3  1999/03/01 15:46:25  peter
+    * ag386bin finally make cycles correct
+    * prefixes are now also normal opcodes
+
+  Revision 1.2  1999/02/25 21:03:10  peter
+    * ag386bin updates
+    + coff writer
+
+}

+ 217 - 0
compiler/og386dbg.pas

@@ -0,0 +1,217 @@
+{
+    $Id$
+    Copyright (c) 1999 by Florian Klaempfl
+
+    Contains the 386 binary writer for debugging purposes
+
+    * This code was inspired by the NASM sources
+      The Netwide Assembler is copyright (C) 1996 Simon Tatham and
+      Julian Hall. All rights reserved.
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+unit og386dbg;
+
+  interface
+    uses
+       i386base,
+       aasm,
+       og386;
+
+    type
+       pdbgoutput = ^tdbgoutput;
+       tdbgoutput = object(tobjectoutput)
+         nsyms   : longint;
+         rawidx  : longint;
+         constructor init;
+         destructor  done;virtual;
+         procedure initwriting;virtual;
+         procedure donewriting;virtual;
+         procedure writebytes(var data;len:longint);virtual;
+         procedure writealloc(len:longint);virtual;
+         procedure writereloc(data,len:longint;p:pasmsymbol;relative:relative_type);virtual;
+         procedure writesymbol(p:pasmsymbol);virtual;
+         procedure writestabs(section:tsection;offset:longint;p:pchar;nidx,nother,line:longint;reloc:boolean);virtual;
+       end;
+
+  implementation
+
+{****************************************************************************
+                                Tdbgoutput
+****************************************************************************}
+
+      const
+        sec_2_str : array[tsection] of string[8]=('<none>',
+          '.text','.data','.bss',
+          '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
+          '.stab','.stabstr',''
+        );
+
+    constructor tdbgoutput.init;
+      begin
+        inherited init;
+        rawidx:=-1;
+        nsyms:=0;
+      end;
+
+
+    destructor tdbgoutput.done;
+      begin
+      end;
+
+
+    procedure tdbgoutput.initwriting;
+      begin
+        inherited initwriting;
+        writeln('initwriting '+Objfile);
+      end;
+
+
+    procedure tdbgoutput.donewriting;
+      begin
+        if rawidx<>-1 then
+         begin
+           writeln;
+           rawidx:=-1;
+         end;
+        writeln('donewriting');
+      end;
+
+
+    procedure tdbgoutput.writesymbol(p:pasmsymbol);
+      begin
+        if rawidx<>-1 then
+         begin
+           writeln;
+           rawidx:=-1;
+         end;
+        p^.idx:=nsyms;
+        write('symbol [',nsyms,'] '+p^.name+' (',sec_2_str[p^.section],',',p^.address,',',p^.size,',');
+        case p^.typ of
+          AS_LOCAL :
+            writeln('local)');
+          AS_GLOBAL :
+            writeln('global)');
+          AS_EXTERNAL :
+            writeln('extern)');
+        else
+          writeln('unknown)');
+        end;
+        inc(nsyms);
+      end;
+
+
+    procedure tdbgoutput.writereloc(data,len:longint;p:pasmsymbol;relative:relative_type);
+      begin
+        if rawidx<>-1 then
+         begin
+           writeln;
+           rawidx:=-1;
+         end;
+        if assigned(p) then
+          write('reloc: ',data,' [',sec_2_str[p^.section],',',p^.address,']')
+        else
+          write('reloc: ',data);
+        case relative of
+          relative_true : writeln(' relative');
+          relative_false: writeln(' not relative');
+          relative_rva  : writeln(' relative virtual address');
+        end;
+      end;
+
+
+    procedure tdbgoutput.writebytes(var data;len:longint);
+
+        function hexstr(val : longint;cnt : byte) : string;
+        const
+          HexTbl : array[0..15] of char='0123456789ABCDEF';
+        var
+          i : longint;
+        begin
+          hexstr[0]:=char(cnt);
+          for i:=cnt downto 1 do
+           begin
+             hexstr[i]:=hextbl[val and $f];
+             val:=val shr 4;
+           end;
+        end;
+
+      var
+        p : pchar;
+        i : longint;
+      begin
+        if len=0 then
+         exit;
+        p:=@data;
+        if rawidx=-1 then
+         begin
+           write('raw: ');
+           rawidx:=0;
+         end;
+        for i:=1to len do
+         begin
+           if rawidx>=16 then
+            begin
+              writeln;
+              write('raw: ');
+              rawidx:=0;
+            end;
+           write(hexstr(ord(p[i-1]),2),' ');
+           inc(rawidx);
+         end;
+      end;
+
+    procedure tdbgoutput.writealloc(len:longint);
+      begin
+        writeln('alloc: ',len);
+      end;
+
+    procedure tdbgoutput.writestabs(section:tsection;offset:longint;p:pchar;nidx,nother,line:longint;reloc:boolean);
+      begin
+        writeln('stabs: ',line,',',nidx,'"',p,'"');
+      end;
+
+
+end.
+{
+  $Log$
+  Revision 1.1  1999-05-01 13:24:24  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.6  1999/03/10 13:41:11  pierre
+   + partial implementation for win32 !
+     winhello works but pp still does not !
+
+  Revision 1.5  1999/03/08 14:51:10  peter
+    + smartlinking for ag386bin
+
+  Revision 1.4  1999/03/05 13:09:53  peter
+    * first things for tai_cut support for ag386bin
+
+  Revision 1.3  1999/03/02 02:56:28  peter
+    + stabs support for binary writers
+    * more fixes and missing updates from the previous commit :(
+
+  Revision 1.2  1999/02/25 21:03:11  peter
+    * ag386bin updates
+    + coff writer
+
+  Revision 1.1  1999/02/16 17:59:39  peter
+    + initial files
+
+}

+ 887 - 0
compiler/og386elf.pas

@@ -0,0 +1,887 @@
+{
+    $Id$
+    Copyright (c) 1999 by Florian Klaempfl
+
+    Contains the binary elf writer
+
+    * This code was inspired by the NASM sources
+      The Netwide Assembler is copyright (C) 1996 Simon Tatham and
+      Julian Hall. All rights reserved.
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+unit og386elf;
+
+{
+  Notes on COFF:
+
+  (0) When I say `standard COFF' below, I mean `COFF as output and
+  used by DJGPP'. I assume DJGPP gets it right.
+
+  (1) Win32 appears to interpret the term `relative relocation'
+  differently from standard COFF. Standard COFF understands a
+  relative relocation to mean that during relocation you add the
+  address of the symbol you're referencing, and subtract the base
+  address of the section you're in. Win32 COFF, by contrast, seems
+  to add the address of the symbol and then subtract the address
+  of THE BYTE AFTER THE RELOCATED DWORD. Hence the two formats are
+  subtly incompatible.
+
+  (2) Win32 doesn't bother putting any flags in the header flags
+  field (at offset 0x12 into the file).
+
+  (3) Win32 uses some extra flags into the section header table:
+  it defines flags 0x80000000 (writable), 0x40000000 (readable)
+  and 0x20000000 (executable), and uses them in the expected
+  combinations. It also defines 0x00100000 through 0x00700000 for
+  section alignments of 1 through 64 bytes.
+
+  (4) Both standard COFF and Win32 COFF seem to use the DWORD
+  field directly after the section name in the section header
+  table for something strange: they store what the address of the
+  section start point _would_ be, if you laid all the sections end
+  to end starting at zero. Dunno why. Microsoft's documentation
+  lists this field as "Virtual Size of Section", which doesn't
+  seem to fit at all. In fact, Win32 even includes non-linked
+  sections such as .drectve in this calculation.
+
+  (5) Standard COFF does something very strange to common
+  variables: the relocation point for a common variable is as far
+  _before_ the variable as its size stretches out _after_ it. So
+  we must fix up common variable references. Win32 seems to be
+  sensible on this one.
+}
+  interface
+
+    uses
+       cobjects,
+       og386,i386base,aasm;
+
+    type
+       preloc = ^treloc;
+       treloc = packed record
+          next     : preloc;
+          address  : longint;
+          symbol   : pasmsymbol;
+          section  : tsection; { only used if symbol=nil }
+          relative : relative_type;
+       end;
+
+       psymbol = ^tsymbol;
+       tsymbol = packed record
+         name    : string[8];
+         strpos  : longint;
+         section : longint;
+         value   : longint;
+         typ     : TAsmsymtype;
+       end;
+
+       pcoffsection = ^tcoffsection;
+       tcoffsection = object
+          index : tsection;
+          data  : PDynamicArray;
+          len,
+          pos,
+          datapos,
+          relocpos,
+          nrelocs,
+          flags     : longint;
+          relochead : PReloc;
+          reloctail : ^PReloc;
+          constructor init(sec:TSection;Aflags:longint);
+          destructor  done;
+          procedure  write(var d;l:longint);
+          procedure  alloc(l:longint);
+          procedure  addsymreloc(ofs:longint;p:pasmsymbol;relative:relative_type);
+          procedure  addsectionreloc(ofs:longint;sec:tsection);
+       end;
+
+       pgenericcoffoutput = ^tgenericcoffoutput;
+       tgenericcoffoutput = object(tobjectoutput)
+         win32   : boolean;
+         sects   : array[TSection] of PCoffSection;
+         strs,
+         syms    : Pdynamicarray;
+         initsym : longint;
+         constructor init;
+         destructor  done;virtual;
+         procedure initwriting;virtual;
+         procedure donewriting;virtual;
+         procedure writebytes(var data;len:longint);virtual;
+         procedure writealloc(len:longint);virtual;
+         procedure writereloc(data,len:longint;p:pasmsymbol;relative:relative_type);virtual;
+         procedure writesymbol(p:pasmsymbol);virtual;
+         procedure writestabs(section:tsection;offset:longint;p:pchar;nidx,nother,line:longint;reloc:boolean);virtual;
+
+         function  text_flags : longint;virtual;
+         function  data_flags : longint;virtual;
+         function  bss_flags : longint;virtual;
+         function  info_flags : longint;virtual;
+       private
+         procedure createsection(sec:tsection);
+         procedure write_relocs(s:pcoffsection);
+         procedure write_symbol(const name:string;strpos,value,section,typ,aux:longint);
+         procedure write_symbols;
+         procedure writetodisk;
+       end;
+
+       pdjgppcoffoutput = ^tdjgppcoffoutput;
+       tdjgppcoffoutput = object(tgenericcoffoutput)
+         constructor init;
+         function text_flags : longint;virtual;
+         function data_flags : longint;virtual;
+         function bss_flags : longint;virtual;
+         function info_flags : longint;virtual;
+       end;
+
+       pwin32coffoutput = ^twin32coffoutput;
+       twin32coffoutput = object(tgenericcoffoutput)
+         constructor init;
+         function text_flags : longint;virtual;
+         function data_flags : longint;virtual;
+         function bss_flags : longint;virtual;
+         function info_flags : longint;virtual;
+       end;
+
+  implementation
+
+      uses
+        strings,verbose,
+        globtype,globals,files;
+
+      type
+      { Structures which are written directly to the output file }
+        coffheader=packed record
+          mach   : word;
+          nsects : word;
+          time   : longint;
+          sympos : longint;
+          syms   : longint;
+          opthdr : word;
+          flag   : word;
+        end;
+        coffsechdr=packed record
+          name     : array[0..7] of char;
+          vsize    : longint;
+          rvaofs   : longint;
+          datalen  : longint;
+          datapos  : longint;
+          relocpos : longint;
+          lineno1  : longint;
+          nrelocs  : word;
+          lineno2  : word;
+          flags    : longint;
+        end;
+        coffsectionrec=packed record
+          len     : longint;
+          nrelocs : word;
+          empty   : array[0..11] of char;
+        end;
+        coffreloc=packed record
+          address  : longint;
+          sym      : longint;
+          relative : word;
+        end;
+        coffsymbol=packed record
+          name    : array[0..3] of char; { real is [0..7], which overlaps the strpos ! }
+          strpos  : longint;
+          value   : longint;
+          section : integer;
+          empty   : integer;
+          typ     : byte;
+          aux     : byte;
+        end;
+        pcoffstab=^coffstab;
+        coffstab=packed record
+          strpos  : longint;
+          ntype   : byte;
+          nother  : byte;
+          ndesc   : word;
+          nvalue  : longint;
+        end;
+
+
+      const
+        sec_2_str : array[tsection] of string[8]=('',
+          '.text','.data','.bss',
+          '.stab','.stabstr',
+          '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
+          ''
+        );
+
+
+{****************************************************************************
+                               TSection
+****************************************************************************}
+
+    constructor tcoffsection.init(sec:TSection;Aflags:longint);
+      begin
+        index:=sec;
+        flags:=AFlags;
+        relocHead:=nil;
+        relocTail:=@relocHead;
+        Len:=0;
+        NRelocs:=0;
+        if sec=sec_bss then
+         data:=nil
+        else
+         new(Data,Init(1,8192));
+      end;
+
+
+    destructor tcoffsection.done;
+      begin
+        if assigned(Data) then
+          dispose(Data,done);
+      end;
+
+
+    procedure  tcoffsection.write(var d;l:longint);
+      begin
+        if not assigned(Data) then
+         Internalerror(3334441);
+        Data^.write(d,l);
+        inc(len,l);
+      end;
+
+
+    procedure  tcoffsection.alloc(l:longint);
+      begin
+        if assigned(Data) then
+         Internalerror(3334442);
+        inc(len,l);
+      end;
+
+
+    procedure tcoffsection.addsymreloc(ofs:longint;p:pasmsymbol;relative:relative_type);
+      var
+        r : PReloc;
+      begin
+        new(r);
+        reloctail^:=r;
+        reloctail:=@r^.next;
+        r^.next:=nil;
+        r^.address:=ofs;
+        r^.symbol:=p;
+        r^.section:=sec_none;
+        r^.relative:=relative;
+        inc(nrelocs);
+      end;
+
+
+    procedure tcoffsection.addsectionreloc(ofs:longint;sec:tsection);
+      var
+        r : PReloc;
+      begin
+        new(r);
+        reloctail^:=r;
+        reloctail:=@r^.next;
+        r^.next:=nil;
+        r^.address:=ofs;
+        r^.symbol:=nil;
+        r^.section:=sec;
+        r^.relative:=relative_false;
+        inc(nrelocs);
+      end;
+
+
+{****************************************************************************
+                            Genericcoffoutput
+****************************************************************************}
+
+    const
+{$ifdef TP}
+      symbolresize = 50;
+      strsresize   = 200;
+{$else}
+      symbolresize = 200;
+      strsresize   = 8192;
+{$endif}
+
+    constructor tgenericcoffoutput.init;
+      begin
+        inherited init;
+      end;
+
+
+    destructor tgenericcoffoutput.done;
+      begin
+        inherited done;
+      end;
+
+
+    procedure tgenericcoffoutput.initwriting;
+      var
+        s : string;
+      begin
+        inherited initwriting;
+        { reset }
+        initsym:=0;
+        new(syms,init(sizeof(TSymbol),symbolresize));
+        new(strs,init(1,strsresize));
+        FillChar(Sects,sizeof(Sects),0);
+        { we need at least the following 3 sections }
+        createsection(sec_code);
+        createsection(sec_data);
+        createsection(sec_bss);
+        if (cs_debuginfo in aktmoduleswitches) then
+         begin
+           createsection(sec_stab);
+           createsection(sec_stabstr);
+           writestabs(sec_none,0,nil,0,0,0,false);
+           { write zero pchar and name together (PM) }
+           s:=#0+SplitFileName(current_module^.mainsource^)+#0;
+           sects[sec_stabstr]^.write(s[1],length(s));
+         end;
+      end;
+
+
+    procedure tgenericcoffoutput.donewriting;
+      var
+        sec : tsection;
+      begin
+        writetodisk;
+        dispose(syms,done);
+        dispose(strs,done);
+        for sec:=low(tsection) to high(tsection) do
+         if assigned(sects[sec]) then
+          dispose(sects[sec],done);
+        inherited donewriting;
+      end;
+
+
+    function tgenericcoffoutput.text_flags : longint;
+      begin
+        text_flags:=0;
+      end;
+
+    function tgenericcoffoutput.data_flags : longint;
+      begin
+        data_flags:=0;
+      end;
+
+    function tgenericcoffoutput.bss_flags : longint;
+      begin
+        bss_flags:=0;
+      end;
+
+    function tgenericcoffoutput.info_flags : longint;
+      begin
+        info_flags:=0;
+      end;
+
+
+    procedure tgenericcoffoutput.createsection(sec:TSection);
+      var
+        Aflags : longint;
+      begin
+        Aflags:=0;
+        case sec of
+          sec_code :
+            Aflags:=text_flags;
+          sec_data :
+            Aflags:=data_flags;
+          sec_bss :
+            Aflags:=bss_flags;
+        { sec_info :
+            Aflags:=info_flags; }
+          else
+            Aflags:=0;
+        end;
+        sects[sec]:=new(PcoffSection,init(Sec,Aflags));
+      end;
+
+
+    procedure tgenericcoffoutput.writesymbol(p:pasmsymbol);
+      var
+        pos : longint;
+        sym : tsymbol;
+        c   : char;
+        s   : string;
+      begin
+        { already written ? }
+        if p^.idx<>-1 then
+         exit;
+        { be sure that the section will exists }
+        if (p^.section<>sec_none) and not(assigned(sects[p^.section])) then
+          createsection(p^.section);
+        { symbolname }
+        pos:=strs^.usedsize+4;
+        c:=#0;
+        s:=p^.name;
+        if length(s)>8 then
+         begin
+           s:=s+#0;
+           strs^.write(s[1],length(s));
+         end
+        else
+         pos:=-1;
+        FillChar(sym,sizeof(sym),0);
+        sym.strpos:=pos;
+        if pos=-1 then
+         sym.name:=s;
+        sym.value:=p^.size;
+        sym.typ:=p^.typ;
+        { if local of global then set the section value to the address
+          of the symbol }
+        if p^.typ in [AS_LOCAL,AS_GLOBAL] then
+         begin
+           sym.section:=ord(p^.section);
+           sym.value:=p^.address;
+         end;
+        { update the asmsymbol index }
+        p^.idx:=syms^.count;
+        { store the symbol, but not the local ones (PM) }
+        if (p^.typ<>AS_LOCAL) or ((copy(s,1,2)<>'.L') and
+          ((copy(s,1,1)<>'L') or not win32)) then
+          syms^.write(sym,1);
+        { make the exported syms known to the objectwriter
+          (needed for .a generation) }
+        if (p^.typ=AS_GLOBAL) or
+           ((p^.typ=AS_EXTERNAL) and (sym.value=p^.size) and (sym.value>0)) then
+          writer^.writesym(p^.name);
+      end;
+
+
+    procedure tgenericcoffoutput.writebytes(var data;len:longint);
+      begin
+        if not assigned(sects[currsec]) then
+         createsection(currsec);
+        sects[currsec]^.write(data,len);
+      end;
+
+
+    procedure tgenericcoffoutput.writealloc(len:longint);
+      begin
+        if not assigned(sects[currsec]) then
+         createsection(currsec);
+        sects[currsec]^.alloc(len);
+      end;
+
+
+    procedure tgenericcoffoutput.writereloc(data,len:longint;p:pasmsymbol;relative:relative_type);
+      begin
+        if not assigned(sects[currsec]) then
+         createsection(currsec);
+        if assigned(p) then
+         begin
+           { no symbol relocation need inside a section }
+           if p^.section=currsec then
+             begin
+               if relative=relative_false then
+                 begin
+                   sects[currsec]^.addsectionreloc(sects[currsec]^.len,currsec);
+                   inc(data,p^.address);
+                 end
+               else if relative=relative_true then
+                 begin
+                   inc(data,p^.address-len-sects[currsec]^.len);
+                 end
+               else if relative=relative_rva then
+                 begin
+                   { don't know if this can happens !! }
+                   { does this work ?? }
+                   sects[currsec]^.addsectionreloc(sects[currsec]^.len,currsec);
+                   inc(data,p^.address);
+                 end;
+             end
+           else
+             begin
+               writesymbol(p);
+               if (p^.section<>sec_none) and (relative=relative_false) then
+                 begin
+                   sects[currsec]^.addsectionreloc(sects[currsec]^.len,p^.section);
+                 end
+               else
+                 sects[currsec]^.addsymreloc(sects[currsec]^.len,p,relative);
+               if not win32 then {seems wrong to me (PM) }
+                begin
+                  {if p^.section<>sec_none then
+                    this is the cause of the strange
+                    feature see Note (5) before
+                    address contains the size for
+                    global vars switched to common }
+                    inc(data,p^.address);
+                end
+               else
+                if (relative<>relative_true) and (p^.section<>sec_none) then
+                 inc(data,p^.address);
+               if relative=relative_true then
+                begin
+                  if win32 then
+                    {inc(data,4-len)}
+                    dec(data,len-4{+p^.address})
+                  else
+                    dec(data,len+sects[currsec]^.len);
+                end;
+            end;
+         end;
+        sects[currsec]^.write(data,len);
+      end;
+
+
+    procedure tgenericcoffoutput.writestabs(section:tsection;offset:longint;p:pchar;nidx,nother,line:longint;reloc : boolean);
+      var
+        stab : coffstab;
+        s : tsection;
+      begin
+        if section=sec_none then
+         s:=currsec
+        else
+         s:=section;
+        { local var can be at offset -1 !! PM }
+        if (offset=-1) and reloc then
+         begin
+           if s=sec_none then
+            offset:=0
+           else
+            offset:=sects[s]^.len;
+         end;
+        fillchar(stab,sizeof(coffstab),0);
+        if assigned(p) and (p[0]<>#0) then
+         begin
+           stab.strpos:=sects[sec_stabstr]^.len;
+           sects[sec_stabstr]^.write(p^,strlen(p)+1);
+         end;
+        stab.ntype:=nidx;
+        stab.ndesc:=line;
+        stab.nother:=nother;
+        stab.nvalue:=offset;
+        sects[sec_stab]^.write(stab,sizeof(stab));
+        { when the offset is not 0 then write a relocation, take also the
+          hdrstab into account with the offset }
+        if reloc then
+          sects[sec_stab]^.addsectionreloc(sects[sec_stab]^.len-4,s);
+      end;
+
+
+    procedure tgenericcoffoutput.write_relocs(s:pcoffsection);
+      var
+        rel  : coffreloc;
+        hr,r : preloc;
+      begin
+        r:=s^.relochead;
+        while assigned(r) do
+         begin
+           rel.address:=r^.address;
+           if assigned(r^.symbol) then
+            begin
+              if (r^.symbol^.typ=AS_LOCAL) then
+               rel.sym:=2*ord(r^.symbol^.section)
+              else
+               rel.sym:=r^.symbol^.idx+initsym;
+            end
+           else
+            rel.sym:=2*ord(r^.section);
+           case r^.relative of
+             relative_true  : rel.relative:=$14;
+             relative_false : rel.relative:=$6;
+             relative_rva   : rel.relative:=$7;
+           end;
+           writer^.write(rel,sizeof(rel));
+           { goto next and dispose this reloc }
+           hr:=r;
+           r:=r^.next;
+           dispose(hr);
+         end;
+      end;
+
+
+    procedure tgenericcoffoutput.write_symbol(const name:string;strpos,value,section,typ,aux:longint);
+      var
+        sym : coffsymbol;
+      begin
+        FillChar(sym,sizeof(sym),0);
+        if strpos=-1 then
+         move(name[1],sym.name,length(name))
+        else
+         sym.strpos:=strpos;
+        sym.value:=value;
+        sym.section:=section;
+        sym.typ:=typ;
+        sym.aux:=aux;
+        writer^.write(sym,sizeof(sym));
+      end;
+
+
+    procedure tgenericcoffoutput.write_symbols;
+      var
+        filename : string[18];
+        sec : tsection;
+        i   : longint;
+        globalval : byte;
+        secrec : coffsectionrec;
+        sym : tsymbol;
+      begin
+        { The `.file' record, and the file name auxiliary record. }
+        write_symbol ('.file', -1, 0, -2, $67, 1);
+        fillchar(filename,sizeof(filename),0);
+        filename:=SplitFileName(current_module^.mainsource^);
+        writer^.write(filename[1],sizeof(filename)-1);
+        { The section records, with their auxiliaries }
+        i:=0;
+        for sec:=low(tsection) to high(tsection) do
+         if assigned(sects[sec]) then
+          begin
+            inc(i);
+            write_symbol(sec_2_str[sec],-1,{sects[sec]^.pos}0,i,3,1);
+            fillchar(secrec,sizeof(secrec),0);
+            secrec.len:=sects[sec]^.len;
+            secrec.nrelocs:=sects[sec]^.nrelocs;
+            writer^.write(secrec,sizeof(secrec));
+          end;
+        { The real symbols. }
+        syms^.seek(0);
+        for i:=1 to syms^.count do
+         begin
+           syms^.read(sym,1);
+           if sym.typ=AS_LOCAL then
+             globalval:=3
+           else
+             globalval:=2;
+           write_symbol(sym.name,sym.strpos,sym.value,sym.section,globalval,0);
+         end;
+      end;
+
+
+    procedure tgenericcoffoutput.writetodisk;
+      var
+        datapos,
+        nsects,pos,sympos,i,fillsize : longint;
+        sec    : tsection;
+        header : coffheader;
+        sechdr : coffsechdr;
+        empty  : array[0..15] of byte;
+      begin
+      { calc amount of sections we have and align sections at 4 bytes }
+        fillchar(empty,sizeof(empty),0);
+        nsects:=0;
+        for sec:=low(tsection) to high(tsection) do
+        { .stabstr section length must be without alignment !! }
+         if assigned(sects[sec]) then
+          begin
+          { fill with zero }
+            fillsize:=4-(sects[sec]^.len and 3);
+            if fillsize<>4 then
+             begin
+               if assigned(sects[sec]^.data) then
+                 sects[sec]^.write(empty,fillsize)
+               else
+                 sects[sec]^.alloc(fillsize);
+               { .stabstr section length must be without alignment !! }
+               if (sec=sec_stabstr) then
+                 dec(sects[sec]^.len,fillsize);
+             end;
+            inc(nsects);
+          end;
+      { Calculate the filepositions }
+        datapos:=sizeof(coffheader)+sizeof(coffsechdr)*nsects;
+        pos:=0;
+        initsym:=2; { 2 for the file }
+        { sections first }
+        for sec:=low(tsection) to high(tsection) do
+         if assigned(sects[sec]) then
+          begin
+            sects[sec]^.pos:=pos;
+            sects[sec]^.datapos:=datapos;
+            inc(pos,sects[sec]^.len);
+            if assigned(sects[sec]^.data) then
+              inc(datapos,sects[sec]^.len);
+            { align after stabstr section !! }
+            if (sec=sec_stabstr) and ((sects[sec]^.len and 3)<>0) then
+              inc(datapos,4-(sects[sec]^.len and 3));
+            inc(initsym,2); { 2 for each section }
+          end;
+        { relocs }
+        for sec:=low(tsection) to high(tsection) do
+         if assigned(sects[sec]) then
+          begin
+            sects[sec]^.relocpos:=datapos;
+            inc(datapos,10*sects[sec]^.nrelocs);
+          end;
+        { symbols }
+        sympos:=datapos;
+      { COFF header }
+        fillchar(header,sizeof(coffheader),0);
+        header.mach:=$14c;
+        header.nsects:=nsects;
+        header.sympos:=sympos;
+        header.syms:=syms^.count+initsym;
+        if not win32 then
+         header.flag:=$104;
+        writer^.write(header,sizeof(header));
+      { Section headers }
+        for sec:=low(tsection) to high(tsection) do
+         if assigned(sects[sec]) then
+          begin
+            fillchar(sechdr,sizeof(sechdr),0);
+            move(sec_2_str[sec][1],sechdr.name,length(sec_2_str[sec]));
+            if not win32 then
+              sechdr.vsize:=sects[sec]^.pos
+            else if sec=sec_bss then
+              sechdr.vsize:=sects[sec]^.len;
+            sechdr.datalen:=sects[sec]^.len;
+            { apparently win32 asw leaves section at datapos zero }
+            { this was an error by me (PM) }
+            if (sects[sec]^.len>0) and assigned(sects[sec]^.data) then
+              sechdr.datapos:=sects[sec]^.datapos;
+            sechdr.relocpos:=sects[sec]^.relocpos;
+            sechdr.nrelocs:=sects[sec]^.nrelocs;
+            sechdr.flags:=sects[sec]^.flags;
+            writer^.write(sechdr,sizeof(sechdr));
+          end;
+      { Sections }
+        for sec:=low(tsection) to high(tsection) do
+         if assigned(sects[sec]) and
+            assigned(sects[sec]^.data) then
+          begin
+            { For the stab section we need an HdrSym which can now be
+              calculated more easily }
+            if sec=sec_stab then
+             begin
+               pcoffstab(sects[sec_stab]^.data^.data)^.nvalue:=sects[sec_stabstr]^.len;
+               pcoffstab(sects[sec_stab]^.data^.data)^.strpos:=1;
+               pcoffstab(sects[sec_stab]^.data^.data)^.ndesc:=
+                 (sects[sec_stab]^.len div sizeof(coffstab))-1{+1 according to gas output PM};
+             end;
+            writer^.write(sects[sec]^.data^.data^,sects[sec]^.data^.usedsize);
+          end;
+      { Relocs }
+        for sec:=low(tsection) to high(tsection) do
+         if assigned(sects[sec]) then
+          write_relocs(sects[sec]);
+      { Symbols }
+        write_symbols;
+      { Strings }
+        i:=strs^.usedsize+4;
+        writer^.write(i,4);
+        writer^.write(strs^.data^,strs^.usedsize);
+      end;
+
+
+{****************************************************************************
+                            DJGppcoffoutput
+****************************************************************************}
+
+    constructor tdjgppcoffoutput.init;
+      begin
+        inherited init;
+        win32:=false;
+      end;
+
+    function tdjgppcoffoutput.text_flags : longint;
+      begin
+        text_flags:=$20;
+      end;
+
+    function tdjgppcoffoutput.data_flags : longint;
+      begin
+        data_flags:=$40;
+      end;
+
+    function tdjgppcoffoutput.bss_flags : longint;
+      begin
+        bss_flags:=$80;
+      end;
+
+    function tdjgppcoffoutput.info_flags : longint;
+      begin
+        writeln('djgpp coff doesn''t support info sections');
+        info_flags:=$40;
+      end;
+
+
+{****************************************************************************
+                            Win32coffoutput
+****************************************************************************}
+
+    constructor twin32coffoutput.init;
+      begin
+        inherited init;
+        win32:=true;
+      end;
+
+    function twin32coffoutput.text_flags : longint;
+      begin
+        text_flags:={ $60500020}$60300020{changed to get same as asw.exe (PM)};
+      end;
+
+    function twin32coffoutput.data_flags : longint;
+      begin
+        data_flags:=$c0300040;
+      end;
+
+    function twin32coffoutput.bss_flags : longint;
+      begin
+        bss_flags:=$c0300080;
+      end;
+
+    function twin32coffoutput.info_flags : longint;
+      begin
+        info_flags:=$100a00;
+      end;
+
+
+end.
+{
+  $Log$
+  Revision 1.1  1999-05-01 13:24:24  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.12  1999/03/12 00:20:06  pierre
+   + win32 output working !
+
+  Revision 1.11  1999/03/11 13:43:08  pierre
+   * more fixes for win32
+
+  Revision 1.10  1999/03/10 13:41:10  pierre
+   + partial implementation for win32 !
+     winhello works but pp still does not !
+
+  Revision 1.9  1999/03/08 14:51:09  peter
+    + smartlinking for ag386bin
+
+  Revision 1.8  1999/03/05 13:09:52  peter
+    * first things for tai_cut support for ag386bin
+
+  Revision 1.7  1999/03/04 13:44:58  pierre
+   * win32 pecoff sections datapos allways zero
+
+  Revision 1.6  1999/03/03 11:41:54  pierre
+    + stabs info corrected to give results near to GAS output
+    * local labels (with .L are not stored in object anymore)
+      so we get the same number of symbols as from GAS !
+
+  Revision 1.5  1999/03/03 01:36:46  pierre
+    + stabs output working (though not really tested)
+      for a simple file the only difference to GAS output is due
+      to the VMA of the different sections
+
+  Revision 1.4  1999/03/02 02:56:27  peter
+    + stabs support for binary writers
+    * more fixes and missing updates from the previous commit :(
+
+  Revision 1.3  1999/03/01 15:46:25  peter
+    * ag386bin finally make cycles correct
+    * prefixes are now also normal opcodes
+
+  Revision 1.2  1999/02/25 21:03:10  peter
+    * ag386bin updates
+    + coff writer
+
+}

+ 283 - 0
compiler/owar.pas

@@ -0,0 +1,283 @@
+{
+    $Id$
+    Copyright (c) 1999 by Peter Vreman
+
+    Contains the stuff for writing .a files directly
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+unit owar;
+interface
+
+uses
+  cobjects,owbase;
+
+type
+  tarhdr=packed record
+    name : array[0..15] of char;
+    date : array[0..11] of char;
+    uid  : array[0..5] of char;
+    gid  : array[0..5] of char;
+    mode : array[0..7] of char;
+    size : array[0..9] of char;
+    fmag : array[0..1] of char;
+  end;
+
+  parobjectwriter=^tarobjectwriter;
+  tarobjectwriter=object(tobjectwriter)
+    constructor Init(const Aarfn:string);
+    destructor  Done;virtual;
+    procedure create(const fn:string);virtual;
+    procedure close;virtual;
+    procedure writesym(sym:string);virtual;
+    procedure write(var b;len:longint);virtual;
+  private
+    arfn   : string;
+    arhdr  : tarhdr;
+    symreloc,
+    symstr,
+    lfnstr,
+    ardata,
+    objdata : PDynamicArray;
+    objfixup : longint;
+    objfn   : string;
+    timestamp : string[12];
+    procedure createarhdr(fn:string;size:longint;const gid,uid,mode:string);
+    procedure writear;
+  end;
+
+
+implementation
+
+uses
+  dos;
+
+const
+{$ifdef TP}
+  symrelocbufsize = 32;
+  symstrbufsize = 256;
+  lfnstrbufsize = 256;
+  arbufsize  = 256;
+  objbufsize = 256;
+{$else}
+  symrelocbufsize = 1024;
+  symstrbufsize = 8192;
+  lfnstrbufsize = 4096;
+  arbufsize  = 65536;
+  objbufsize = 16384;
+{$endif}
+
+{*****************************************************************************
+                                   Helpers
+*****************************************************************************}
+
+const
+  C1970=2440588;
+  D0=1461;
+  D1=146097;
+  D2=1721119;
+Function Gregorian2Julian(DT:DateTime):LongInt;
+Var
+  Century,XYear,Month : LongInt;
+Begin
+  Month:=DT.Month;
+  If Month<=2 Then
+   Begin
+     Dec(DT.Year);
+     Inc(Month,12);
+   End;
+  Dec(Month,3);
+  Century:=(longint(DT.Year Div 100)*D1) shr 2;
+  XYear:=(longint(DT.Year Mod 100)*D0) shr 2;
+  Gregorian2Julian:=((((Month*153)+2) div 5)+DT.Day)+D2+XYear+Century;
+End;
+
+function DT2Unix(DT:DateTime):LongInt;
+Begin
+  DT2Unix:=(Gregorian2Julian(DT)-C1970)*86400+(LongInt(DT.Hour)*3600)+(DT.Min*60)+DT.Sec;
+end;
+
+
+{*****************************************************************************
+                                TArObjectWriter
+*****************************************************************************}
+
+constructor tarobjectwriter.init(const Aarfn:string);
+var
+  time  : datetime;
+  dummy : word;
+begin
+  arfn:=Aarfn;
+  new(arData,init(1,arbufsize));
+  new(symreloc,init(4,symrelocbufsize));
+  new(symstr,init(1,symstrbufsize));
+  new(lfnstr,init(1,lfnstrbufsize));
+{ create timestamp }
+  getdate(time.year,time.month,time.day,dummy);
+  gettime(time.hour,time.min,time.sec,dummy);
+  Str(DT2Unix(time),timestamp);
+end;
+
+
+destructor tarobjectwriter.done;
+begin
+  writear;
+  dispose(arData,done);
+  dispose(symreloc,done);
+  dispose(symstr,done);
+  dispose(lfnstr,done);
+end;
+
+
+procedure tarobjectwriter.createarhdr(fn:string;size:longint;const gid,uid,mode:string);
+var
+  tmp : string[9];
+begin
+  fillchar(arhdr,sizeof(tarhdr),' ');
+{ create ar header }
+  fn:=fn+'/';
+  if length(fn)>16 then
+   begin
+     arhdr.name[0]:='/';
+     str(lfnstr^.usedsize,tmp);
+     move(tmp[1],arhdr.name[1],length(tmp));
+     fn:=fn+#10;
+     lfnstr^.write(fn[1],length(fn));
+   end
+  else
+   move(fn[1],arhdr.name,length(fn));
+  { don't write a date if also no gid/uid/mode is specified }
+  if gid<>'' then
+    move(timestamp[1],arhdr.date,sizeof(timestamp));
+  str(size,tmp);
+  move(tmp[1],arhdr.size,length(tmp));
+  move(gid[1],arhdr.gid,length(gid));
+  move(uid[1],arhdr.uid,length(uid));
+  move(mode[1],arhdr.mode,length(mode));
+  arhdr.fmag:='`'#10;
+end;
+
+
+procedure tarobjectwriter.create(const fn:string);
+begin
+  objfn:=fn;
+  objfixup:=ardata^.usedsize;
+{ reset size }
+  new(objdata,init(1,objbufsize));
+end;
+
+
+procedure tarobjectwriter.close;
+begin
+  objdata^.align(2);
+{ fix the size in the header }
+  createarhdr(objfn,objdata^.usedsize,'42','42','644');
+{ write the header }
+  ardata^.write(arhdr,sizeof(tarhdr));
+{ write the data of this objfile }
+  ardata^.write(objdata^.data^,objdata^.usedsize);
+{ free this object }
+  dispose(objdata,done);
+end;
+
+
+procedure tarobjectwriter.writesym(sym:string);
+begin
+  sym:=sym+#0;
+  symreloc^.write(objfixup,1);
+  symstr^.write(sym[1],length(sym));
+end;
+
+
+procedure tarobjectwriter.write(var b;len:longint);
+begin
+  objdata^.write(b,len);
+end;
+
+
+procedure tarobjectwriter.writear;
+
+  function lsb2msb(l:longint):longint;
+  type
+    bytearr=array[0..3] of byte;
+  var
+    l1 : longint;
+  begin
+    bytearr(l1)[0]:=bytearr(l)[3];
+    bytearr(l1)[1]:=bytearr(l)[2];
+    bytearr(l1)[2]:=bytearr(l)[1];
+    bytearr(l1)[3]:=bytearr(l)[0];
+    lsb2msb:=l1;
+  end;
+
+const
+  armagic:array[1..8] of char='!<arch>'#10;
+type
+  plongint=^longint;
+var
+  arf : file;
+  fixup,
+  relocs,i : longint;
+begin
+  assign(arf,arfn);
+  {$I-}
+   rewrite(arf,1);
+  {$I+}
+  if ioresult<>0 then
+   exit;
+  blockwrite(arf,armagic,sizeof(armagic));
+  { align first, because we need the size for the fixups of the symbol reloc }
+  if lfnstr^.usedsize>0 then
+   lfnstr^.align(2);
+  if symreloc^.usedsize>0 then
+   begin
+     symstr^.align(2);
+     fixup:=12+sizeof(tarhdr)+symreloc^.usedsize+symstr^.usedsize;
+     if lfnstr^.usedsize>0 then
+      inc(fixup,lfnstr^.usedsize+sizeof(tarhdr));
+     relocs:=symreloc^.count;
+     for i:=0to relocs-1 do
+      plongint(@symreloc^.data[i*4])^:=lsb2msb(plongint(@symreloc^.data[i*4])^+fixup);
+     createarhdr('',4+symreloc^.usedsize+symstr^.usedsize,'0','0','0');
+     blockwrite(arf,arhdr,sizeof(tarhdr));
+     relocs:=lsb2msb(relocs);
+     blockwrite(arf,relocs,4);
+     blockwrite(arf,symreloc^.data^,symreloc^.usedsize);
+     blockwrite(arf,symstr^.data^,symstr^.usedsize);
+   end;
+  if lfnstr^.usedsize>0 then
+   begin
+     createarhdr('/',lfnstr^.usedsize,'','','');
+     blockwrite(arf,arhdr,sizeof(tarhdr));
+     blockwrite(arf,lfnstr^.data^,lfnstr^.usedsize);
+   end;
+  blockwrite(arf,ardata^.data^,ardata^.usedsize);
+  system.close(arf);
+end;
+
+
+end.
+{
+  $Log$
+  Revision 1.1  1999-05-01 13:24:26  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.1  1999/03/18 20:30:51  peter
+    + .a writer
+
+}

+ 146 - 0
compiler/owbase.pas

@@ -0,0 +1,146 @@
+{
+    $Id$
+    Copyright (c) 1999 by Peter Vreman
+
+    Contains the base stuff for writing for object files to disk
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+unit owbase;
+interface
+
+type
+  pobjectwriter=^tobjectwriter;
+  tobjectwriter=object
+    constructor Init;
+    destructor  Done;virtual;
+    procedure create(const fn:string);virtual;
+    procedure close;virtual;
+    procedure writesym(sym:string);virtual;
+    procedure write(var b;len:longint);virtual;
+  private
+    f      : file;
+    opened : boolean;
+    buf    : pchar;
+    bufidx : longint;
+    procedure writebuf;
+  end;
+
+
+implementation
+
+const
+{$ifdef TP}
+  bufsize = 256;
+{$else}
+  bufsize = 32768;
+{$endif}
+
+
+constructor tobjectwriter.init;
+begin
+  getmem(buf,bufsize);
+  bufidx:=0;
+  opened:=false;
+end;
+
+
+destructor tobjectwriter.done;
+begin
+  if opened then
+   close;
+  freemem(buf,bufsize);
+end;
+
+
+procedure tobjectwriter.create(const fn:string);
+begin
+  assign(f,fn);
+  {$I-}
+   rewrite(f,1);
+  {$I+}
+  if ioresult<>0 then
+   exit;
+  bufidx:=0;
+  opened:=true;
+end;
+
+
+procedure tobjectwriter.close;
+begin
+  if bufidx>0 then
+   writebuf;
+  system.close(f);
+  opened:=false;
+end;
+
+
+procedure tobjectwriter.writebuf;
+begin
+  blockwrite(f,buf^,bufidx);
+  bufidx:=0;
+end;
+
+
+procedure tobjectwriter.writesym(sym:string);
+begin
+end;
+
+
+procedure tobjectwriter.write(var b;len:longint);
+var
+  p   : pchar;
+  left,
+  idx : longint;
+begin
+  p:=pchar(@b);
+  idx:=0;
+  while len>0 do
+   begin
+     left:=bufsize-bufidx;
+     if len>left then
+      begin
+        move(p[idx],buf[bufidx],left);
+        dec(len,left);
+        inc(idx,left);
+        inc(bufidx,left);
+        writebuf;
+      end
+     else
+      begin
+        move(p[idx],buf[bufidx],len);
+        inc(bufidx,len);
+        exit;
+      end;
+   end;
+end;
+
+
+end.
+{
+  $Log$
+  Revision 1.1  1999-05-01 13:24:26  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.2  1999/03/18 20:30:51  peter
+    + .a writer
+
+  Revision 1.1  1999/03/08 14:51:11  peter
+    + smartlinking for ag386bin
+
+}

+ 6 - 2
compiler/pass_1.pas

@@ -43,7 +43,7 @@ implementation
       tcadd,tccal,tccnv,tccon,tcflw,
       tcinl,tcld,tcmat,tcmem,tcset
 {$ifdef i386}
-{$ifdef Ag386Bin}
+{$ifndef OLDASM}
       ,i386base,i386asm
 {$else}
       ,i386
@@ -372,7 +372,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.100  1999-02-22 02:44:07  peter
+  Revision 1.101  1999-05-01 13:24:26  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.100  1999/02/22 02:44:07  peter
     * ag386bin doesn't use i386.pas anymore
 
   Revision 1.99  1998/12/11 00:03:27  peter

+ 8 - 4
compiler/pass_2.pas

@@ -49,7 +49,7 @@ implementation
      ,gdb
 {$endif}
 {$ifdef i386}
-{$ifdef Ag386Bin}
+{$ifndef OLDASM}
      ,i386base,i386asm
 {$else}
      ,i386
@@ -120,7 +120,7 @@ implementation
 
 
     procedure secondasm(var p : ptree);
-{$ifdef AG386BIN}
+{$ifndef OLDASM}
       var
         hp,hp2 : pai;
         localfixup,parafixup,
@@ -128,7 +128,7 @@ implementation
         r : preference;
 {$endif}
       begin
-{$ifdef AG386BIN}
+{$ifndef OLDASM}
          if (aktprocsym^.definition^.options and poinline)<>0 then
            begin
              localfixup:=aktprocsym^.definition^.localst^.address_fixup;
@@ -547,7 +547,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.18  1999-04-28 06:02:04  florian
+  Revision 1.19  1999-05-01 13:24:28  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.18  1999/04/28 06:02:04  florian
     * changes of Bruessel:
        + message handler can now take an explicit self
        * typinfo fixed: sometimes the type names weren't written

+ 6 - 2
compiler/pdecl.pas

@@ -64,7 +64,7 @@ unit pdecl;
        ,pbase,ptconst,pexpr,psub,pexports
        { processor specific stuff }
 {$ifdef i386}
-{$ifdef Ag386Bin}
+{$ifndef OLDASM}
        ,i386base
 {$else}
        ,i386
@@ -2272,7 +2272,11 @@ unit pdecl;
 end.
 {
   $Log$
-  Revision 1.112  1999-04-28 06:02:07  florian
+  Revision 1.113  1999-05-01 13:24:30  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.112  1999/04/28 06:02:07  florian
     * changes of Bruessel:
        + message handler can now take an explicit self
        * typinfo fixed: sometimes the type names weren't written

+ 6 - 2
compiler/pexpr.pas

@@ -53,7 +53,7 @@ unit pexpr;
        ,pbase,pdecl
        { processor specific stuff }
 {$ifdef i386}
-{$ifdef ag386bin}
+{$ifndef OLDASM}
        ,i386base
 {$else}
        ,i386
@@ -1972,7 +1972,11 @@ unit pexpr;
 end.
 {
   $Log$
-  Revision 1.98  1999-04-26 18:29:56  peter
+  Revision 1.99  1999-05-01 13:24:31  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.98  1999/04/26 18:29:56  peter
     * farpointerdef moved into pointerdef.is_far
 
   Revision 1.97  1999/04/19 09:27:48  peter

+ 6 - 2
compiler/pmodules.pas

@@ -38,7 +38,7 @@ unit pmodules;
        symtable,aasm,hcodegen,
        link,assemble,import,export,gendef,ppu,comprsrc
 {$ifdef i386}
-{$ifdef Ag386Bin}
+{$ifndef OLDASM}
        ,i386base,i386asm
 {$else}       ,i386
 {$endif}
@@ -1359,7 +1359,11 @@ unit pmodules;
 end.
 {
   $Log$
-  Revision 1.116  1999-04-26 23:22:42  peter
+  Revision 1.117  1999-05-01 13:24:32  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.116  1999/04/26 23:22:42  peter
     * fixed double .o file insertion
 
   Revision 1.115  1999/04/26 18:29:58  peter

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 350 - 510
compiler/popt386.pas


+ 6 - 2
compiler/pstatmnt.pas

@@ -44,7 +44,7 @@ unit pstatmnt;
        symtable,aasm,pass_1,types,scanner,hcodegen,ppu
        ,pbase,pexpr,pdecl
 {$ifdef i386}
-{$ifdef Ag386Bin}
+{$ifndef OLDASM}
        ,i386base,i386asm
 {$else}
        ,i386
@@ -1283,7 +1283,11 @@ unit pstatmnt;
 end.
 {
   $Log$
-  Revision 1.81  1999-04-26 13:31:42  peter
+  Revision 1.82  1999-05-01 13:24:35  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.81  1999/04/26 13:31:42  peter
     * release storenumber,double_checksum
 
   Revision 1.80  1999/04/21 09:43:48  peter

+ 6 - 2
compiler/ptconst.pas

@@ -41,7 +41,7 @@ unit ptconst;
        ,pbase,pexpr
        { processor specific stuff }
 {$ifdef i386}
-{$ifdef Ag386Bin}
+{$ifndef OLDASM}
        ,i386base
 {$else}
        ,i386
@@ -714,7 +714,11 @@ unit ptconst;
 end.
 {
   $Log$
-  Revision 1.40  1999-04-25 22:42:17  pierre
+  Revision 1.41  1999-05-01 13:24:39  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.40  1999/04/25 22:42:17  pierre
    + code for initialized vars in Delphi mode
 
   Revision 1.39  1999/03/24 23:17:21  peter

+ 413 - 0
compiler/ra386.pas

@@ -0,0 +1,413 @@
+{
+    $Id$
+    Copyright (c) 1997-98 by Carl Eric Codere
+
+    Handles the common i386 assembler reader routines
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+Unit Ra386;
+interface
+
+uses
+  aasm,
+  i386base,
+  RAUtils;
+
+{ Parser helpers }
+function is_prefix(t:tasmop):boolean;
+function is_override(t:tasmop):boolean;
+Function CheckPrefix(prefixop,op:tasmop): Boolean;
+Function CheckOverride(overrideop,op:tasmop): Boolean;
+Procedure InitAsmRef(var instr: TInstruction;operandnum:byte);
+
+{ Operand sizes }
+procedure AddReferenceSizes(var instr:TInstruction);
+procedure SetInstructionOpsize(var instr:TInstruction);
+procedure CheckOperandSizes(var instr:TInstruction);
+
+{ opcode adding }
+procedure ConcatInstruction(p : paasmoutput;var instr:TInstruction);
+
+
+implementation
+
+uses
+  globtype,globals,verbose,
+  i386asm;
+
+
+{*****************************************************************************
+                              Parser Helpers
+*****************************************************************************}
+
+function is_prefix(t:tasmop):boolean;
+var
+  i : longint;
+Begin
+  is_prefix:=false;
+  for i:=1 to AsmPrefixes do
+   if t=AsmPrefix[i-1] then
+    begin
+      is_prefix:=true;
+      exit;
+    end;
+end;
+
+
+function is_override(t:tasmop):boolean;
+var
+  i : longint;
+Begin
+  is_override:=false;
+  for i:=1 to AsmOverrides do
+   if t=AsmOverride[i-1] then
+    begin
+      is_override:=true;
+      exit;
+    end;
+end;
+
+
+Function CheckPrefix(prefixop,op:tasmop): Boolean;
+{ Checks if the prefix is valid with the following opcode }
+{ return false if not, otherwise true                          }
+Begin
+  CheckPrefix := TRUE;
+(*  Case prefix of
+    A_REP,A_REPNE,A_REPE:
+      Case opcode Of
+        A_SCASB,A_SCASW,A_SCASD,
+        A_INS,A_OUTS,A_MOVS,A_CMPS,A_LODS,A_STOS:;
+        Else
+          Begin
+            CheckPrefix := FALSE;
+            exit;
+          end;
+      end; { case }
+    A_LOCK:
+      Case opcode Of
+        A_BT,A_BTS,A_BTR,A_BTC,A_XCHG,A_ADD,A_OR,A_ADC,A_SBB,A_AND,A_SUB,
+        A_XOR,A_NOT,A_NEG,A_INC,A_DEC:;
+        Else
+          Begin
+            CheckPrefix := FALSE;
+            Exit;
+          end;
+      end; { case }
+    A_NONE: exit; { no prefix here }
+    else
+      CheckPrefix := FALSE;
+   end; { end case } *)
+end;
+
+
+Function CheckOverride(overrideop,op:tasmop): Boolean;
+{ Check if the override is valid, and if so then }
+{ update the instr variable accordingly.         }
+Begin
+  CheckOverride := true;
+{     Case instr.getinstruction of
+    A_MOVS,A_XLAT,A_CMPS:
+      Begin
+        CheckOverride := TRUE;
+        Message(assem_e_segment_override_not_supported);
+      end
+  end }
+end;
+
+
+Procedure InitAsmRef(var instr: TInstruction;operandnum:byte);
+{*********************************************************************}
+{  Description: This routine first check if the opcode is of     }
+{  type OPR_NONE, or OPR_REFERENCE , if not it gives out an error.    }
+{  If the operandtype = OPR_NONE or <> OPR_REFERENCE then it sets up  }
+{  the operand type to OPR_REFERENCE, as well as setting up the ref   }
+{  to point to the default segment.                                   }
+{*********************************************************************}
+Begin
+  With instr do
+  Begin
+     case operands[operandnum].operandtype of
+       OPR_REFERENCE: exit;
+       OPR_NONE: ;
+     else
+       Message(assem_e_invalid_operand_type);
+     end;
+     operands[operandnum].operandtype := OPR_REFERENCE;
+     operands[operandnum].ref.segment := R_DEFAULT_SEG;
+  end;
+end;
+
+
+{*****************************************************************************
+                                Operand Sizes
+*****************************************************************************}
+
+procedure AddReferenceSizes(var instr:TInstruction);
+{ this will add the sizes for references like [esi] which do not
+  have the size set yet, it will take only the size if the other
+  operand is a register }
+var
+  operand2,i : longint;
+begin
+  with instr do
+   begin
+     for i:=1to ops do
+      if (operands[i].size=S_NO) then
+       begin
+         case operands[i].operandtype of
+          OPR_REFERENCE :
+            begin
+              if i=2 then
+               operand2:=1
+              else
+               operand2:=2;
+              { Only allow register as operand to take the size from }
+              if operands[operand2].operandtype=OPR_REGISTER then
+               operands[i].size:=operands[operand2].size
+              else
+               begin
+                 { if no register then take the opsize (which is available with ATT) }
+                 operands[i].size:=opsize;
+               end;
+            end;
+          OPR_SYMBOL :
+            begin
+              operands[i].size:=S_L;
+            end;
+         end;
+       end;
+   end;
+end;
+
+
+procedure SetInstructionOpsize(var instr:TInstruction);
+begin
+  with instr do
+   begin
+     if opsize<>S_NO then
+      exit;
+     case ops of
+       0 : ;
+       1 :
+         opsize:=operands[1].size;
+       2 :
+         begin
+           case opcode of
+             A_MOVZX,A_MOVSX :
+               begin
+                 case operands[1].size of
+                   S_W :
+                     case operands[2].size of
+                       S_L :
+                         opsize:=S_WL;
+                     end;
+                   S_B :
+                     case operands[2].size of
+                       S_W :
+                         opsize:=S_BW;
+                       S_L :
+                         opsize:=S_BL;
+                     end;
+                 end;
+               end;
+             A_IN,A_OUT :
+               opsize:=operands[1].size;
+             else
+               opsize:=operands[2].size;
+           end;
+         end;
+       3 :
+         opsize:=operands[3].size;
+     end;
+   end;
+end;
+
+
+procedure CheckOperandSizes(var instr:TInstruction);
+var
+  sizeerr : boolean;
+  i : longint;
+begin
+  with instr do
+   begin
+     { don't check labeled instructions }
+     if labeled then
+      exit;
+     { Check only the most common opcodes here, the others are done in
+       the assembler pass }
+     case opcode of
+       A_PUSH,A_DEC,A_INC,A_NOT,A_NEG,
+       A_CMP,A_MOV,
+       A_ADD,A_SUB,A_ADC,A_SBB,
+       A_AND,A_OR,A_TEST,A_XOR: ;
+     else
+       exit;
+     end;
+     { Handle the BW,BL,WL separatly }
+     sizeerr:=false;
+     if opsize in [S_BW,S_BL,S_WL] then
+      begin
+        if ops<>2 then
+         sizeerr:=true
+        else
+         begin
+           case opsize of
+             S_BW :
+               sizeerr:=(operands[1].size<>S_B) or (operands[2].size<>S_W);
+             S_BL :
+               sizeerr:=(operands[1].size<>S_B) or (operands[2].size<>S_L);
+             S_WL :
+               sizeerr:=(operands[1].size<>S_W) or (operands[2].size<>S_L);
+           end;
+         end;
+      end
+     else
+      begin
+        for i:=1to ops do
+         begin
+           if (operands[i].operandtype<>OPR_CONSTANT) and
+              (operands[i].size<>opsize) then
+            sizeerr:=true;
+         end;
+      end;
+     if sizeerr then
+      begin
+        { if range checks are on then generate an error }
+        if (cs_compilesystem in aktmoduleswitches) or
+           not (cs_check_range in aktlocalswitches) then
+          Message(assem_w_size_suffix_and_dest_dont_match)
+        else
+          Message(assem_e_size_suffix_and_dest_dont_match);
+      end;
+   end;
+end;
+
+
+{*****************************************************************************
+                              opcode Adding
+*****************************************************************************}
+
+procedure ConcatInstruction(p : paasmoutput;var instr:TInstruction);
+var
+  siz  : topsize;
+  i    : longint;
+  hlab : plabel;
+  ai   : pai386;
+begin
+  with instr do
+   begin
+   { Handle a labeled opcode first to see if it needs conversion }
+     if labeled then
+      begin
+        { check if it's a jmp or call to a label, then issue a pai386_labeled }
+        if (Ops=1) then
+         begin
+           case opcode of
+             A_CALL,A_JMP,A_Jcc,A_JCXZ, A_JECXZ,
+             A_LOOP, A_LOOPE, A_LOOPNE, A_LOOPNZ, A_LOOPZ :
+               begin
+                 p^.concat(new(pai386_labeled,op_cond_lab(opcode,condition,operands[1].hl)));
+                 exit;
+               end;
+           end;
+         end;
+        { convert all labinstr to references }
+        for i:=1to Ops do
+         if operands[i].operandtype=OPR_LABINSTR then
+          begin
+            hlab:=operands[i].hl;
+            operands[i].operandtype:=OPR_REFERENCE;
+            reset_reference(operands[i].ref);
+            operands[i].ref.symbol:=newasmsymbol(lab2str(hlab));
+          end;
+      end;
+
+    { Get Opsize }
+      if (opsize<>S_NO) or (Ops=0) then
+       siz:=opsize
+      else
+       begin
+         if (Ops=2) and (instr.operands[1].operandtype=OPR_REGISTER) then
+          siz:=operands[1].size
+         else
+          siz:=operands[Ops].size;
+       end;
+
+     ai:=new(pai386,op_none(opcode,siz));
+     ai^.Ops:=Ops;
+     for i:=1to Ops do
+      begin
+        case instr.operands[i].operandtype of
+          OPR_CONSTANT :
+            ai^.loadconst(i-1,instr.operands[i].val);
+          OPR_REGISTER:
+            ai^.loadreg(i-1,instr.operands[i].reg);
+          OPR_SYMBOL:
+            ai^.loadsymbol(i-1,instr.operands[i].symbol,instr.operands[i].symofs);
+          OPR_REFERENCE:
+            ai^.loadref(i-1,newreference(instr.operands[i].ref));
+        end;
+      end;
+
+   { Condition ? }
+     if condition<>C_None then
+      ai^.SetCondition(condition);
+
+   { Concat the opcode or give an error }
+     if assigned(ai) then
+      p^.concat(ai)
+     else
+      Message(assem_e_invalid_opcode_and_operand);
+
+   end;
+end;
+
+end.
+{
+  $Log$
+  Revision 1.1  1999-05-01 13:24:40  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.7  1999/04/26 23:26:16  peter
+    * redesigned record offset parsing to support nested records
+    * normal compiler uses the redesigned createvarinstr()
+
+  Revision 1.6  1999/04/14 09:07:44  peter
+    * asm reader improvements
+
+  Revision 1.5  1999/03/29 16:05:52  peter
+    * optimizer working for ag386bin
+
+  Revision 1.4  1999/03/26 00:01:16  peter
+    * first things for optimizer (compiles but cycle crashes)
+
+  Revision 1.3  1999/03/06 17:24:25  peter
+    * rewritten intel parser a lot, especially reference reading
+    * size checking added for asm parsers
+
+  Revision 1.2  1999/03/02 02:56:29  peter
+    + stabs support for binary writers
+    * more fixes and missing updates from the previous commit :(
+
+  Revision 1.1  1999/03/01 15:46:26  peter
+    * ag386bin finally make cycles correct
+    * prefixes are now also normal opcodes
+
+}

+ 6 - 2
compiler/ra386dir.pas

@@ -33,7 +33,7 @@ unit Ra386dir;
 
      uses
         files,hcodegen,globals,scanner,aasm
-{$ifdef Ag386Bin}
+{$ifndef OLDASM}
         ,i386base,i386asm
 {$else}
         ,i386
@@ -295,7 +295,11 @@ unit Ra386dir;
 end.
 {
   $Log$
-  Revision 1.17  1999-03-31 13:55:18  peter
+  Revision 1.18  1999-05-01 13:24:40  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.17  1999/03/31 13:55:18  peter
     * assembler inlining working for ag386bin
 
   Revision 1.16  1999/03/24 23:17:22  peter

+ 288 - 385
compiler/rautils.pas

@@ -20,37 +20,7 @@
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
  **********************************************************************}
-
 Unit RAUtils;
-
-{*************************************************************************}
-{  This unit implements some objects as well as utilities which will be   }
-{  used by all inline assembler parsers (non-processor specific).         }
-{                                                                         }
-{  Main routines/objects herein:                                          }
-{  o Object TExprParse is a simple expression parser to resolve assembler }
-{    expressions. (Based generally on some code by Thai Tran from SWAG).  }
-{  o Object TInstruction is a simple object used for instructions         }
-{  o Record TOperand is a simple record used to store information on      }
-{    each operand.                                                        }
-{  o String conversion routines from octal,binary and hex to decimal.     }
-{  o A linked list object/record for local labels                         }
-{  o Routines for retrieving symbols (local and global)                   }
-{  o Object for a linked list of strings (with duplicate strings not      }
-{    allowed).                                                            }
-{  o Non-processor dependant routines for adding instructions to the      }
-{    instruction list.                                                    }
-{*************************************************************************}
-
-
-{--------------------------------------------------------------------}
-{ LEFT TO DO:                                                        }
-{ o Fix the remaining bugs in the expression parser, such as with    }
-{     4+-3                                                           }
-{ o Add support for local typed constants search.                    }
-{ o Add support for private/protected fields in method assembler     }
-{    routines.                                                       }
-{--------------------------------------------------------------------}
 Interface
 
 Uses
@@ -58,11 +28,7 @@ Uses
   symtable,aasm,hcodegen,verbose,globals,files,strings,
   cobjects,
 {$ifdef i386}
-{$ifdef Ag386Bin}
   i386base;
-{$else}
-  i386;
-{$endif}
 {$endif}
 {$ifdef m68k}
    m68k;
@@ -77,16 +43,12 @@ Const
 
 
 Type
-
-
   {---------------------------------------------------------------------}
   {                     Label Management types                          }
   {---------------------------------------------------------------------}
 
-
-    PAsmLabel = ^TAsmLabel;
-
     { Each local label has this structure associated with it }
+    PAsmLabel = ^TAsmLabel;
     TAsmLabel = record
       name: PString;    { pointer to a pascal string name of label }
       lab: PLabel;      { pointer to a label as defined in FPC     }
@@ -103,7 +65,6 @@ Type
       Function Search(const s: string): PAsmLabel;
     private
       Last: PAsmLabel;
-      Function NewPasStr(s:string): PString;
     end;
 
 
@@ -130,64 +91,51 @@ Type
     { Each instruction operand can be of this type }
     TOperand = record
       size: topsize;
-      opinfo: longint; { ao_xxxx flags }
+      opinfo: longint; { ot_ flags }
       overriden : boolean; { indicates if the opcode has been overriden }
                            { by a pseudo-opcode such as DWORD PTR       }
+      hasvar : boolean; { if the operand is loaded with a variable }
       case operandtype:toperandtype of
        { the size of the opr_none field should be at least equal to each }
        { other field as to facilitate initialization.                    }
        OPR_NONE: (l: array[1..sizeof(treference)] of byte);
-       OPR_REFERENCE: (ref:treference);
        OPR_CONSTANT:  (val: longint);
+         { the fakeval is here so the val of a constant will not override
+           any field in the reference (PFV) }
+       OPR_REFERENCE: (fakeval:longint;ref:treference);
        OPR_REGISTER:  (reg:tregister);
        OPR_LABINSTR: (hl: plabel);
        { Register list such as in the movem instruction }
        OPR_REGLIST:  (list: set of tregister);
-       OPR_SYMBOL : (symbol:pasmsymbol);
+       OPR_SYMBOL : (symofs:longint;symbol:pasmsymbol);
     end;
 
 
-
     TInstruction = object
     public
+      opcode    : tasmop;
+      opsize    : topsize;
+      condition : tasmcond;
+      ops       : byte;
       operands: array[1..maxoperands] of TOperand;
-      { if numops = zero, a size may still be valid in operands[1] }
-      { it still should be checked.                                }
-      numops: byte;
-      { set to TRUE if the instruction is labeled.                }
+      { set to TRUE if the instruction is labeled }
       labeled: boolean;
-      { This is used for instructions such A_CMPSB... etc, to determine }
-      { the size of the instruction.                                    }
-      stropsize: topsize;
       procedure init;
       procedure done;
-      { sets up the prefix field with the instruction pointed to in s }
-      procedure addprefix(tok: tasmop);
-      { sets up the instruction with the instruction pointed to in s }
-      procedure addinstr(tok: tasmop);
-      { get the current instruction of this object }
-      function getinstruction: tasmop;
-      { get the current prefix of this instruction }
-      function getprefix: tasmop;
-    private
-      prefix: tasmop;
-      instruction: tasmop;
     end;
 
 
-
-
   {---------------------------------------------------------------------}
   {                   Expression parser types                           }
   {---------------------------------------------------------------------}
 
   { expression parser error codes }
   texpr_error =
-  (zero_divide,       { divide by zero.     }
-   stack_overflow,    { stack overflow.     }
-   stack_underflow,   { stack underflow.    }
-   invalid_number,    { invalid conversion  }
-   invalid_op);       { invalid operator    }
+   (zero_divide,       { divide by zero.     }
+    stack_overflow,    { stack overflow.     }
+    stack_underflow,   { stack underflow.    }
+    invalid_number,    { invalid conversion  }
+    invalid_op);       { invalid operator    }
 
 
    TExprOperator = record
@@ -240,6 +188,10 @@ Type
   {                     String routines                                 }
   {---------------------------------------------------------------------}
 
+Function ValDecimal(const S:String):longint;
+Function ValOctal(const S:String):longint;
+Function ValBinary(const S:String):longint;
+Function ValHexaDecimal(const S:String):longint;
 
   {*********************************************************************}
   { PROCEDURE PadZero;                                                  }
@@ -251,48 +203,23 @@ Type
   {*********************************************************************}
   Function PadZero(Var s: String; n: byte): Boolean;
 
-  { Converts an Hex digit string to a Decimal string                      }
-  { Returns '' if there was an error.                                     }
-  Function HexToDec(const S:String): String;
-
-  { Converts a binary digit string to a Decimal string                    }
-  { Returns '' if there was an error.                                     }
-  Function BinaryToDec(const S:String): String;
-
-  { Converts an octal digit string to a Decimal string                    }
-  { Returns '' if there was an error.                                     }
-  Function OctalToDec(const S:String): String;
-
   { Converts a string containing C styled escape sequences to }
   { a pascal style string.                                    }
   Function EscapeToPascal(const s:string): string;
 
-  Procedure ConcatPasString(p : paasmoutput;s:string);
-  { Writes the string s directly to the assembler output }
-  Procedure ConcatDirect(p : paasmoutput;s:string);
-
 
   {---------------------------------------------------------------------}
   {                     Symbol helper routines                          }
   {---------------------------------------------------------------------}
 
   Procedure SetOperandSize(var instr:TInstruction;operandnum,size:longint);
-Function GetRecordOffsetSize(s:string;Var Offset: longint;var Size:longint):boolean;
+  Function GetRecordOffsetSize(s:string;Var Offset: longint;var Size:longint):boolean;
   Function SearchIConstant(const s:string; var l:longint): boolean;
   Function SearchLabel(const s: string; var hl: plabel): boolean;
+  Function SearchDirectVar(var Instr: TInstruction; const hs:string;operandnum:byte): Boolean;
   Function CreateVarInstr(var Instr: TInstruction; const hs:string;
      operandnum:byte):boolean;
-  {*********************************************************************}
-  { FUNCTION NewPasStr(s:string): PString                               }
-  {  Description: This routine allocates a string on the heap and       }
-  {  returns a pointer to the allocated string.                         }
-  {                                                                     }
-  {  Remarks: The string allocated should not be modified, since it's   }
-  {  length will be less then 255.                                      }
-  {  Remarks: It is assumed that HeapError will be called if an         }
-  {  allocation fails.                                                  }
-  {*********************************************************************}
-  Function newpasstr(s: string): Pointer;
+
   Procedure SetupResult(Var Instr:TInstruction; operandnum: byte);
 {$ifdef i386}
 
@@ -306,8 +233,12 @@ Function GetRecordOffsetSize(s:string;Var Offset: longint;var Size:longint):bool
   { swaps in the case of a 2/3 operand opcode the destination and the    }
   { source as to put it in AT&T style instruction format.                }
   Procedure SwapOperands(Var instr: TInstruction);
+  Procedure ConcatPasString(p : paasmoutput;s:string);
+  { Writes the string s directly to the assembler output }
+  Procedure ConcatDirect(p : paasmoutput;s:string);
   Procedure ConcatLabel(p: paasmoutput;var l : plabel);
   Procedure ConcatConstant(p : paasmoutput;value: longint; maxvalue: longint);
+  Procedure ConcatConstSymbol(p : paasmoutput;const sym:string;l:longint);
   Procedure ConcatRealConstant(p : paasmoutput;value: bestreal; real_typ : tfloattype);
   Procedure ConcatString(p : paasmoutput;s:string);
   Procedure ConcatPublic(p:paasmoutput;const s : string);
@@ -319,6 +250,7 @@ Function GetRecordOffsetSize(s:string;Var Offset: longint;var Size:longint):bool
   { add to internal list of labels }
   Procedure ConcatInternal(const s : string;typ : texternal_typ);
 
+
 Implementation
 
 {*************************************************************************}
@@ -334,13 +266,18 @@ var
   t : tmsgconst;
 Begin
   case anerror of
-  zero_divide: t:=assem_f_ev_zero_divide;
-  stack_overflow: t:=assem_f_ev_stack_overflow;
-  stack_underflow: t:=assem_f_ev_stack_underflow;
-  invalid_number: t:=assem_f_ev_invalid_number;
-  invalid_op: t:=assem_f_ev_invalid_op;
-  else
-   t:=assem_f_ev_unknown;
+    zero_divide:
+      t:=assem_f_ev_zero_divide;
+    stack_overflow:
+      t:=assem_f_ev_stack_overflow;
+    stack_underflow:
+      t:=assem_f_ev_stack_underflow;
+    invalid_number:
+      t:=assem_f_ev_invalid_number;
+    invalid_op:
+      t:=assem_f_ev_invalid_op;
+    else
+      t:=assem_f_ev_unknown;
   end;
   Message(t);
 end;
@@ -561,272 +498,210 @@ Begin
   expr.Done;
 end;
 
+
 {*************************************************************************}
 {                         String conversions/utils                        }
 {*************************************************************************}
 
-  Function newpasstr(s: string): Pointer;
-  Var
-   StrPtr: PString;
-  Begin
-    GetMem(StrPtr, length(s)+1);
-    Move(s,StrPtr^,length(s)+1);
-    newpasstr:= Strptr;
-  end;
-
-
-  Function EscapeToPascal(const s:string): string;
-  { converts a C styled string - which contains escape }
-  { characters to a pascal style string.               }
-  var
-   i,j: word;
-   str: string;
-   temp: string;
-   value: byte;
-   code: integer;
-  Begin
-   str:='';
-   i:=1;
-   j:=1;
-   repeat
-     if s[i] = '\' then
-     Begin
-      Inc(i);
-      if i > 255 then
+Function EscapeToPascal(const s:string): string;
+{ converts a C styled string - which contains escape }
+{ characters to a pascal style string.               }
+var
+  i,len : longint;
+  hs    : string;
+  temp  : string;
+  c     : char;
+Begin
+  hs:='';
+  len:=0;
+  i:=0;
+  while (i<length(s)) and (len<255) do
+   begin
+     Inc(i);
+     if (s[i]='\') and (i<length(s)) then
       Begin
-       EscapeToPascal:=str;
-       exit;
-      end;
-      case s[i] of
-       '\': insert('\',str,j);
-       'b': insert(#08,str,j);
-       'f': insert(#12,str,j);
-       'n': insert(#10,str,j);
-       'r': insert(#13,str,j);
-       't': insert(#09,str,j);
-       '"': insert('"',str,j);
-       { octal number }
-       '0'..'7': Begin
-                  temp:=s[i];
-                  temp:=temp+s[i+1];
-                  temp:=temp+s[i+2];
-                  inc(i,2);
-                  val(octaltodec(temp),value,code);
-                  if (code <> 0) then
-                   Message(assem_w_invalid_numeric);
-                  insert(chr(value),str,j);
-                 end;
-     { hexadecimal number }
-     'x': Begin
-            temp:=s[i+1];
-            temp:=temp+s[i+2];
-            inc(i,2);
-            val(hextodec(temp),value,code);
-            if (code <> 0) then
-             Message(assem_w_invalid_numeric);
-            insert(chr(value),str,j);
-          end;
+        inc(i);
+        case s[i] of
+         '\' :
+           c:='\';
+         'b':
+           c:=#8;
+         'f':
+           c:=#12;
+         'n':
+           c:=#10;
+         'r':
+           c:=#13;
+         't':
+           c:=#9;
+         '"':
+           c:='"';
+         '0'..'7':
+           Begin
+             temp:=s[i];
+             temp:=temp+s[i+1];
+             temp:=temp+s[i+2];
+             inc(i,2);
+             c:=chr(ValOctal(temp));
+           end;
+         'x':
+           Begin
+             temp:=s[i+1];
+             temp:=temp+s[i+2];
+             inc(i,2);
+             c:=chr(ValHexaDecimal(temp));
+           end;
+         else
+           Begin
+             Message1(assem_e_escape_seq_ignored,s[i]);
+             c:=s[i];
+           end;
+        end;
+      end
      else
-      Begin
-         Message1(assem_e_escape_seq_ignored,s[i]);
-         insert(s[i],str,j);
-      end;
-    end; {end case }
-    Inc(i);
-   end
-   else
-   Begin
-    Insert(s[i],str,j);
-    Inc(i);
-    if i > 255 then
-    Begin
-     EscapeToPascal:=str;
-     exit;
-    end;
+      c:=s[i];
+     inc(len);
+     hs[len]:=c;
    end;
-   Inc(j);
- until (i > length(s)) or (j > 255);
- EscapeToPascal:=str;
+  hs[0]:=chr(len);
+  EscapeToPascal:=hs;
 end;
 
 
-
-  Function OctalToDec(const S:String): String;
-  { Converts an octal string to a Decimal string }
-  { Returns '' if there was an error.            }
-  var vs: longint;
-    c: byte;
-    st: string;
-  Begin
-   vs := 0;
-   for c:=1 to length(s) do
+Function ValDecimal(const S:String):longint;
+{ Converts a decimal string to longint }
+var
+  vs,c : longint;
+Begin
+  vs := 0;
+  for c:=1 to length(s) do
    begin
-     case s[c] of
-     '0': vs:=vs shl 3;
-     '1': vs:=vs shl 3+1;
-     '2': vs:=vs shl 3+2;
-     '3': vs:=vs shl 3+3;
-     '4': vs:=vs shl 3+4;
-     '5': vs:=vs shl 3+5;
-     '6': vs:=vs shl 3+6;
-     '7': vs:=vs shl 3+7;
-    else
+     vs:=vs*10;
+     if s[c] in ['0'..'9'] then
+      inc(vs,ord(s[c])-ord('0'))
+     else
       begin
-        Message(assem_f_error_converting_octal);
-        OctalToDec := '';
+        Comment(V_Error,'assem_e_error_converting_decimal');
+        ValDecimal:=0;
         exit;
       end;
-    end;
    end;
-     str(vs,st);
-     OctalToDec := st;
-  end;
+  ValDecimal:=vs;
+end;
 
-  Function BinaryToDec(const S:String): String;
-  { Converts a binary string to a Decimal string }
-  { Returns '' if there was an error.            }
-  var vs: longint;
-    c: byte;
-    st: string;
-  Begin
-   vs := 0;
-   for c:=1 to length(s) do
+
+Function ValOctal(const S:String):longint;
+{ Converts an octal string to longint }
+var
+  vs,c : longint;
+Begin
+  vs := 0;
+  for c:=1 to length(s) do
    begin
-     if s[c] = '0' then
-       vs:=vs shl 1
-     else
-     if s[c]='1' then
-       vs:=vs shl 1+1
+     vs:=vs shl 3;
+     if s[c] in ['0'..'7'] then
+      inc(vs,ord(s[c])-ord('0'))
      else
-       begin
-         Message(assem_f_error_converting_bin);
-         BinaryToDec := '';
-         exit;
-       end;
+      begin
+        Comment(V_Error,'assem_e_error_converting_octal');
+        ValOctal:=0;
+        exit;
+      end;
    end;
-     str(vs,st);
-     BinaryToDec := st;
-  end;
+  ValOctal:=vs;
+end;
 
 
-  Function HexToDec(const S:String): String;
-  var vs: longint;
-    c: byte;
-    st: string;
-  Begin
-   vs := 0;
-   for c:=1 to length(s) do
+Function ValBinary(const S:String):longint;
+{ Converts a binary string to longint }
+var
+  vs,c : longint;
+Begin
+  vs := 0;
+  for c:=1 to length(s) do
    begin
-     case upcase(s[c]) of
-     '0': vs:=vs shl 4;
-     '1': vs:=vs shl 4+1;
-     '2': vs:=vs shl 4+2;
-     '3': vs:=vs shl 4+3;
-     '4': vs:=vs shl 4+4;
-     '5': vs:=vs shl 4+5;
-     '6': vs:=vs shl 4+6;
-     '7': vs:=vs shl 4+7;
-     '8': vs:=vs shl 4+8;
-     '9': vs:=vs shl 4+9;
-     'A': vs:=vs shl 4+10;
-     'B': vs:=vs shl 4+11;
-     'C': vs:=vs shl 4+12;
-     'D': vs:=vs shl 4+13;
-     'E': vs:=vs shl 4+14;
-     'F': vs:=vs shl 4+15;
-    else
+     vs:=vs shl 1;
+     if s[c] in ['0'..'1'] then
+      inc(vs,ord(s[c])-ord('0'))
+     else
       begin
-        Message(assem_f_error_converting_hex);
-        HexToDec := '';
+        Comment(V_Error,'assem_e_error_converting_binary');
+        ValBinary:=0;
         exit;
       end;
-    end;
    end;
-     str(vs,st);
-     HexToDec := st;
-  end;
+  ValBinary:=vs;
+end;
 
-  Function PadZero(Var s: String; n: byte): Boolean;
+
+Function ValHexadecimal(const S:String):longint;
+{ Converts a binary string to longint }
+var
+  vs,c : longint;
+Begin
+  vs := 0;
+  for c:=1 to length(s) do
+   begin
+     vs:=vs shl 4;
+     case s[c] of
+       '0'..'9' :
+         inc(vs,ord(s[c])-ord('0'));
+       'A'..'F' :
+         inc(vs,ord(s[c])-ord('A')+10);
+       'a'..'f' :
+         inc(vs,ord(s[c])-ord('a')+10);
+       else
+         begin
+           Comment(V_Error,'assem_e_error_converting_hexadecimal');
+           ValHexadecimal:=0;
+           exit;
+         end;
+     end;
+   end;
+  ValHexadecimal:=vs;
+end;
+
+
+Function PadZero(Var s: String; n: byte): Boolean;
+Begin
+  PadZero := TRUE;
+  { Do some error checking first }
+  if Length(s) = n then
+    exit
+  else
+  if Length(s) > n then
   Begin
+    PadZero := FALSE;
+    delete(s,n+1,length(s));
+    exit;
+  end
+  else
     PadZero := TRUE;
-    { Do some error checking first }
-    if Length(s) = n then
-      exit
-    else
-    if Length(s) > n then
-    Begin
-      PadZero := FALSE;
-      delete(s,n+1,length(s));
-      exit;
-    end
-    else
-      PadZero := TRUE;
-    { Fill it up with the specified character }
-    fillchar(s[length(s)+1],n-1,#0);
-    {$ifndef TP}
-      {$ifopt H+}
-        setlength(s,n);
-      {$else}
-        s[0] := chr(n);
-      {$endif}
-    {$else}
-      s[0] := chr(n);
-    {$endif}
-  end;
+  { Fill it up with the specified character }
+  fillchar(s[length(s)+1],n-1,#0);
+  s[0] := chr(n);
+end;
 
-{*************************************************************************}
-{                          Instruction utilities                          }
-{*************************************************************************}
 
- Procedure TInstruction.init;
- var
-  k: integer;
- Begin
-  numops := 0;
+{****************************************************************************
+                                 TInstruction
+****************************************************************************}
+
+Procedure TInstruction.init;
+Begin
+  Opcode:=A_NONE;
+  Opsize:=S_NO;
+  Condition:=C_NONE;
   labeled := FALSE;
-  stropsize := S_NO;
-  prefix := A_NONE;
-  instruction := A_NONE;
-  for k:=1 to maxoperands do
-  begin
-    operands[k].size := S_NO;
-    operands[k].overriden := FALSE;
-    operands[k].operandtype := OPR_NONE;
-    { init to zeros }
-    fillchar(operands[k].l, sizeof(operands[k].l),#0);
-  end;
- end;
-
- Procedure TInstruction.addprefix(tok: tasmop);
- Begin
-   if tok = A_NONE then
-    Message(assem_e_syn_prefix_not_found);
-   if Prefix = A_NONE then
-    Prefix := tok
-   else
-    Message(assem_e_syn_try_add_more_prefix);
- end;
-
- Procedure TInstruction.addinstr(tok: tasmop);
- Begin
-   if tok = A_NONE then
-    Message(assem_e_syn_opcode_not_found);
-   Instruction := tok;
- end;
-
- function TInstruction.getinstruction: tasmop;
- Begin
-   getinstruction := Instruction;
- end;
-      { get the current prefix of this instruction }
- function TInstruction.getprefix: tasmop;
- Begin
-   getprefix := prefix;
- end;
-
- Procedure TInstruction.done;
- Begin
- end;
+  Ops:=0;
+  FillChar(Operands,sizeof(Operands),0);
+end;
+
+
+Procedure TInstruction.done;
+Begin
+end;
+
 
 {*************************************************************************}
 {                          Local label utilities                          }
@@ -860,7 +735,7 @@ end;
           New(Last^.Next);
           Last := Last^.Next;
        end;
-      Last^.name := NewPasStr(s);
+      Last^.name := stringdup(s);
       Last^.Lab := lab;
       Last^.Next := nil;
       Last^.emitted := emitted;
@@ -919,43 +794,22 @@ end;
   end;
 
 
-
-  Function TAsmLabelList.newpasstr(s: string): PString;
-  {*********************************************************************}
-  { FUNCTION NewPasStr(s:string): PString                               }
-  {  Description: This routine allocates a string on the heap and       }
-  {  returns a pointer to the allocated string.                         }
-  {                                                                     }
-  {  Remarks: The string allocated should not be modified, since it's   }
-  {  length will be less then 255.                                      }
-  {  Remarks: It is assumed that HeapError will be called if an         }
-  {  allocation fails.                                                  }
-  {*********************************************************************}
-  Var
-   StrPtr: PString;
-  Begin
-    GetMem(StrPtr, length(s)+1);
-    Move(s,StrPtr^,length(s)+1);
-    newpasstr:= Strptr;
-  end;
-
 {*************************************************************************}
 {                      Symbol table helper routines                       }
 {*************************************************************************}
 
-
   Procedure SwapOperands(Var instr: TInstruction);
   Var
    tempopr: TOperand;
   Begin
-    if instr.numops = 2 then
+    if instr.Ops = 2 then
     Begin
       tempopr := instr.operands[1];
       instr.operands[1] := instr.operands[2];
       instr.operands[2] := tempopr;
     end
     else
-    if instr.numops = 3 then
+    if instr.Ops = 3 then
     Begin
       tempopr := instr.operands[1];
       instr.operands[1] := instr.operands[3];
@@ -1195,7 +1049,9 @@ Begin
           parasymtable :
             begin
               instr.operands[operandnum].ref.base := procinfo.framepointer;
-              instr.operands[operandnum].ref.offset := pvarsym(sym)^.address+aktprocsym^.definition^.parast^.address_fixup;
+              instr.operands[operandnum].ref.offset := pvarsym(sym)^.address;
+              instr.operands[operandnum].ref.offsetfixup:=aktprocsym^.definition^.parast^.address_fixup;
+              instr.operands[operandnum].ref.options := ref_parafixup;
             end;
           localsymtable :
             begin
@@ -1205,6 +1061,8 @@ Begin
                 begin
                   instr.operands[operandnum].ref.base := procinfo.framepointer;
                   instr.operands[operandnum].ref.offset := -(pvarsym(sym)^.address);
+                  instr.operands[operandnum].ref.options := ref_localfixup;
+                  instr.operands[operandnum].ref.offsetfixup:=aktprocsym^.definition^.localst^.address_fixup;
                 end;
             end;
         end;
@@ -1216,6 +1074,7 @@ Begin
           arraydef :
             SetOperandSize(instr,operandnum,parraydef(pvarsym(sym)^.definition)^.elesize)
         end;
+        instr.operands[operandnum].hasvar:=true;
         CreateVarInstr := TRUE;
         Exit;
       end;
@@ -1230,6 +1089,7 @@ Begin
           arraydef :
             SetOperandSize(instr,operandnum,parraydef(ptypedconstsym(sym)^.definition)^.elesize)
         end;
+        instr.operands[operandnum].hasvar:=true;
         CreateVarInstr := TRUE;
         Exit;
       end;
@@ -1239,6 +1099,7 @@ Begin
          begin
            instr.operands[operandnum].operandtype:=OPR_CONSTANT;
            instr.operands[operandnum].val:=pconstsym(sym)^.value;
+           instr.operands[operandnum].hasvar:=true;
            CreateVarInstr := TRUE;
            Exit;
          end;
@@ -1249,6 +1110,7 @@ Begin
          begin
            instr.operands[operandnum].operandtype:=OPR_CONSTANT;
            instr.operands[operandnum].val:=0;
+           instr.operands[operandnum].hasvar:=true;
            CreateVarInstr := TRUE;
            Exit;
          end;
@@ -1259,6 +1121,7 @@ Begin
           Message(assem_w_calling_overload_func);
         instr.operands[operandnum].operandtype:=OPR_SYMBOL;
         instr.operands[operandnum].symbol:=newasmsymbol(pprocsym(sym)^.definition^.mangledname);
+        instr.operands[operandnum].hasvar:=true;
         CreateVarInstr := TRUE;
         Exit;
       end;
@@ -1315,6 +1178,39 @@ end;
   end;
 
 
+{ looks for internal names of variables and routines }
+Function SearchDirectVar(var Instr: TInstruction; const hs:string;operandnum:byte): Boolean;
+var
+  p : pai_external;
+Begin
+   SearchDirectVar:=false;
+   { search in the list of internals }
+   p:=search_assembler_symbol(internals,hs,EXT_ANY);
+     if p=nil then
+       p:=search_assembler_symbol(externals,hs,EXT_ANY);
+   if p<>nil then
+     begin
+       instr.operands[operandnum].ref.symbol:=p^.sym;
+        case p^.exttyp of
+           EXT_BYTE   : instr.operands[operandnum].size := S_B;
+           EXT_WORD   : instr.operands[operandnum].size := S_W;
+           EXT_NEAR,EXT_FAR,EXT_PROC,EXT_DWORD,EXT_CODEPTR,EXT_DATAPTR:
+           instr.operands[operandnum].size := S_L;
+           EXT_QWORD  : instr.operands[operandnum].size := S_FL;
+           EXT_TBYTE  : instr.operands[operandnum].size := S_FX;
+         else
+           { this is in the case where the instruction is LEA }
+           { or something like that, in that case size is not }
+           { important.                                       }
+             instr.operands[operandnum].size := S_NO;
+         end;
+       instr.operands[operandnum].hasvar:=true;
+       SearchDirectVar := TRUE;
+       Exit;
+     end;
+end;
+
+
  {*************************************************************************}
  {                   Instruction Generation Utilities                      }
  {*************************************************************************}
@@ -1389,6 +1285,13 @@ end;
           p^.concat(new(pai_const,init_32bit(longint(value))));
   end;
 
+
+  Procedure ConcatConstSymbol(p : paasmoutput;const sym:string;l:longint);
+  begin
+    p^.concat(new(pai_const_symbol,init_offset(sym,l)));
+  end;
+
+
   Procedure ConcatRealConstant(p : paasmoutput;value: bestreal; real_typ : tfloattype);
   {***********************************************************************}
   { PROCEDURE ConcatRealConstant(value: bestreal; real_typ : tfloattype); }
@@ -1494,35 +1397,35 @@ end;
 end.
 {
   $Log$
-  Revision 1.9  1999-04-26 23:26:14  peter
+  Revision 1.10  1999-05-01 13:24:41  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.8  1999/04/26 23:26:19  peter
     * redesigned record offset parsing to support nested records
     * normal compiler uses the redesigned createvarinstr()
 
-  Revision 1.8  1999/03/31 13:55:19  peter
-    * assembler inlining working for ag386bin
-
-  Revision 1.7  1999/03/24 23:17:23  peter
-    * fixed bugs 212,222,225,227,229,231,233
+  Revision 1.7  1999/04/14 09:07:48  peter
+    * asm reader improvements
 
-  Revision 1.6  1999/03/01 13:22:25  pierre
-   * varsym refs incremented
-
-  Revision 1.5  1999/02/25 21:02:51  peter
-    * ag386bin updates
-    + coff writer
+  Revision 1.6  1999/03/31 13:55:34  peter
+    * assembler inlining working for ag386bin
 
-  Revision 1.4  1999/02/22 02:15:39  peter
-    * updates for ag386bin
+  Revision 1.5  1999/03/26 00:01:17  peter
+    * first things for optimizer (compiles but cycle crashes)
 
-  Revision 1.3  1999/02/16 00:47:28  peter
-    * fixed local copies of value para's
+  Revision 1.4  1999/03/25 16:55:36  peter
+    + unitpath,librarypath,includepath,objectpath directives
 
-  Revision 1.2  1999/01/27 13:04:11  pierre
-   * bug with static vars in assembler readers
+  Revision 1.3  1999/03/06 17:24:28  peter
+    * rewritten intel parser a lot, especially reference reading
+    * size checking added for asm parsers
 
-  Revision 1.1  1999/01/10 15:38:00  peter
-    * moved some tables from ra386*.pas -> i386.pas
-    + start of coff writer
-    * renamed asmutils unit to rautils
+  Revision 1.2  1999/03/02 02:56:33  peter
+    + stabs support for binary writers
+    * more fixes and missing updates from the previous commit :(
 
+  Revision 1.1  1999/03/01 15:46:26  peter
+    * ag386bin finally make cycles correct
+    * prefixes are now also normal opcodes
 }

+ 6 - 2
compiler/symtable.pas

@@ -34,7 +34,7 @@ unit symtable;
        globtype,globals,tokens,systems,verbose,
        aasm
 {$ifdef i386}
-  {$ifdef ag386bin}
+  {$ifndef OLDASM}
        ,i386base
   {$else}
        ,i386
@@ -3204,7 +3204,11 @@ const localsymtablestack : psymtable = nil;
 end.
 {
   $Log$
-  Revision 1.4  1999-04-29 17:25:37  peter
+  Revision 1.5  1999-05-01 13:24:43  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.4  1999/04/29 17:25:37  peter
     * small fix for deref
 
   Revision 1.3  1999/04/26 18:30:03  peter

+ 7 - 3
compiler/systems.pas

@@ -823,7 +823,7 @@ implementation
             exeext      : '.exe';
             os          : os_i386_GO32V2;
             link        : link_i386_ldgo32v2;
-{$ifdef Ag386Bin}
+{$ifndef OLDASM}
             assem       : as_i386_coff;
 {$else}
             assem       : as_i386_as;
@@ -899,7 +899,7 @@ implementation
             exeext      : '.exe';
             os          : os_i386_Win32;
             link        : link_i386_ldw;
-{$ifdef Ag386Bin}
+{$ifndef OLDASM}
             assem       : as_i386_pecoff;
 {$else}
             assem       : as_i386_asw;
@@ -1369,7 +1369,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.65  1999-03-26 00:05:47  peter
+  Revision 1.66  1999-05-01 13:24:44  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.65  1999/03/26 00:05:47  peter
     * released valintern
     + deffile is now removed when compiling is finished
     * ^( compiles now correct

+ 6 - 2
compiler/tcadd.pas

@@ -37,7 +37,7 @@ implementation
       symtable,aasm,types,
       hcodegen,htypechk,pass_1
 {$ifdef i386}
-{$ifdef ag386bin}
+{$ifndef OLDASM}
       ,i386base
 {$else}
       ,i386
@@ -1074,7 +1074,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.27  1999-04-28 06:02:14  florian
+  Revision 1.28  1999-05-01 13:24:46  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.27  1999/04/28 06:02:14  florian
     * changes of Bruessel:
        + message handler can now take an explicit self
        * typinfo fixed: sometimes the type names weren't written

+ 6 - 2
compiler/tccal.pas

@@ -42,7 +42,7 @@ implementation
       aasm,types,
       hcodegen,htypechk,pass_1
 {$ifdef i386}
-{$ifdef ag386bin}
+{$ifndef OLDASM}
       ,i386base
 {$else}
       ,i386
@@ -1149,7 +1149,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.37  1999-04-26 13:31:57  peter
+  Revision 1.38  1999-05-01 13:24:47  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.37  1999/04/26 13:31:57  peter
     * release storenumber,double_checksum
 
   Revision 1.36  1999/04/26 09:30:46  peter

+ 6 - 2
compiler/tccnv.pas

@@ -44,7 +44,7 @@ implementation
       symtable,aasm,types,
       hcodegen,htypechk,pass_1
 {$ifdef i386}
-{$ifdef ag386bin}
+{$ifndef OLDASM}
       ,i386base
 {$else}
       ,i386
@@ -940,7 +940,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.26  1999-04-26 13:31:58  peter
+  Revision 1.27  1999-05-01 13:24:48  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.26  1999/04/26 13:31:58  peter
     * release storenumber,double_checksum
 
   Revision 1.25  1999/04/22 10:49:09  peter

+ 6 - 2
compiler/tccon.pas

@@ -41,7 +41,7 @@ implementation
       symtable,aasm,types,
       hcodegen,pass_1
 {$ifdef i386}
-{$ifdef ag386bin}
+{$ifndef OLDASM}
       ,i386base
 {$else}
       ,i386
@@ -130,7 +130,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.4  1999-02-22 02:15:47  peter
+  Revision 1.5  1999-05-01 13:24:50  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.4  1999/02/22 02:15:47  peter
     * updates for ag386bin
 
   Revision 1.3  1998/11/17 00:36:48  peter

+ 6 - 2
compiler/tcflw.pas

@@ -47,7 +47,7 @@ implementation
       symtable,aasm,types,
       hcodegen,htypechk,temp_gen,pass_1
 {$ifdef i386}
-{$ifdef ag386bin}
+{$ifndef OLDASM}
       ,i386base
 {$else}
       ,i386
@@ -500,7 +500,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.8  1999-03-24 23:17:36  peter
+  Revision 1.9  1999-05-01 13:24:52  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.8  1999/03/24 23:17:36  peter
     * fixed bugs 212,222,225,227,229,231,233
 
   Revision 1.7  1999/03/09 19:24:42  peter

+ 6 - 2
compiler/tcinl.pas

@@ -38,7 +38,7 @@ implementation
       hcodegen,htypechk,pass_1,
       tccal
 {$ifdef i386}
-{$ifdef ag386bin}
+{$ifndef OLDASM}
       ,i386base
 {$else}
       ,i386
@@ -1100,7 +1100,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.29  1999-04-28 06:02:15  florian
+  Revision 1.30  1999-05-01 13:24:53  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.29  1999/04/28 06:02:15  florian
     * changes of Bruessel:
        + message handler can now take an explicit self
        * typinfo fixed: sometimes the type names weren't written

+ 6 - 2
compiler/tcld.pas

@@ -42,7 +42,7 @@ implementation
       hcodegen,htypechk,pass_1,
       tccnv
 {$ifdef i386}
-{$ifdef ag386bin}
+{$ifndef OLDASM}
       ,i386base
 {$else}
       ,i386
@@ -477,7 +477,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.24  1999-04-28 06:02:17  florian
+  Revision 1.25  1999-05-01 13:24:54  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.24  1999/04/28 06:02:17  florian
     * changes of Bruessel:
        + message handler can now take an explicit self
        * typinfo fixed: sometimes the type names weren't written

+ 6 - 2
compiler/tcmat.pas

@@ -40,7 +40,7 @@ implementation
       symtable,aasm,types,
       hcodegen,htypechk,pass_1
 {$ifdef i386}
-{$ifdef ag386bin}
+{$ifndef OLDASM}
       ,i386base
 {$else}
       ,i386
@@ -377,7 +377,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.12  1999-02-22 02:15:53  peter
+  Revision 1.13  1999-05-01 13:24:55  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.12  1999/02/22 02:15:53  peter
     * updates for ag386bin
 
   Revision 1.11  1999/02/03 10:11:11  pierre

+ 6 - 2
compiler/tcmem.pas

@@ -48,7 +48,7 @@ implementation
       symtable,aasm,types,
       hcodegen,htypechk,pass_1
 {$ifdef i386}
-{$ifdef ag386bin}
+{$ifndef OLDASM}
       ,i386base
 {$else}
       ,i386
@@ -555,7 +555,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.13  1999-04-26 18:30:05  peter
+  Revision 1.14  1999-05-01 13:24:57  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.13  1999/04/26 18:30:05  peter
     * farpointerdef moved into pointerdef.is_far
 
   Revision 1.12  1999/03/02 18:24:24  peter

+ 7 - 3
compiler/tcset.pas

@@ -41,7 +41,7 @@ implementation
       hcodegen,htypechk,pass_1,
       tccnv
 {$ifdef i386}
-{$ifdef ag386bin}
+{$ifndef OLDASM}
       ,i386base
 {$else}
       ,i386
@@ -99,7 +99,7 @@ implementation
             arrayconstructor_to_set(p^.right);
             firstpass(p^.right);
             if codegenerror then
-             exit; 
+             exit;
           end;
 
          if p^.right^.resulttype^.deftype<>setdef then
@@ -259,7 +259,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.8  1999-04-14 15:00:13  peter
+  Revision 1.9  1999-05-01 13:24:58  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.8  1999/04/14 15:00:13  peter
     * forgot firstpass after array->set conversion
 
   Revision 1.7  1999/03/02 18:22:36  peter

+ 6 - 2
compiler/temp_gen.pas

@@ -26,7 +26,7 @@ unit temp_gen;
 
     uses
 {$ifdef i386}
-{$ifdef ag386bin}
+{$ifndef OLDASM}
       i386base,i386asm,
 {$else}
       i386,
@@ -648,7 +648,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.20  1999-04-19 09:30:48  pierre
+  Revision 1.21  1999-05-01 13:24:59  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.20  1999/04/19 09:30:48  pierre
    + added warning for unreleased ANSI temp
 
   Revision 1.19  1999/04/16 20:44:38  florian

+ 6 - 2
compiler/tgeni386.pas

@@ -27,7 +27,7 @@ unit tgeni386;
     uses
        cobjects,globals,tree,hcodegen,verbose,files,aasm
 {$ifdef i386}
-{$ifdef ag386bin}
+{$ifndef OLDASM}
        ,i386base,i386asm
 {$else}
        ,i386
@@ -373,7 +373,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.22  1999-04-21 16:31:48  pierre
+  Revision 1.23  1999-05-01 13:25:01  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.22  1999/04/21 16:31:48  pierre
   ra386att.pas
 
   Revision 1.21  1999/04/16 11:49:47  peter

+ 6 - 2
compiler/tree.pas

@@ -30,7 +30,7 @@ unit tree;
 
     uses
        globtype,cobjects,symtable,aasm
-{$ifdef ag386bin}
+{$ifndef OLDASM}
        ,i386base
 {$else}
        ,i386
@@ -1717,7 +1717,11 @@ unit tree;
 end.
 {
   $Log$
-  Revision 1.74  1999-04-21 21:45:31  pierre
+  Revision 1.75  1999-05-01 13:25:02  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.74  1999/04/21 21:45:31  pierre
    * wrong log fro v1.73 corrected
 
   Revision 1.73  1999/04/21 16:31:49  pierre

+ 6 - 2
compiler/win_targ.pas

@@ -58,7 +58,7 @@ unit win_targ;
        ,gdb
 {$endif}
 {$ifdef i386}
-{$ifdef Ag386Bin}
+{$ifndef OLDASM}
        ,i386base,i386asm
 {$else}
        ,i386
@@ -710,7 +710,11 @@ unit win_targ;
 end.
 {
   $Log$
-  Revision 1.23  1999-04-07 14:18:32  pierre
+  Revision 1.24  1999-05-01 13:25:04  peter
+    * merged nasm compiler
+    * old asm moved to oldasm/
+
+  Revision 1.23  1999/04/07 14:18:32  pierre
    * typo correction
 
   Revision 1.22  1999/04/07 14:04:40  pierre

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio