+ 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 -
This commit is contained in:
nickysn 2017-10-24 15:07:20 +00:00
parent fb57fd7324
commit e58bad8eef
11 changed files with 476 additions and 369 deletions

6
.gitattributes vendored
View File

@ -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

View File

@ -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
#

View File

@ -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
);

File diff suppressed because it is too large Load Diff

View File

@ -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
tests/test/tasm14a.pp Normal file
View File

@ -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
tests/test/tasm14b.pp Normal file
View File

@ -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
tests/test/tasm14c.pp Normal file
View File

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

12
tests/test/tasm14d.pp Normal file
View File

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

13
tests/test/tasm14e.pp Normal file
View File

@ -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
tests/test/tasm14f.pp Normal file
View File

@ -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.