Browse Source

* fixed operand order that got mixed up for external writers after
my previous assembler block valid instruction check

peter 24 years ago
parent
commit
acd6ede655
4 changed files with 44 additions and 8 deletions
  1. 6 1
      compiler/i386/ag386att.pas
  2. 7 2
      compiler/i386/ag386int.pas
  3. 7 2
      compiler/i386/ag386nsm.pas
  4. 24 3
      compiler/i386/cpuasm.pas

+ 6 - 1
compiler/i386/ag386att.pas

@@ -704,6 +704,7 @@ interface
 
 
            ait_instruction :
            ait_instruction :
              begin
              begin
+               taicpu(hp).SetOperandOrder(op_att);
                op:=taicpu(hp).opcode;
                op:=taicpu(hp).opcode;
                calljmp:=is_calljmp(op);
                calljmp:=is_calljmp(op);
              { call maybe not translated to call }
              { call maybe not translated to call }
@@ -892,7 +893,11 @@ interface
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.2  2000-12-25 00:07:31  peter
+  Revision 1.3  2001-01-13 20:24:24  peter
+    * fixed operand order that got mixed up for external writers after
+      my previous assembler block valid instruction check
+
+  Revision 1.2  2000/12/25 00:07:31  peter
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
       tlinkedlist objects)
       tlinkedlist objects)
 
 

+ 7 - 2
compiler/i386/ag386int.pas

@@ -478,9 +478,10 @@ interface
                      end;
                      end;
    ait_instruction : begin
    ait_instruction : begin
                      { Must be done with args in ATT order }
                      { Must be done with args in ATT order }
+                       taicpu(hp).SetOperandOrder(op_att);
                        taicpu(hp).CheckNonCommutativeOpcodes;
                        taicpu(hp).CheckNonCommutativeOpcodes;
                      { We need intel order, no At&t }
                      { We need intel order, no At&t }
-                       taicpu(hp).SwapOperands;
+                       taicpu(hp).SetOperandOrder(op_intel);
                      { Reset }
                      { Reset }
                        suffix:='';
                        suffix:='';
                        prefix:= '';
                        prefix:= '';
@@ -640,7 +641,11 @@ ait_stab_function_name : ;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.4  2000-12-25 00:07:31  peter
+  Revision 1.5  2001-01-13 20:24:24  peter
+    * fixed operand order that got mixed up for external writers after
+      my previous assembler block valid instruction check
+
+  Revision 1.4  2000/12/25 00:07:31  peter
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
       tlinkedlist objects)
       tlinkedlist objects)
 
 

+ 7 - 2
compiler/i386/ag386nsm.pas

@@ -621,9 +621,10 @@ interface
            ait_instruction :
            ait_instruction :
              begin
              begin
              { Must be done with args in ATT order }
              { Must be done with args in ATT order }
+               taicpu(hp).SetOperandOrder(op_att);
                taicpu(hp).CheckNonCommutativeOpcodes;
                taicpu(hp).CheckNonCommutativeOpcodes;
              { We need intel order, no At&t }
              { We need intel order, no At&t }
-               taicpu(hp).SwapOperands;
+               taicpu(hp).SetOperandOrder(op_intel);
              { Reset
              { Reset
                suffix:='';
                suffix:='';
                prefix:='';}
                prefix:='';}
@@ -767,7 +768,11 @@ interface
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.3  2000-12-25 00:07:31  peter
+  Revision 1.4  2001-01-13 20:24:24  peter
+    * fixed operand order that got mixed up for external writers after
+      my previous assembler block valid instruction check
+
+  Revision 1.3  2000/12/25 00:07:31  peter
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
     + new tlinkedlist class (merge of old tstringqueue,tcontainer and
       tlinkedlist objects)
       tlinkedlist objects)
 
 

+ 24 - 3
compiler/i386/cpuasm.pas

@@ -48,6 +48,8 @@ const
   MaxPrefixes=4;
   MaxPrefixes=4;
 
 
 type
 type
