Browse Source

+ added the 'Cannot override ES' message in the at&t assembler reader as well

git-svn-id: trunk@37456 -
nickysn 7 years ago
parent
commit
dd9b5eb2aa
7 changed files with 111 additions and 0 deletions
  1. 5 0
      .gitattributes
  2. 16 0
      compiler/x86/rax86att.pas
  3. 18 0
      tests/test/tasm13f.pp
  4. 18 0
      tests/test/tasm13g.pp
  5. 18 0
      tests/test/tasm13h.pp
  6. 18 0
      tests/test/tasm13i.pp
  7. 18 0
      tests/test/tasm13j.pp

+ 5 - 0
.gitattributes

@@ -12393,6 +12393,11 @@ tests/test/tasm13b.pp svneol=native#text/plain
 tests/test/tasm13c.pp svneol=native#text/plain
 tests/test/tasm13d.pp svneol=native#text/plain
 tests/test/tasm13e.pp svneol=native#text/plain
+tests/test/tasm13f.pp svneol=native#text/plain
+tests/test/tasm13g.pp svneol=native#text/plain
+tests/test/tasm13h.pp svneol=native#text/plain
+tests/test/tasm13i.pp svneol=native#text/plain
+tests/test/tasm13j.pp svneol=native#text/plain
 tests/test/tasm2.inc svneol=native#text/plain
 tests/test/tasm2.pp svneol=native#text/plain
 tests/test/tasm2a.pp svneol=native#text/plain

+ 16 - 0
compiler/x86/rax86att.pas

@@ -786,6 +786,7 @@ Implementation
       var
         operandnum : longint;
         PrefixOp,OverrideOp: tasmop;
+        di_param: ShortInt;
       Begin
         PrefixOp:=A_None;
         OverrideOp:=A_None;
@@ -897,6 +898,21 @@ Implementation
                   opcode:=x86_param2paramless_string_op(opcode);
                 end;
             end;
+        { Check for invalid ES: overrides }
+        if is_x86_parameterized_string_op(instr.opcode) then
+          begin
+            di_param:=get_x86_string_op_di_param(instr.opcode);
+            if di_param<>-1 then
+              begin
+                di_param:=x86_parameterized_string_op_param_count(instr.opcode)-di_param;
+                if di_param<=operandnum then
+                  with instr.operands[di_param] do
+                    if (opr.typ=OPR_REFERENCE) and
+                       (opr.ref.segment<>NR_NO) and
+                       (opr.ref.segment<>NR_ES) then
+                      Message(asmr_e_cannot_override_es_segment);
+              end;
+          end;
       end;
 
 

+ 18 - 0
tests/test/tasm13f.pp

@@ -0,0 +1,18 @@
+{ %CPU=i8086,i386,x86_64 }
+{ %fail }
+
+{ Tests the 'Cannot override ES segment' error message }
+
+{$asmmode att}
+
+begin
+  asm
+{$if defined(cpui8086)}
+    movsb (%si), %ds:(%di)
+{$elseif defined(cpui386)}
+    movsb (%esi), %ds:(%edi)
+{$elseif defined(cpux86_64)}
+    movsb (%rsi), %fs:(%rdi)
+{$endif}
+  end;
+end.

+ 18 - 0
tests/test/tasm13g.pp

@@ -0,0 +1,18 @@
+{ %CPU=i8086,i386,x86_64 }
+{ %fail }
+
+{ Tests the 'Cannot override ES segment' error message }
+
+{$asmmode att}
+
+begin
+  asm
+{$if defined(cpui8086)}
+    cmpsb %ds:(%di), (%si)
+{$elseif defined(cpui386)}
+    cmpsb %ds:(%edi), (%esi)
+{$elseif defined(cpux86_64)}
+    cmpsb %fs:(%rdi), (%rsi)
+{$endif}
+  end;
+end.

+ 18 - 0
tests/test/tasm13h.pp

@@ -0,0 +1,18 @@
+{ %CPU=i8086,i386,x86_64 }
+{ %fail }
+
+{ Tests the 'Cannot override ES segment' error message }
+
+{$asmmode att}
+
+begin
+  asm
+{$if defined(cpui8086)}
+    scasb %ds:(%di)
+{$elseif defined(cpui386)}
+    scasb %ds:(%edi)
+{$elseif defined(cpux86_64)}
+    scasb %fs:(%rdi)
+{$endif}
+  end;
+end.

+ 18 - 0
tests/test/tasm13i.pp

@@ -0,0 +1,18 @@
+{ %CPU=i8086,i386,x86_64 }
+{ %fail }
+
+{ Tests the 'Cannot override ES segment' error message }
+
+{$asmmode att}
+
+begin
+  asm
+{$if defined(cpui8086)}
+    stosb %ds:(%di)
+{$elseif defined(cpui386)}
+    stosb %ds:(%edi)
+{$elseif defined(cpux86_64)}
+    stosb %fs:(%rdi)
+{$endif}
+  end;
+end.

+ 18 - 0
tests/test/tasm13j.pp

@@ -0,0 +1,18 @@
+{ %CPU=i8086,i386,x86_64 }
+{ %fail }
+
+{ Tests the 'Cannot override ES segment' error message }
+
+{$asmmode att}
+
+begin
+  asm
+{$if defined(cpui8086)}
+    insb %dx,%ds:(%di)
+{$elseif defined(cpui386)}
+    insb %dx,%ds:(%edi)
+{$elseif defined(cpux86_64)}
+    insb %dx,%fs:(%rdi)
+{$endif}
+  end;
+end.