浏览代码

+ check for the 'pop cs' instruction in the x86 inline assembler and print a
warning (on the i8086 target) or an error (on i386 and x86_64) when this
instruction is used (because it only works on 8086 and 8088 CPUs)

git-svn-id: trunk@37514 -

nickysn 7 年之前
父节点
当前提交
e58bad8eef
共有 11 个文件被更改,包括 408 次插入303 次删除
  1. 6 0
      .gitattributes
  2. 6 1
      compiler/msg/errore.msg
  3. 4 2
      compiler/msgidx.inc
  4. 305 300
      compiler/msgtxt.inc
  5. 13 0
      compiler/x86/rax86.pas
  6. 12 0
      tests/test/tasm14a.pp
  7. 12 0
      tests/test/tasm14b.pp
  8. 12 0
      tests/test/tasm14c.pp
  9. 12 0
      tests/test/tasm14d.pp
  10. 13 0
      tests/test/tasm14e.pp
  11. 13 0
      tests/test/tasm14f.pp

+ 6 - 0
.gitattributes

@@ -12401,6 +12401,12 @@ 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/tasm14a.pp svneol=native#text/plain
+tests/test/tasm14b.pp svneol=native#text/plain
+tests/test/tasm14c.pp svneol=native#text/plain
+tests/test/tasm14d.pp svneol=native#text/plain
+tests/test/tasm14e.pp svneol=native#text/plain
+tests/test/tasm14f.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

+ 6 - 1
compiler/msg/errore.msg

@@ -2483,7 +2483,7 @@ cg_f_max_units_reached=06057_F_Maximum number of units ($1) reached for the curr
 #
 # Assembler reader
 #
-# 07134 is the last used one
+# 07136 is the last used one
 #
 asmr_d_start_reading=07000_DL_Starting $1 styled assembler parsing
 % This informs you that an assembler block is being parsed
@@ -2812,6 +2812,11 @@ asmr_w_invalid_reference=07133_W_Reference is not valid here (expected "$1")
 asmr_e_address_sizes_do_not_match=07134_E_Address sizes do not match
 % Caused by using two memory operands in the same instruction with mismatched
 % address sizes (e.g. movs byte ptr [EDI], byte ptr [SI] )
+asmr_e_pop_cs_not_valid=07135_E_Instruction "POP CS" is not valid for the current target
+% The 'pop cs' instruction works only on the 8086 and 8088 CPUs, which are not
+% supported on the i386 or x86_64 targets.
+asmr_w_pop_cs_not_portable=07136_W_Instruction "POP CS" is not portable (it only works on 8086 and 8088 CPUs)
+% The 'pop cs' instruction doesn't work on any CPU, except 8086 and 8088.
 #
 # Assembler/binary writers
 #

+ 4 - 2
compiler/msgidx.inc

@@ -816,6 +816,8 @@ const
   asmr_e_cannot_override_es_segment=07132;
   asmr_w_invalid_reference=07133;
   asmr_e_address_sizes_do_not_match=07134;
+  asmr_e_pop_cs_not_valid=07135;
+  asmr_w_pop_cs_not_portable=07136;
   asmw_f_too_many_asm_files=08000;
   asmw_f_assembler_output_not_supported=08001;
   asmw_f_comp_not_supported=08002;
@@ -1086,9 +1088,9 @@ const
   option_info=11024;
   option_help_pages=11025;
 
-  MsgTxtSize = 80651;
+  MsgTxtSize = 80799;
 
   MsgIdxMax : array[1..20] of longint=(
-    27,105,347,124,96,58,135,33,221,67,
+    27,105,347,124,96,58,137,33,221,67,
     60,20,30,1,1,1,1,1,1,1
   );

文件差异内容过多而无法显示
+ 305 - 300
compiler/msgtxt.inc


+ 13 - 0
compiler/x86/rax86.pas

@@ -1209,6 +1209,19 @@ begin
        operands[2].opr.reg:=NR_ST0;
      end;
 
+   { Check for 'POP CS' }
+   if (opcode=A_POP) and (ops=1) and (operands[1].opr.typ=OPR_REGISTER) and
+      (operands[1].opr.reg=NR_CS) then
+{$ifdef i8086}
+     { On i8086 we print only a warning, because 'POP CS' works on 8086 and 8088
+       CPUs, but isn't supported on any later CPU }
+     Message(asmr_w_pop_cs_not_portable);
+{$else i8086}
+     { On the i386 and x86_64 targets, we print out an error, because no CPU,
+       supported by these targets support 'POP CS' }
+     Message(asmr_e_pop_cs_not_valid);
+{$endif i8086}
+
    { I tried to convince Linus Torvalds to add
      code to support ENTER instruction
      (when raising a stack page fault)

+ 12 - 0
tests/test/tasm14a.pp

@@ -0,0 +1,12 @@
+{ %CPU=i386,x86_64 }
+{ %fail }
+
+{ Pop CS should produce an error on i386 and x86_64 }
+
+{$asmmode intel}
+
+begin
+  asm
+    pop cs
+  end;
+end.

+ 12 - 0
tests/test/tasm14b.pp

@@ -0,0 +1,12 @@
+{ %CPU=i386,x86_64 }
+{ %fail }
+
+{ Pop CS should produce an error on i386 and x86_64 }
+
+{$asmmode att}
+
+begin
+  asm
+    popl %cs
+  end;
+end.

+ 12 - 0
tests/test/tasm14c.pp

@@ -0,0 +1,12 @@
+{ %CPU=i8086 }
+{ %NORUN }
+
+{ Pop CS should produce a warning on i8086 }
+
+{$asmmode intel}
+
+begin
+  asm
+    pop cs
+  end;
+end.

+ 12 - 0
tests/test/tasm14d.pp

@@ -0,0 +1,12 @@
+{ %CPU=i8086 }
+{ %NORUN }
+
+{ Pop CS should produce a warning on i8086 }
+
+{$asmmode att}
+
+begin
+  asm
+    popw %cs
+  end;
+end.

+ 13 - 0
tests/test/tasm14e.pp

@@ -0,0 +1,13 @@
+{ %CPU=i8086 }
+{ %OPT=-Sew }
+{ %fail }
+
+{ Pop CS should produce a warning on i8086 }
+
+{$asmmode intel}
+
+begin
+  asm
+    pop cs
+  end;
+end.

+ 13 - 0
tests/test/tasm14f.pp

@@ -0,0 +1,13 @@
+{ %CPU=i8086 }
+{ %OPT=-Sew }
+{ %fail }
+
+{ Pop CS should produce a warning on i8086 }
+
+{$asmmode att}
+
+begin
+  asm
+    popw %cs
+  end;
+end.

部分文件因为文件数量过多而无法显示