+  TOperandOrder = (op_intel,op_att);
+
   tairegalloc = class(tai)
   tairegalloc = class(tai)
      allocation : boolean;
      allocation : boolean;
      reg        : tregister;
      reg        : tregister;
@@ -113,10 +115,10 @@ type
      destructor destroy;override;
      destructor destroy;override;
      function  getcopy:tlinkedlistitem;override;
      function  getcopy:tlinkedlistitem;override;
      function  GetString:string;
      function  GetString:string;
-     procedure SwapOperands;
      procedure CheckNonCommutativeOpcodes;
      procedure CheckNonCommutativeOpcodes;
   private
   private
      segprefix : tregister;
      segprefix : tregister;
+     FOperandOrder : TOperandOrder;
      procedure init(op : tasmop;_size : topsize); { this need to be called by all constructor }
      procedure init(op : tasmop;_size : topsize); { this need to be called by all constructor }
 {$ifndef NOAG386BIN}
 {$ifndef NOAG386BIN}
   public
   public
@@ -125,6 +127,7 @@ type
      function  CheckIfValid:boolean;
      function  CheckIfValid:boolean;
      function  Pass1(offset:longint):longint;virtual;
      function  Pass1(offset:longint):longint;virtual;
      procedure Pass2;virtual;
      procedure Pass2;virtual;
+     procedure SetOperandOrder(order:TOperandOrder);
   private
   private
      { next fields are filled in pass1, so pass2 is faster }
      { next fields are filled in pass1, so pass2 is faster }
      insentry  : PInsEntry;
      insentry  : PInsEntry;
@@ -137,6 +140,7 @@ type
      function  calcsize(p:PInsEntry):longint;
      function  calcsize(p:PInsEntry):longint;
      procedure gencode;
      procedure gencode;
      function  NeedAddrPrefix(opidx:byte):boolean;
      function  NeedAddrPrefix(opidx:byte):boolean;
+     procedure SwapOperands;
 {$endif NOAG386BIN}
 {$endif NOAG386BIN}
   end;
   end;
 
 
@@ -321,6 +325,8 @@ uses
       begin
       begin
          typ:=ait_instruction;
          typ:=ait_instruction;
          is_jmp:=false;
          is_jmp:=false;
+         { default order is att }
+         FOperandOrder:=op_att;
          segprefix:=R_NO;
          segprefix:=R_NO;
          opcode:=op;
          opcode:=op;
          opsize:=_size;
          opsize:=_size;
@@ -697,6 +703,17 @@ uses
         end;
         end;
       end;
       end;
 
 
+
+    procedure taicpu.SetOperandOrder(order:TOperandOrder);
+      begin
+        if FOperandOrder<>order then
+         begin
+           SwapOperands;
+           FOperandOrder:=order;
+         end;
+      end;
+
+
 { This check must be done with the operand in ATT order
 { This check must be done with the operand in ATT order
   i.e.after swapping in the intel reader
   i.e.after swapping in the intel reader
   but before swapping in the NASM and TASM writers PM }
   but before swapping in the NASM and TASM writers PM }
@@ -960,7 +977,7 @@ begin
   if Insentry=nil then
   if Insentry=nil then
    begin
    begin
      { We need intel style operands }
      { We need intel style operands }
-     SwapOperands;
+     SetOperandOrder(op_intel);
      { create the .ot fields }
      { create the .ot fields }
      create_ot;
      create_ot;
      { set the file postion }
      { set the file postion }
@@ -1721,7 +1738,11 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.9  2001-01-12 19:18:42  peter
+  Revision 1.10  2001-01-13 20:24:24  peter
+    * fixed operand order that got mixed up for external writers after
+      my previous assembler block valid instruction check
+
+  Revision 1.9  2001/01/12 19:18:42  peter
     * check for valid asm instructions
     * check for valid asm instructions
 
 
   Revision 1.8  2001/01/07 15:48:56  jonas
   Revision 1.8  2001/01/07 15:48:56  jonas