Browse Source

* bug0175 solved give error on $R+ and warning otherwise

pierre 26 years ago
parent
commit
094fde4f06
1 changed files with 37 additions and 20 deletions
  1. 37 20
      compiler/ra386att.pas

+ 37 - 20
compiler/ra386att.pas

@@ -1054,6 +1054,22 @@ var
    end;
    end;
 
 
 
 
+  Function CheckAndSetOpsize(var op : toperand;size : topsize) : boolean;
+    Begin
+       CheckAndSetOpsize:=true;
+       { operandtype for constant get a default value for size }
+       if (op.operandtype<>OPR_CONSTANT) and (op.size<>S_NO) and (op.size<>size) then
+         begin
+            CheckAndSetOpsize:=false;
+            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;
+       op.size:=size;
+    End;
+    
   Procedure ConcatOpCode(var instr: TInstruction);
   Procedure ConcatOpCode(var instr: TInstruction);
   {*********************************************************************}
   {*********************************************************************}
   { First Pass:                                                         }
   { First Pass:                                                         }
@@ -1154,25 +1170,25 @@ var
               begin
               begin
                 if stropsize = S_BL then
                 if stropsize = S_BL then
                   begin
                   begin
-                    operands[1].size := S_B;
+                    CheckAndSetOpsize(operands[1],S_B);
                     stropsize := S_NO;
                     stropsize := S_NO;
-                    operands[2].size := S_L;
+                    CheckAndSetOpsize(operands[2],S_L);
                     addinstr(A_MOVSBL)
                     addinstr(A_MOVSBL)
                   end
                   end
                 else
                 else
                   if stropsize = S_WL then
                   if stropsize = S_WL then
                     begin
                     begin
-                      operands[1].size := S_W;
+                      CheckAndSetOpsize(operands[1],S_W);
                       stropsize := S_NO;
                       stropsize := S_NO;
-                      operands[2].size := S_L;
+                      CheckAndSetOpsize(operands[2],S_L);
                       addinstr(A_MOVSWL)
                       addinstr(A_MOVSWL)
                     end
                     end
                   else
                   else
                     if stropsize = S_BW then
                     if stropsize = S_BW then
                       begin
                       begin
-                        operands[1].size := S_B;
+                        CheckAndSetOpsize(operands[1],S_B);
                         stropsize := S_NO;
                         stropsize := S_NO;
-                        operands[2].size := S_W;
+                        CheckAndSetOpsize(operands[2],S_W);
                         addinstr(A_MOVSBW)
                         addinstr(A_MOVSBW)
                       end
                       end
                     else
                     else
@@ -1206,25 +1222,25 @@ var
               Begin
               Begin
                 if stropsize = S_BW then
                 if stropsize = S_BW then
                   begin
                   begin
-                    operands[1].size := S_B;
+                    CheckAndSetOpsize(operands[1],S_B);
                     stropsize := S_NO;
                     stropsize := S_NO;
-                    operands[2].size := S_W;
+                    CheckAndSetOpsize(operands[2],S_W);
                     addinstr(A_MOVZB)
                     addinstr(A_MOVZB)
                   end
                   end
                 else
                 else
                   if stropsize = S_BL then
                   if stropsize = S_BL then
                     begin
                     begin
-                      operands[1].size := S_B;
+                      CheckAndSetOpsize(operands[1],S_B);
                       stropsize := S_NO;
                       stropsize := S_NO;
-                      operands[2].size := S_L;
+                      CheckAndSetOpsize(operands[2],S_L);
                       addinstr(A_MOVZB)
                       addinstr(A_MOVZB)
                     end
                     end
                   else
                   else
                     if stropsize = S_WL then
                     if stropsize = S_WL then
                       begin
                       begin
-                        operands[1].size := S_W;
+                        CheckAndSetOpsize(operands[1],S_W);
                         stropsize := S_NO;
                         stropsize := S_NO;
-                        operands[2].size := S_L;
+                        CheckAndSetOpsize(operands[2],S_L);
                         addinstr(A_MOVZWL)
                         addinstr(A_MOVZWL)
                       end
                       end
                     else
                     else
@@ -1495,13 +1511,11 @@ var
      { REQUIRED for intasmi3)                                             }
      { REQUIRED for intasmi3)                                             }
         A_MOV,A_ADD,A_SUB,A_ADC,A_SBB,A_CMP,A_AND,A_OR,A_TEST,A_XOR:
         A_MOV,A_ADD,A_SUB,A_ADC,A_SBB,A_CMP,A_AND,A_OR,A_TEST,A_XOR:
           begin
           begin
-            if (instr.stropsize <> S_NO) and
-               (instr.operands[2].size <> S_NO) then
-              if (instr.stropsize <> instr.operands[2].size) then
-                begin
-                  Message(assem_e_size_suffix_and_dest_reg_dont_match);
-                  exit;
-                end;
+            if (instr.stropsize <> S_NO) then
+              Begin
+                 if not CheckAndSetOpsize(operands[1],instr.stropsize) or
+                    not CheckAndSetOpsize(operands[2],instr.stropsize) then
+              End;
           end;
           end;
         A_DEC,A_INC,A_NOT,A_NEG:
         A_DEC,A_INC,A_NOT,A_NEG:
           begin
           begin
@@ -3688,7 +3702,10 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.29  1999-01-10 15:37:54  peter
+  Revision 1.30  1999-01-28 14:12:59  pierre
+   * bug0175 solved give error on $R+ and warning otherwise
+
+  Revision 1.29  1999/01/10 15:37:54  peter
     * moved some tables from ra386*.pas -> i386.pas
     * moved some tables from ra386*.pas -> i386.pas
     + start of coff writer
     + start of coff writer
     * renamed asmutils unit to rautils
     * renamed asmutils unit to rautils